diff options
Diffstat (limited to 'Windows/Window.h')
-rwxr-xr-x | Windows/Window.h | 107 |
1 files changed, 72 insertions, 35 deletions
diff --git a/Windows/Window.h b/Windows/Window.h index a3c670eb..c2818444 100755 --- a/Windows/Window.h +++ b/Windows/Window.h @@ -8,6 +8,21 @@ namespace NWindows { +inline ATOM MyRegisterClass(CONST WNDCLASS *wndClass) + { return ::RegisterClass(wndClass); } + +#ifndef _UNICODE +ATOM MyRegisterClass(CONST WNDCLASSW *wndClass); +#endif + +#ifdef _UNICODE +inline bool MySetWindowText(HWND wnd, LPCWSTR s) { return BOOLToBool(::SetWindowText(wnd, s)); } +#else +bool MySetWindowText(HWND wnd, LPCWSTR s); +#endif + + + class CWindow { private: @@ -22,8 +37,7 @@ public: return *this; } operator HWND() const { return _window; } - void Attach(HWND newWindow) - { _window = newWindow; } + void Attach(HWND newWindow) { _window = newWindow; } HWND Detach() { HWND window = _window; @@ -31,18 +45,11 @@ public: return window; } - HWND GetParent() const - { return ::GetParent(_window); } - bool GetWindowRect(LPRECT rect) const - { return BOOLToBool(::GetWindowRect(_window,rect )); } - bool IsZoomed() const - { return BOOLToBool(::IsZoomed(_window)); } - - bool ClientToScreen(LPPOINT point) const - { return BOOLToBool(::ClientToScreen(_window, point)); } - - bool ScreenToClient(LPPOINT point) const - { return BOOLToBool(::ScreenToClient(_window, point)); } + HWND GetParent() const { return ::GetParent(_window); } + bool GetWindowRect(LPRECT rect) const { return BOOLToBool(::GetWindowRect(_window,rect )); } + bool IsZoomed() const { return BOOLToBool(::IsZoomed(_window)); } + bool ClientToScreen(LPPOINT point) const { return BOOLToBool(::ClientToScreen(_window, point)); } + bool ScreenToClient(LPPOINT point) const { return BOOLToBool(::ScreenToClient(_window, point)); } bool CreateEx(DWORD exStyle, LPCTSTR className, LPCTSTR windowName, DWORD style, @@ -56,6 +63,32 @@ public: return (_window != NULL); } + bool Create(LPCTSTR className, + LPCTSTR windowName, DWORD style, + int x, int y, int width, int height, + HWND parentWindow, HMENU idOrHMenu, + HINSTANCE instance, LPVOID createParam) + { + _window = ::CreateWindow(className, windowName, + style, x, y, width, height, parentWindow, + idOrHMenu, instance, createParam); + return (_window != NULL); + } + + #ifndef _UNICODE + bool Create(LPCWSTR className, + LPCWSTR windowName, DWORD style, + int x, int y, int width, int height, + HWND parentWindow, HMENU idOrHMenu, + HINSTANCE instance, LPVOID createParam); + bool CreateEx(DWORD exStyle, LPCWSTR className, + LPCWSTR windowName, DWORD style, + int x, int y, int width, int height, + HWND parentWindow, HMENU idOrHMenu, + HINSTANCE instance, LPVOID createParam); + #endif + + bool Destroy() { if (_window == NULL) @@ -65,25 +98,17 @@ public: _window = NULL; return result; } - bool IsWindow() - { return BOOLToBool(::IsWindow(_window)); } + bool IsWindow() { return BOOLToBool(::IsWindow(_window)); } bool Move(int x, int y, int width, int height, bool repaint = true) { return BOOLToBool(::MoveWindow(_window, x, y, width, height, BoolToBOOL(repaint))); } - bool GetClientRect(LPRECT rect) - { return BOOLToBool(::GetClientRect(_window, rect)); } - bool Show(int cmdShow) - { return BOOLToBool(::ShowWindow(_window, cmdShow)); } - bool SetPlacement(CONST WINDOWPLACEMENT *placement) - { return BOOLToBool(::SetWindowPlacement(_window, placement)); } - bool GetPlacement(WINDOWPLACEMENT *placement) - { return BOOLToBool(::GetWindowPlacement(_window, placement)); } - - bool Update() - { return BOOLToBool(::UpdateWindow(_window)); } + bool GetClientRect(LPRECT rect) { return BOOLToBool(::GetClientRect(_window, rect)); } + bool Show(int cmdShow) { return BOOLToBool(::ShowWindow(_window, cmdShow)); } + bool SetPlacement(CONST WINDOWPLACEMENT *placement) { return BOOLToBool(::SetWindowPlacement(_window, placement)); } + bool GetPlacement(WINDOWPLACEMENT *placement) { return BOOLToBool(::GetWindowPlacement(_window, placement)); } + bool Update() { return BOOLToBool(::UpdateWindow(_window)); } bool InvalidateRect(LPCRECT rect, bool backgroundErase = true) { return BOOLToBool(::InvalidateRect(_window, rect, BoolToBOOL(backgroundErase))); } - void SetRedraw(bool redraw = true) - { SendMessage(WM_SETREDRAW, BoolToBOOL(redraw), 0); } + void SetRedraw(bool redraw = true) { SendMessage(WM_SETREDRAW, BoolToBOOL(redraw), 0); } #ifndef _WIN32_WCE LONG SetStyle(LONG_PTR style) @@ -109,6 +134,11 @@ public: #ifndef _WIN32_WCE LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr ) { return ::SetWindowLongPtr(_window, index, newLongPtr); } + #ifndef _UNICODE + LONG_PTR SetLongPtrW(int index, LONG_PTR newLongPtr ) + { return ::SetWindowLongPtrW(_window, index, newLongPtr); } + #endif + LONG_PTR GetLongPtr(int index) const { return ::GetWindowLongPtr(_window, index ); } LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr ) @@ -124,18 +154,25 @@ public: { return ModifyStyleBase(GWL_EXSTYLE, remove, add, flags); } */ - HWND SetFocus() - { return ::SetFocus(_window); } + HWND SetFocus() { return ::SetFocus(_window); } LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) - { return ::SendMessage(_window, message, wParam, lParam) ;} + { return ::SendMessage(_window, message, wParam, lParam) ;} + #ifndef _UNICODE + LRESULT SendMessageW(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) + { return ::SendMessageW(_window, message, wParam, lParam) ;} + #endif + bool PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) { return BOOLToBool(::PostMessage(_window, message, wParam, lParam)) ;} + #ifndef _UNICODE + LRESULT PostMessageW(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) + { return ::PostMessageW(_window, message, wParam, lParam) ;} + #endif - bool SetText(LPCTSTR s) - { return BOOLToBool(::SetWindowText(_window, s)); } + bool SetText(LPCTSTR s) { return BOOLToBool(::SetWindowText(_window, s)); } #ifndef _UNICODE - bool CWindow::SetText(LPCWSTR s); + bool CWindow::SetText(LPCWSTR s) { return MySetWindowText(_window, s); } #endif int GetTextLength() const |