xref: /aosp_15_r20/external/lzma/CPP/Windows/Window.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1*f6dc9357SAndroid Build Coastguard Worker // Windows/Window.h
2*f6dc9357SAndroid Build Coastguard Worker 
3*f6dc9357SAndroid Build Coastguard Worker #ifndef ZIP7_INC_WINDOWS_WINDOW_H
4*f6dc9357SAndroid Build Coastguard Worker #define ZIP7_INC_WINDOWS_WINDOW_H
5*f6dc9357SAndroid Build Coastguard Worker 
6*f6dc9357SAndroid Build Coastguard Worker #include "../Common/MyWindows.h"
7*f6dc9357SAndroid Build Coastguard Worker #include "../Common/MyString.h"
8*f6dc9357SAndroid Build Coastguard Worker 
9*f6dc9357SAndroid Build Coastguard Worker #include "Defs.h"
10*f6dc9357SAndroid Build Coastguard Worker 
11*f6dc9357SAndroid Build Coastguard Worker #ifndef UNDER_CE
12*f6dc9357SAndroid Build Coastguard Worker #ifdef WM_CHANGEUISTATE
13*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_WM_CHANGEUISTATE  WM_CHANGEUISTATE
14*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_WM_UPDATEUISTATE  WM_UPDATEUISTATE
15*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_WM_QUERYUISTATE   WM_QUERYUISTATE
16*f6dc9357SAndroid Build Coastguard Worker #else
17*f6dc9357SAndroid Build Coastguard Worker // these are defined for (_WIN32_WINNT >= 0x0500):
18*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_WM_CHANGEUISTATE  0x0127
19*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_WM_UPDATEUISTATE  0x0128
20*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_WM_QUERYUISTATE   0x0129
21*f6dc9357SAndroid Build Coastguard Worker #endif
22*f6dc9357SAndroid Build Coastguard Worker 
23*f6dc9357SAndroid Build Coastguard Worker #ifdef UIS_SET
24*f6dc9357SAndroid Build Coastguard Worker 
25*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UIS_SET         UIS_SET
26*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UIS_CLEAR       UIS_CLEAR
27*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UIS_INITIALIZE  UIS_INITIALIZE
28*f6dc9357SAndroid Build Coastguard Worker 
29*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UISF_HIDEFOCUS  UISF_HIDEFOCUS
30*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UISF_HIDEACCEL  UISF_HIDEACCEL
31*f6dc9357SAndroid Build Coastguard Worker 
32*f6dc9357SAndroid Build Coastguard Worker #else
33*f6dc9357SAndroid Build Coastguard Worker // these are defined for (_WIN32_WINNT >= 0x0500):
34*f6dc9357SAndroid Build Coastguard Worker // LOWORD(wParam) values in WM_*UISTATE
35*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UIS_SET         1
36*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UIS_CLEAR       2
37*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UIS_INITIALIZE  3
38*f6dc9357SAndroid Build Coastguard Worker 
39*f6dc9357SAndroid Build Coastguard Worker // HIWORD(wParam) values in WM_*UISTATE
40*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UISF_HIDEFOCUS  0x1
41*f6dc9357SAndroid Build Coastguard Worker #define Z7_WIN_UISF_HIDEACCEL  0x2
42*f6dc9357SAndroid Build Coastguard Worker // defined for for (_WIN32_WINNT >= 0x0501):
43*f6dc9357SAndroid Build Coastguard Worker // #define Z7_WIN_UISF_ACTIVE     0x4
44*f6dc9357SAndroid Build Coastguard Worker 
45*f6dc9357SAndroid Build Coastguard Worker #endif
46*f6dc9357SAndroid Build Coastguard Worker 
47*f6dc9357SAndroid Build Coastguard Worker #endif // UNDER_CE
48*f6dc9357SAndroid Build Coastguard Worker 
49*f6dc9357SAndroid Build Coastguard Worker 
50*f6dc9357SAndroid Build Coastguard Worker #ifdef Z7_OLD_WIN_SDK
51*f6dc9357SAndroid Build Coastguard Worker 
52*f6dc9357SAndroid Build Coastguard Worker // #define VK_OEM_1          0xBA   // ';:' for US
53*f6dc9357SAndroid Build Coastguard Worker #define VK_OEM_PLUS       0xBB   // '+' any country
54*f6dc9357SAndroid Build Coastguard Worker // #define VK_OEM_COMMA      0xBC   // ',' any country
55*f6dc9357SAndroid Build Coastguard Worker #define VK_OEM_MINUS      0xBD   // '-' any country
56*f6dc9357SAndroid Build Coastguard Worker // #define VK_OEM_PERIOD     0xBE   // '.' any country
57*f6dc9357SAndroid Build Coastguard Worker // #define VK_OEM_2          0xBF   // '/?' for US
58*f6dc9357SAndroid Build Coastguard Worker // #define VK_OEM_3          0xC0   // '`~' for US
59*f6dc9357SAndroid Build Coastguard Worker 
60*f6dc9357SAndroid Build Coastguard Worker // #ifndef GWLP_USERDATA
61*f6dc9357SAndroid Build Coastguard Worker #define GWLP_WNDPROC        (-4)
62*f6dc9357SAndroid Build Coastguard Worker #define GWLP_USERDATA       (-21)
63*f6dc9357SAndroid Build Coastguard Worker // #endif
64*f6dc9357SAndroid Build Coastguard Worker #define DWLP_MSGRESULT  0
65*f6dc9357SAndroid Build Coastguard Worker // #define DWLP_DLGPROC    DWLP_MSGRESULT + sizeof(LRESULT)
66*f6dc9357SAndroid Build Coastguard Worker // #define DWLP_USER       DWLP_DLGPROC + sizeof(DLGPROC)
67*f6dc9357SAndroid Build Coastguard Worker 
68*f6dc9357SAndroid Build Coastguard Worker #define BTNS_BUTTON     TBSTYLE_BUTTON      // 0x0000
69*f6dc9357SAndroid Build Coastguard Worker 
70*f6dc9357SAndroid Build Coastguard Worker /*
71*f6dc9357SAndroid Build Coastguard Worker vc6 defines INT_PTR via long:
72*f6dc9357SAndroid Build Coastguard Worker   typedef long INT_PTR, *PINT_PTR;
73*f6dc9357SAndroid Build Coastguard Worker   typedef unsigned long UINT_PTR, *PUINT_PTR;
74*f6dc9357SAndroid Build Coastguard Worker but newer sdk (sdk2003+) defines INT_PTR via int:
75*f6dc9357SAndroid Build Coastguard Worker   typedef _W64 int INT_PTR, *PINT_PTR;
76*f6dc9357SAndroid Build Coastguard Worker   typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
77*f6dc9357SAndroid Build Coastguard Worker */
78*f6dc9357SAndroid Build Coastguard Worker 
79*f6dc9357SAndroid Build Coastguard Worker #define IS_INTRESOURCE(_r) (((ULONG_PTR)(_r) >> 16) == 0)
80*f6dc9357SAndroid Build Coastguard Worker 
81*f6dc9357SAndroid Build Coastguard Worker #define GetWindowLongPtrA   GetWindowLongA
82*f6dc9357SAndroid Build Coastguard Worker #define GetWindowLongPtrW   GetWindowLongW
83*f6dc9357SAndroid Build Coastguard Worker #ifdef UNICODE
84*f6dc9357SAndroid Build Coastguard Worker #define GetWindowLongPtr  GetWindowLongPtrW
85*f6dc9357SAndroid Build Coastguard Worker #else
86*f6dc9357SAndroid Build Coastguard Worker #define GetWindowLongPtr  GetWindowLongPtrA
87*f6dc9357SAndroid Build Coastguard Worker #endif // !UNICODE
88*f6dc9357SAndroid Build Coastguard Worker 
89*f6dc9357SAndroid Build Coastguard Worker #define SetWindowLongPtrA   SetWindowLongA
90*f6dc9357SAndroid Build Coastguard Worker #define SetWindowLongPtrW   SetWindowLongW
91*f6dc9357SAndroid Build Coastguard Worker #ifdef UNICODE
92*f6dc9357SAndroid Build Coastguard Worker #define SetWindowLongPtr  SetWindowLongPtrW
93*f6dc9357SAndroid Build Coastguard Worker #else
94*f6dc9357SAndroid Build Coastguard Worker #define SetWindowLongPtr  SetWindowLongPtrA
95*f6dc9357SAndroid Build Coastguard Worker #endif // !UNICODE
96*f6dc9357SAndroid Build Coastguard Worker 
97*f6dc9357SAndroid Build Coastguard Worker #define ListView_SetCheckState(hwndLV, i, fCheck) \
98*f6dc9357SAndroid Build Coastguard Worker   ListView_SetItemState(hwndLV, i, INDEXTOSTATEIMAGEMASK((fCheck)?2:1), LVIS_STATEIMAGEMASK)
99*f6dc9357SAndroid Build Coastguard Worker 
100*f6dc9357SAndroid Build Coastguard Worker #endif // Z7_OLD_WIN_SDK
101*f6dc9357SAndroid Build Coastguard Worker 
LRESULTToBool(LRESULT v)102*f6dc9357SAndroid Build Coastguard Worker inline bool LRESULTToBool(LRESULT v) { return (v != FALSE); }
103*f6dc9357SAndroid Build Coastguard Worker 
104*f6dc9357SAndroid Build Coastguard Worker #define MY_int_TO_WPARAM(i) ((WPARAM)(INT_PTR)(i))
105*f6dc9357SAndroid Build Coastguard Worker 
106*f6dc9357SAndroid Build Coastguard Worker namespace NWindows {
107*f6dc9357SAndroid Build Coastguard Worker 
MyRegisterClass(CONST WNDCLASS * wndClass)108*f6dc9357SAndroid Build Coastguard Worker inline ATOM MyRegisterClass(CONST WNDCLASS *wndClass)
109*f6dc9357SAndroid Build Coastguard Worker   { return ::RegisterClass(wndClass); }
110*f6dc9357SAndroid Build Coastguard Worker 
111*f6dc9357SAndroid Build Coastguard Worker #ifndef _UNICODE
112*f6dc9357SAndroid Build Coastguard Worker ATOM MyRegisterClass(CONST WNDCLASSW *wndClass);
113*f6dc9357SAndroid Build Coastguard Worker #endif
114*f6dc9357SAndroid Build Coastguard Worker 
115*f6dc9357SAndroid Build Coastguard Worker #ifdef _UNICODE
MySetWindowText(HWND wnd,LPCWSTR s)116*f6dc9357SAndroid Build Coastguard Worker inline bool MySetWindowText(HWND wnd, LPCWSTR s) { return BOOLToBool(::SetWindowText(wnd, s)); }
117*f6dc9357SAndroid Build Coastguard Worker #else
118*f6dc9357SAndroid Build Coastguard Worker bool MySetWindowText(HWND wnd, LPCWSTR s);
119*f6dc9357SAndroid Build Coastguard Worker #endif
120*f6dc9357SAndroid Build Coastguard Worker 
121*f6dc9357SAndroid Build Coastguard Worker 
122*f6dc9357SAndroid Build Coastguard Worker #ifdef UNDER_CE
123*f6dc9357SAndroid Build Coastguard Worker #define GWLP_USERDATA GWL_USERDATA
124*f6dc9357SAndroid Build Coastguard Worker #define GWLP_WNDPROC GWL_WNDPROC
125*f6dc9357SAndroid Build Coastguard Worker #define BTNS_BUTTON TBSTYLE_BUTTON
126*f6dc9357SAndroid Build Coastguard Worker #define WC_COMBOBOXW L"ComboBox"
127*f6dc9357SAndroid Build Coastguard Worker #define DWLP_MSGRESULT DWL_MSGRESULT
128*f6dc9357SAndroid Build Coastguard Worker #endif
129*f6dc9357SAndroid Build Coastguard Worker 
130*f6dc9357SAndroid Build Coastguard Worker class CWindow
131*f6dc9357SAndroid Build Coastguard Worker {
Z7_CLASS_NO_COPY(CWindow)132*f6dc9357SAndroid Build Coastguard Worker   Z7_CLASS_NO_COPY(CWindow)
133*f6dc9357SAndroid Build Coastguard Worker private:
134*f6dc9357SAndroid Build Coastguard Worker   // bool ModifyStyleBase(int styleOffset, DWORD remove, DWORD add, UINT flags);
135*f6dc9357SAndroid Build Coastguard Worker protected:
136*f6dc9357SAndroid Build Coastguard Worker   HWND _window;
137*f6dc9357SAndroid Build Coastguard Worker public:
138*f6dc9357SAndroid Build Coastguard Worker   CWindow(HWND newWindow = NULL): _window(newWindow) {}
139*f6dc9357SAndroid Build Coastguard Worker   CWindow& operator=(HWND newWindow)
140*f6dc9357SAndroid Build Coastguard Worker   {
141*f6dc9357SAndroid Build Coastguard Worker     _window = newWindow;
142*f6dc9357SAndroid Build Coastguard Worker     return *this;
143*f6dc9357SAndroid Build Coastguard Worker   }
HWND()144*f6dc9357SAndroid Build Coastguard Worker   operator HWND() const { return _window; }
Attach(HWND newWindow)145*f6dc9357SAndroid Build Coastguard Worker   void Attach(HWND newWindow) { _window = newWindow; }
Detach()146*f6dc9357SAndroid Build Coastguard Worker   HWND Detach()
147*f6dc9357SAndroid Build Coastguard Worker   {
148*f6dc9357SAndroid Build Coastguard Worker     HWND window = _window;
149*f6dc9357SAndroid Build Coastguard Worker     _window = NULL;
150*f6dc9357SAndroid Build Coastguard Worker     return window;
151*f6dc9357SAndroid Build Coastguard Worker   }
152*f6dc9357SAndroid Build Coastguard Worker 
Foreground()153*f6dc9357SAndroid Build Coastguard Worker   bool Foreground() { return BOOLToBool(::SetForegroundWindow(_window)); }
154*f6dc9357SAndroid Build Coastguard Worker 
GetParent()155*f6dc9357SAndroid Build Coastguard Worker   HWND GetParent() const { return ::GetParent(_window); }
GetWindowRect(LPRECT rect)156*f6dc9357SAndroid Build Coastguard Worker   bool GetWindowRect(LPRECT rect) const { return BOOLToBool(::GetWindowRect(_window,rect)); }
157*f6dc9357SAndroid Build Coastguard Worker   #ifndef UNDER_CE
IsZoomed()158*f6dc9357SAndroid Build Coastguard Worker   bool IsZoomed() const { return BOOLToBool(::IsZoomed(_window)); }
159*f6dc9357SAndroid Build Coastguard Worker   #endif
ClientToScreen(LPPOINT point)160*f6dc9357SAndroid Build Coastguard Worker   bool ClientToScreen(LPPOINT point) const { return BOOLToBool(::ClientToScreen(_window, point)); }
ScreenToClient(LPPOINT point)161*f6dc9357SAndroid Build Coastguard Worker   bool ScreenToClient(LPPOINT point) const { return BOOLToBool(::ScreenToClient(_window, point)); }
162*f6dc9357SAndroid Build Coastguard Worker 
CreateEx(DWORD exStyle,LPCTSTR className,LPCTSTR windowName,DWORD style,int x,int y,int width,int height,HWND parentWindow,HMENU idOrHMenu,HINSTANCE instance,LPVOID createParam)163*f6dc9357SAndroid Build Coastguard Worker   bool CreateEx(DWORD exStyle, LPCTSTR className,
164*f6dc9357SAndroid Build Coastguard Worker       LPCTSTR windowName, DWORD style,
165*f6dc9357SAndroid Build Coastguard Worker       int x, int y, int width, int height,
166*f6dc9357SAndroid Build Coastguard Worker       HWND parentWindow, HMENU idOrHMenu,
167*f6dc9357SAndroid Build Coastguard Worker       HINSTANCE instance, LPVOID createParam)
168*f6dc9357SAndroid Build Coastguard Worker   {
169*f6dc9357SAndroid Build Coastguard Worker     _window = ::CreateWindowEx(exStyle, className, windowName,
170*f6dc9357SAndroid Build Coastguard Worker       style, x, y, width, height, parentWindow,
171*f6dc9357SAndroid Build Coastguard Worker       idOrHMenu, instance, createParam);
172*f6dc9357SAndroid Build Coastguard Worker     return (_window != NULL);
173*f6dc9357SAndroid Build Coastguard Worker   }
174*f6dc9357SAndroid Build Coastguard Worker 
Create(LPCTSTR className,LPCTSTR windowName,DWORD style,int x,int y,int width,int height,HWND parentWindow,HMENU idOrHMenu,HINSTANCE instance,LPVOID createParam)175*f6dc9357SAndroid Build Coastguard Worker   bool Create(LPCTSTR className,
176*f6dc9357SAndroid Build Coastguard Worker       LPCTSTR windowName, DWORD style,
177*f6dc9357SAndroid Build Coastguard Worker       int x, int y, int width, int height,
178*f6dc9357SAndroid Build Coastguard Worker       HWND parentWindow, HMENU idOrHMenu,
179*f6dc9357SAndroid Build Coastguard Worker       HINSTANCE instance, LPVOID createParam)
180*f6dc9357SAndroid Build Coastguard Worker   {
181*f6dc9357SAndroid Build Coastguard Worker     _window = ::CreateWindow(className, windowName,
182*f6dc9357SAndroid Build Coastguard Worker       style, x, y, width, height, parentWindow,
183*f6dc9357SAndroid Build Coastguard Worker       idOrHMenu, instance, createParam);
184*f6dc9357SAndroid Build Coastguard Worker     return (_window != NULL);
185*f6dc9357SAndroid Build Coastguard Worker   }
186*f6dc9357SAndroid Build Coastguard Worker 
187*f6dc9357SAndroid Build Coastguard Worker   #ifndef _UNICODE
188*f6dc9357SAndroid Build Coastguard Worker   bool Create(LPCWSTR className,
189*f6dc9357SAndroid Build Coastguard Worker       LPCWSTR windowName, DWORD style,
190*f6dc9357SAndroid Build Coastguard Worker       int x, int y, int width, int height,
191*f6dc9357SAndroid Build Coastguard Worker       HWND parentWindow, HMENU idOrHMenu,
192*f6dc9357SAndroid Build Coastguard Worker       HINSTANCE instance, LPVOID createParam);
193*f6dc9357SAndroid Build Coastguard Worker   bool CreateEx(DWORD exStyle, LPCWSTR className,
194*f6dc9357SAndroid Build Coastguard Worker       LPCWSTR windowName, DWORD style,
195*f6dc9357SAndroid Build Coastguard Worker       int x, int y, int width, int height,
196*f6dc9357SAndroid Build Coastguard Worker       HWND parentWindow, HMENU idOrHMenu,
197*f6dc9357SAndroid Build Coastguard Worker       HINSTANCE instance, LPVOID createParam);
198*f6dc9357SAndroid Build Coastguard Worker   #endif
199*f6dc9357SAndroid Build Coastguard Worker 
200*f6dc9357SAndroid Build Coastguard Worker 
Destroy()201*f6dc9357SAndroid Build Coastguard Worker   bool Destroy()
202*f6dc9357SAndroid Build Coastguard Worker   {
203*f6dc9357SAndroid Build Coastguard Worker     if (_window == NULL)
204*f6dc9357SAndroid Build Coastguard Worker       return true;
205*f6dc9357SAndroid Build Coastguard Worker     bool result = BOOLToBool(::DestroyWindow(_window));
206*f6dc9357SAndroid Build Coastguard Worker     if (result)
207*f6dc9357SAndroid Build Coastguard Worker       _window = NULL;
208*f6dc9357SAndroid Build Coastguard Worker     return result;
209*f6dc9357SAndroid Build Coastguard Worker   }
IsWindow()210*f6dc9357SAndroid Build Coastguard Worker   bool IsWindow() {  return BOOLToBool(::IsWindow(_window)); }
211*f6dc9357SAndroid Build Coastguard Worker   bool Move(int x, int y, int width, int height, bool repaint = true)
212*f6dc9357SAndroid Build Coastguard Worker     { return BOOLToBool(::MoveWindow(_window, x, y, width, height, BoolToBOOL(repaint))); }
213*f6dc9357SAndroid Build Coastguard Worker 
ChangeSubWindowSizeX(HWND hwnd,int xSize)214*f6dc9357SAndroid Build Coastguard Worker   bool ChangeSubWindowSizeX(HWND hwnd, int xSize)
215*f6dc9357SAndroid Build Coastguard Worker   {
216*f6dc9357SAndroid Build Coastguard Worker     RECT rect;
217*f6dc9357SAndroid Build Coastguard Worker     ::GetWindowRect(hwnd, &rect);
218*f6dc9357SAndroid Build Coastguard Worker     POINT p1;
219*f6dc9357SAndroid Build Coastguard Worker     p1.x = rect.left;
220*f6dc9357SAndroid Build Coastguard Worker     p1.y = rect.top;
221*f6dc9357SAndroid Build Coastguard Worker     ScreenToClient(&p1);
222*f6dc9357SAndroid Build Coastguard Worker     return BOOLToBool(::MoveWindow(hwnd, p1.x, p1.y, xSize, rect.bottom - rect.top, TRUE));
223*f6dc9357SAndroid Build Coastguard Worker   }
224*f6dc9357SAndroid Build Coastguard Worker 
ScreenToClient(RECT * rect)225*f6dc9357SAndroid Build Coastguard Worker   void ScreenToClient(RECT *rect)
226*f6dc9357SAndroid Build Coastguard Worker   {
227*f6dc9357SAndroid Build Coastguard Worker     POINT p1, p2;
228*f6dc9357SAndroid Build Coastguard Worker     p1.x = rect->left;
229*f6dc9357SAndroid Build Coastguard Worker     p1.y = rect->top;
230*f6dc9357SAndroid Build Coastguard Worker     p2.x = rect->right;
231*f6dc9357SAndroid Build Coastguard Worker     p2.y = rect->bottom;
232*f6dc9357SAndroid Build Coastguard Worker     ScreenToClient(&p1);
233*f6dc9357SAndroid Build Coastguard Worker     ScreenToClient(&p2);
234*f6dc9357SAndroid Build Coastguard Worker 
235*f6dc9357SAndroid Build Coastguard Worker     rect->left = p1.x;
236*f6dc9357SAndroid Build Coastguard Worker     rect->top = p1.y;
237*f6dc9357SAndroid Build Coastguard Worker     rect->right = p2.x;
238*f6dc9357SAndroid Build Coastguard Worker     rect->bottom = p2.y;
239*f6dc9357SAndroid Build Coastguard Worker   }
240*f6dc9357SAndroid Build Coastguard Worker 
GetClientRect(LPRECT rect)241*f6dc9357SAndroid Build Coastguard Worker   bool GetClientRect(LPRECT rect) { return BOOLToBool(::GetClientRect(_window, rect)); }
Show(int cmdShow)242*f6dc9357SAndroid Build Coastguard Worker   bool Show(int cmdShow) { return BOOLToBool(::ShowWindow(_window, cmdShow)); }
Show_Bool(bool show)243*f6dc9357SAndroid Build Coastguard Worker   bool Show_Bool(bool show) { return Show(show ? SW_SHOW: SW_HIDE); }
244*f6dc9357SAndroid Build Coastguard Worker 
245*f6dc9357SAndroid Build Coastguard Worker   #ifndef UNDER_CE
SetPlacement(CONST WINDOWPLACEMENT * placement)246*f6dc9357SAndroid Build Coastguard Worker   bool SetPlacement(CONST WINDOWPLACEMENT *placement) { return BOOLToBool(::SetWindowPlacement(_window, placement)); }
GetPlacement(WINDOWPLACEMENT * placement)247*f6dc9357SAndroid Build Coastguard Worker   bool GetPlacement(WINDOWPLACEMENT *placement) { return BOOLToBool(::GetWindowPlacement(_window, placement)); }
248*f6dc9357SAndroid Build Coastguard Worker   #endif
Update()249*f6dc9357SAndroid Build Coastguard Worker   bool Update() { return BOOLToBool(::UpdateWindow(_window)); }
250*f6dc9357SAndroid Build Coastguard Worker   bool InvalidateRect(LPCRECT rect, bool backgroundErase = true)
251*f6dc9357SAndroid Build Coastguard Worker     { return BOOLToBool(::InvalidateRect(_window, rect, BoolToBOOL(backgroundErase))); }
252*f6dc9357SAndroid Build Coastguard Worker   void SetRedraw(bool redraw = true) { SendMsg(WM_SETREDRAW, (WPARAM)BoolToBOOL(redraw), 0); }
253*f6dc9357SAndroid Build Coastguard Worker 
SetStyle(LONG_PTR style)254*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR SetStyle(LONG_PTR style) { return SetLongPtr(GWL_STYLE, style); }
255*f6dc9357SAndroid Build Coastguard Worker   // LONG_PTR SetStyle(DWORD style) { return SetLongPtr(GWL_STYLE, (LONG_PTR)style); }
GetStyle()256*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR GetStyle() const { return GetLongPtr(GWL_STYLE); }
257*f6dc9357SAndroid Build Coastguard Worker   // bool MyIsMaximized() const { return ((GetStyle() & WS_MAXIMIZE) != 0); }
258*f6dc9357SAndroid Build Coastguard Worker 
SetLong(int index,LONG newLongPtr)259*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR SetLong(int index, LONG newLongPtr) { return ::SetWindowLong(_window, index, newLongPtr); }
GetLong(int index)260*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR GetLong(int index) const { return ::GetWindowLong(_window, index); }
SetUserDataLong(LONG newLongPtr)261*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR SetUserDataLong(LONG newLongPtr) { return SetLong(GWLP_USERDATA, newLongPtr); }
GetUserDataLong()262*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR GetUserDataLong() const { return GetLong(GWLP_USERDATA); }
263*f6dc9357SAndroid Build Coastguard Worker 
264*f6dc9357SAndroid Build Coastguard Worker 
265*f6dc9357SAndroid Build Coastguard Worker   #ifdef UNDER_CE
266*f6dc9357SAndroid Build Coastguard Worker 
SetLongPtr(int index,LONG_PTR newLongPtr)267*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr) { return SetLong(index, newLongPtr); }
GetLongPtr(int index)268*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR GetLongPtr(int index) const { return GetLong(index); }
269*f6dc9357SAndroid Build Coastguard Worker 
SetUserDataLongPtr(LONG_PTR newLongPtr)270*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr) { return SetUserDataLong(newLongPtr); }
GetUserDataLongPtr()271*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR GetUserDataLongPtr() const { return GetUserDataLong(); }
272*f6dc9357SAndroid Build Coastguard Worker 
273*f6dc9357SAndroid Build Coastguard Worker   #else
274*f6dc9357SAndroid Build Coastguard Worker 
SetLongPtr(int index,LONG_PTR newLongPtr)275*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr)
276*f6dc9357SAndroid Build Coastguard Worker     { return ::SetWindowLongPtr(_window, index,
277*f6dc9357SAndroid Build Coastguard Worker           #ifndef _WIN64
278*f6dc9357SAndroid Build Coastguard Worker           (LONG)
279*f6dc9357SAndroid Build Coastguard Worker           #endif
280*f6dc9357SAndroid Build Coastguard Worker           newLongPtr); }
281*f6dc9357SAndroid Build Coastguard Worker   #ifndef _UNICODE
SetLongPtrW(int index,LONG_PTR newLongPtr)282*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR SetLongPtrW(int index, LONG_PTR newLongPtr)
283*f6dc9357SAndroid Build Coastguard Worker     { return ::SetWindowLongPtrW(_window, index,
284*f6dc9357SAndroid Build Coastguard Worker           #ifndef _WIN64
285*f6dc9357SAndroid Build Coastguard Worker           (LONG)
286*f6dc9357SAndroid Build Coastguard Worker           #endif
287*f6dc9357SAndroid Build Coastguard Worker           newLongPtr); }
288*f6dc9357SAndroid Build Coastguard Worker   #endif
289*f6dc9357SAndroid Build Coastguard Worker 
GetLongPtr(int index)290*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR GetLongPtr(int index) const { return ::GetWindowLongPtr(_window, index); }
SetUserDataLongPtr(LONG_PTR newLongPtr)291*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr) { return SetLongPtr(GWLP_USERDATA, newLongPtr); }
GetUserDataLongPtr()292*f6dc9357SAndroid Build Coastguard Worker   LONG_PTR GetUserDataLongPtr() const { return GetLongPtr(GWLP_USERDATA); }
293*f6dc9357SAndroid Build Coastguard Worker 
294*f6dc9357SAndroid Build Coastguard Worker   #endif
295*f6dc9357SAndroid Build Coastguard Worker 
296*f6dc9357SAndroid Build Coastguard Worker   /*
297*f6dc9357SAndroid Build Coastguard Worker   bool ModifyStyle(HWND hWnd, DWORD remove, DWORD add, UINT flags = 0)
298*f6dc9357SAndroid Build Coastguard Worker     {  return ModifyStyleBase(GWL_STYLE, remove, add, flags); }
299*f6dc9357SAndroid Build Coastguard Worker   bool ModifyStyleEx(HWND hWnd, DWORD remove, DWORD add, UINT flags = 0)
300*f6dc9357SAndroid Build Coastguard Worker     { return ModifyStyleBase(GWL_EXSTYLE, remove, add, flags); }
301*f6dc9357SAndroid Build Coastguard Worker   */
302*f6dc9357SAndroid Build Coastguard Worker 
SetFocus()303*f6dc9357SAndroid Build Coastguard Worker   HWND SetFocus() { return ::SetFocus(_window); }
304*f6dc9357SAndroid Build Coastguard Worker 
305*f6dc9357SAndroid Build Coastguard Worker   LRESULT SendMsg(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
306*f6dc9357SAndroid Build Coastguard Worker     { return ::SendMessage(_window, message, wParam, lParam); }
307*f6dc9357SAndroid Build Coastguard Worker   #ifndef _UNICODE
308*f6dc9357SAndroid Build Coastguard Worker   LRESULT SendMsgW(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
309*f6dc9357SAndroid Build Coastguard Worker     { return ::SendMessageW(_window, message, wParam, lParam); }
310*f6dc9357SAndroid Build Coastguard Worker   #endif
311*f6dc9357SAndroid Build Coastguard Worker 
312*f6dc9357SAndroid Build Coastguard Worker   bool PostMsg(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
313*f6dc9357SAndroid Build Coastguard Worker     { return BOOLToBool(::PostMessage(_window, message, wParam, lParam)); }
314*f6dc9357SAndroid Build Coastguard Worker   #ifndef _UNICODE
315*f6dc9357SAndroid Build Coastguard Worker   bool PostMsgW(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)
316*f6dc9357SAndroid Build Coastguard Worker     { return BOOLToBool(::PostMessageW(_window, message, wParam, lParam)); }
317*f6dc9357SAndroid Build Coastguard Worker   #endif
318*f6dc9357SAndroid Build Coastguard Worker 
SetText(LPCTSTR s)319*f6dc9357SAndroid Build Coastguard Worker   bool SetText(LPCTSTR s) { return BOOLToBool(::SetWindowText(_window, s)); }
320*f6dc9357SAndroid Build Coastguard Worker   #ifndef _UNICODE
SetText(LPCWSTR s)321*f6dc9357SAndroid Build Coastguard Worker   bool SetText(LPCWSTR s) { return MySetWindowText(_window, s); }
322*f6dc9357SAndroid Build Coastguard Worker   #endif
323*f6dc9357SAndroid Build Coastguard Worker 
GetTextLength()324*f6dc9357SAndroid Build Coastguard Worker   int GetTextLength() const
325*f6dc9357SAndroid Build Coastguard Worker     { return GetWindowTextLength(_window); }
GetText(LPTSTR string,int maxCount)326*f6dc9357SAndroid Build Coastguard Worker   int GetText(LPTSTR string, int maxCount) const
327*f6dc9357SAndroid Build Coastguard Worker     { return GetWindowText(_window, string, maxCount); }
328*f6dc9357SAndroid Build Coastguard Worker   bool GetText(CSysString &s) const;
329*f6dc9357SAndroid Build Coastguard Worker   #ifndef _UNICODE
330*f6dc9357SAndroid Build Coastguard Worker   /*
331*f6dc9357SAndroid Build Coastguard Worker   UINT GetText(LPWSTR string, int maxCount) const
332*f6dc9357SAndroid Build Coastguard Worker     { return GetWindowTextW(_window, string, maxCount); }
333*f6dc9357SAndroid Build Coastguard Worker   */
334*f6dc9357SAndroid Build Coastguard Worker   bool GetText(UString &s) const;
335*f6dc9357SAndroid Build Coastguard Worker   #endif
336*f6dc9357SAndroid Build Coastguard Worker 
Enable(bool enable)337*f6dc9357SAndroid Build Coastguard Worker   bool Enable(bool enable)
338*f6dc9357SAndroid Build Coastguard Worker     { return BOOLToBool(::EnableWindow(_window, BoolToBOOL(enable))); }
339*f6dc9357SAndroid Build Coastguard Worker 
IsEnabled()340*f6dc9357SAndroid Build Coastguard Worker   bool IsEnabled() const
341*f6dc9357SAndroid Build Coastguard Worker     { return BOOLToBool(::IsWindowEnabled(_window)); }
342*f6dc9357SAndroid Build Coastguard Worker 
343*f6dc9357SAndroid Build Coastguard Worker   #ifndef UNDER_CE
GetSystemMenu(bool revert)344*f6dc9357SAndroid Build Coastguard Worker   HMENU GetSystemMenu(bool revert)
345*f6dc9357SAndroid Build Coastguard Worker     { return ::GetSystemMenu(_window, BoolToBOOL(revert)); }
346*f6dc9357SAndroid Build Coastguard Worker   #endif
347*f6dc9357SAndroid Build Coastguard Worker 
348*f6dc9357SAndroid Build Coastguard Worker   UINT_PTR SetTimer(UINT_PTR idEvent, UINT elapse, TIMERPROC timerFunc = NULL)
349*f6dc9357SAndroid Build Coastguard Worker     { return ::SetTimer(_window, idEvent, elapse, timerFunc); }
KillTimer(UINT_PTR idEvent)350*f6dc9357SAndroid Build Coastguard Worker   bool KillTimer(UINT_PTR idEvent)
351*f6dc9357SAndroid Build Coastguard Worker     {return BOOLToBool(::KillTimer(_window, idEvent)); }
352*f6dc9357SAndroid Build Coastguard Worker 
SetIcon(WPARAM sizeType,HICON icon)353*f6dc9357SAndroid Build Coastguard Worker   HICON SetIcon(WPARAM sizeType, HICON icon) { return (HICON)SendMsg(WM_SETICON, sizeType, (LPARAM)icon); }
354*f6dc9357SAndroid Build Coastguard Worker };
355*f6dc9357SAndroid Build Coastguard Worker 
356*f6dc9357SAndroid Build Coastguard Worker #define RECT_SIZE_X(r) ((r).right - (r).left)
357*f6dc9357SAndroid Build Coastguard Worker #define RECT_SIZE_Y(r) ((r).bottom - (r).top)
358*f6dc9357SAndroid Build Coastguard Worker 
IsKeyDown(int virtKey)359*f6dc9357SAndroid Build Coastguard Worker inline bool IsKeyDown(int virtKey) { return (::GetKeyState(virtKey) & 0x8000) != 0; }
360*f6dc9357SAndroid Build Coastguard Worker 
361*f6dc9357SAndroid Build Coastguard Worker }
362*f6dc9357SAndroid Build Coastguard Worker 
363*f6dc9357SAndroid Build Coastguard Worker #endif
364