1 |
/* |
/* |
2 |
* $Id: Window.h,v 1.4 2007-08-18 08:52:18 maya Exp $ |
* $Id: Window.h,v 1.4 2007-08-18 08:52:18 maya Exp $ |
3 |
*/ |
*/ |
4 |
|
|
5 |
#ifndef _YCL_WINDOWS_H_ |
#ifndef _YCL_WINDOWS_H_ |
6 |
#define _YCL_WINDOWS_H_ |
#define _YCL_WINDOWS_H_ |
7 |
|
|
8 |
#if _MSC_VER >= 1000 |
#if _MSC_VER >= 1000 |
9 |
#pragma once |
#pragma once |
10 |
#endif // _MSC_VER >= 1000 |
#endif // _MSC_VER >= 1000 |
11 |
|
|
12 |
#include <YCL/common.h> |
#include <YCL/common.h> |
13 |
|
|
14 |
#include <YCL/String.h> |
#include <YCL/String.h> |
15 |
|
|
16 |
namespace yebisuya { |
namespace yebisuya { |
17 |
|
|
18 |
class Window { |
class Window { |
19 |
private: |
private: |
20 |
HWND window; |
HWND window; |
21 |
public: |
public: |
22 |
Window():window(NULL) { |
Window():window(NULL) { |
23 |
} |
} |
24 |
Window(HWND window):window(window) { |
Window(HWND window):window(window) { |
25 |
} |
} |
26 |
void operator<<=(HWND newWindow) { |
void operator<<=(HWND newWindow) { |
27 |
window = newWindow; |
window = newWindow; |
28 |
} |
} |
29 |
operator HWND()const { |
operator HWND()const { |
30 |
return window; |
return window; |
31 |
} |
} |
32 |
|
|
33 |
long GetWindowLong(int index)const { |
long GetWindowLong(int index)const { |
34 |
return ::GetWindowLong(window, index); |
return ::GetWindowLong(window, index); |
35 |
} |
} |
36 |
long SetWindowLong(int index, long data) { |
long SetWindowLong(int index, long data) { |
37 |
return ::SetWindowLong(window, index, data); |
return ::SetWindowLong(window, index, data); |
38 |
} |
} |
39 |
int GetWindowTextLength()const { |
int GetWindowTextLength()const { |
40 |
return ::GetWindowTextLength(window); |
return ::GetWindowTextLength(window); |
41 |
} |
} |
42 |
int GetWindowText(char* buffer, int size)const { |
int GetWindowText(char* buffer, int size)const { |
43 |
return ::GetWindowText(window, buffer, size); |
return ::GetWindowText(window, buffer, size); |
44 |
} |
} |
45 |
String GetWindowText()const { |
String GetWindowText()const { |
46 |
int length = GetWindowTextLength(); |
int length = GetWindowTextLength(); |
47 |
char* buffer = (char*) alloca(length + 1); |
char* buffer = (char*) alloca(length + 1); |
48 |
GetWindowText(buffer, length + 1); |
GetWindowText(buffer, length + 1); |
49 |
return buffer; |
return buffer; |
50 |
} |
} |
51 |
bool SetWindowText(const char* text) { |
bool SetWindowText(const char* text) { |
52 |
return ::SetWindowText(window, text) != FALSE; |
return ::SetWindowText(window, text) != FALSE; |
53 |
} |
} |
54 |
long SendMessage(int message, int wparam = 0, long lparam = 0)const { |
long SendMessage(int message, int wparam = 0, long lparam = 0)const { |
55 |
return ::SendMessage(window, message, wparam, lparam); |
return ::SendMessage(window, message, wparam, lparam); |
56 |
} |
} |
57 |
long PostMessage(int message, int wparam = 0, long lparam = 0)const { |
long PostMessage(int message, int wparam = 0, long lparam = 0)const { |
58 |
return ::PostMessage(window, message, wparam, lparam); |
return ::PostMessage(window, message, wparam, lparam); |
59 |
} |
} |
60 |
HWND GetParent()const { |
HWND GetParent()const { |
61 |
return ::GetParent(window); |
return ::GetParent(window); |
62 |
} |
} |
63 |
bool EnableWindow(bool enabled) { |
bool EnableWindow(bool enabled) { |
64 |
return ::EnableWindow(window, enabled) != FALSE; |
return ::EnableWindow(window, enabled) != FALSE; |
65 |
} |
} |
66 |
long DefWindowProc(int message, int wparam, long lparam) { |
long DefWindowProc(int message, int wparam, long lparam) { |
67 |
return ::DefWindowProc(window, message, wparam, lparam); |
return ::DefWindowProc(window, message, wparam, lparam); |
68 |
} |
} |
69 |
long CallWindowProc(WNDPROC proc, int message, int wParam, long lParam) { |
long CallWindowProc(WNDPROC proc, int message, int wParam, long lParam) { |
70 |
return ::CallWindowProc(proc, window, message, wParam, lParam); |
return ::CallWindowProc(proc, window, message, wParam, lParam); |
71 |
} |
} |
72 |
bool ShowWindow(int command) { |
bool ShowWindow(int command) { |
73 |
return ::ShowWindow(window, command) != FALSE; |
return ::ShowWindow(window, command) != FALSE; |
74 |
} |
} |
75 |
HWND SetFocus() { |
HWND SetFocus() { |
76 |
return ::SetFocus(window); |
return ::SetFocus(window); |
77 |
} |
} |
78 |
HWND SetCapture() { |
HWND SetCapture() { |
79 |
return ::SetCapture(window); |
return ::SetCapture(window); |
80 |
} |
} |
81 |
bool IsWindowEnabled()const { |
bool IsWindowEnabled()const { |
82 |
return ::IsWindowEnabled(window) != FALSE; |
return ::IsWindowEnabled(window) != FALSE; |
83 |
} |
} |
84 |
bool IsWindowVisible()const { |
bool IsWindowVisible()const { |
85 |
return ::IsWindowVisible(window) != FALSE; |
return ::IsWindowVisible(window) != FALSE; |
86 |
} |
} |
87 |
bool IsIconic()const { |
bool IsIconic()const { |
88 |
return ::IsIconic(window) != FALSE; |
return ::IsIconic(window) != FALSE; |
89 |
} |
} |
90 |
bool IsZoomed()const { |
bool IsZoomed()const { |
91 |
return ::IsZoomed(window) != FALSE; |
return ::IsZoomed(window) != FALSE; |
92 |
} |
} |
93 |
int SetTimer(int id, int elapse, TIMERPROC timerProc = NULL) { |
int SetTimer(int id, int elapse, TIMERPROC timerProc = NULL) { |
94 |
return ::SetTimer(window, id, elapse, timerProc); |
return ::SetTimer(window, id, elapse, timerProc); |
95 |
} |
} |
96 |
bool KillTimer(int id) { |
bool KillTimer(int id) { |
97 |
return ::KillTimer(window, id) != FALSE; |
return ::KillTimer(window, id) != FALSE; |
98 |
} |
} |
99 |
HMENU GetMenu()const { |
HMENU GetMenu()const { |
100 |
return ::GetMenu(window); |
return ::GetMenu(window); |
101 |
} |
} |
102 |
bool SetForegroundWindow() { |
bool SetForegroundWindow() { |
103 |
return ::SetForegroundWindow(window) != FALSE; |
return ::SetForegroundWindow(window) != FALSE; |
104 |
} |
} |
105 |
void UpdateWindow() { |
void UpdateWindow() { |
106 |
::UpdateWindow(window); |
::UpdateWindow(window); |
107 |
} |
} |
108 |
bool GetWindowRect(RECT& rect)const { |
bool GetWindowRect(RECT& rect)const { |
109 |
return ::GetWindowRect(window, &rect) != FALSE; |
return ::GetWindowRect(window, &rect) != FALSE; |
110 |
} |
} |
111 |
bool GetClientRect(RECT& rect)const { |
bool GetClientRect(RECT& rect)const { |
112 |
return ::GetClientRect(window, &rect) != FALSE; |
return ::GetClientRect(window, &rect) != FALSE; |
113 |
} |
} |
114 |
bool SetWindowPos(HWND previous, int x, int y, int cx, int cy, int flags) { |
bool SetWindowPos(HWND previous, int x, int y, int cx, int cy, int flags) { |
115 |
return ::SetWindowPos(window, previous, x, y, cx, cy, flags) != FALSE; |
return ::SetWindowPos(window, previous, x, y, cx, cy, flags) != FALSE; |
116 |
} |
} |
117 |
bool ClientToScreen(POINT& point)const { |
bool ClientToScreen(POINT& point)const { |
118 |
return ::ClientToScreen(window, &point) != FALSE; |
return ::ClientToScreen(window, &point) != FALSE; |
119 |
} |
} |
120 |
bool ScreenToClient(POINT& point)const { |
bool ScreenToClient(POINT& point)const { |
121 |
return ::ScreenToClient(window, &point) != FALSE; |
return ::ScreenToClient(window, &point) != FALSE; |
122 |
} |
} |
123 |
bool ClientToScreen(RECT& rect)const { |
bool ClientToScreen(RECT& rect)const { |
124 |
return ::ClientToScreen(window, (POINT*) &rect.left) != FALSE |
return ::ClientToScreen(window, (POINT*) &rect.left) != FALSE |
125 |
&& ::ClientToScreen(window, (POINT*) &rect.right) != FALSE; |
&& ::ClientToScreen(window, (POINT*) &rect.right) != FALSE; |
126 |
} |
} |
127 |
bool ScreenToClient(RECT& rect)const { |
bool ScreenToClient(RECT& rect)const { |
128 |
return ::ScreenToClient(window, (POINT*) &rect.left) != FALSE |
return ::ScreenToClient(window, (POINT*) &rect.left) != FALSE |
129 |
&& ::ScreenToClient(window, (POINT*) &rect.right) != FALSE; |
&& ::ScreenToClient(window, (POINT*) &rect.right) != FALSE; |
130 |
} |
} |
131 |
bool InvalidateRect(bool erase = true) { |
bool InvalidateRect(bool erase = true) { |
132 |
return ::InvalidateRect(window, NULL, erase) != FALSE; |
return ::InvalidateRect(window, NULL, erase) != FALSE; |
133 |
} |
} |
134 |
bool InvalidateRect(RECT& rect, bool erase = true) { |
bool InvalidateRect(RECT& rect, bool erase = true) { |
135 |
return ::InvalidateRect(window, &rect, erase) != FALSE; |
return ::InvalidateRect(window, &rect, erase) != FALSE; |
136 |
} |
} |
137 |
bool GetWindowPlacement(WINDOWPLACEMENT& wp)const { |
bool GetWindowPlacement(WINDOWPLACEMENT& wp)const { |
138 |
wp.length = sizeof wp; |
wp.length = sizeof wp; |
139 |
return ::GetWindowPlacement(window, &wp) != FALSE; |
return ::GetWindowPlacement(window, &wp) != FALSE; |
140 |
} |
} |
141 |
bool SetWindowPlacement(const WINDOWPLACEMENT& wp) { |
bool SetWindowPlacement(const WINDOWPLACEMENT& wp) { |
142 |
return ::SetWindowPlacement(window, &wp) != FALSE; |
return ::SetWindowPlacement(window, &wp) != FALSE; |
143 |
} |
} |
144 |
HWND ChildWindowFromPoint(POINT point, int flags = CWP_ALL)const { |
HWND ChildWindowFromPoint(POINT point, int flags = CWP_ALL)const { |
145 |
return ::ChildWindowFromPointEx(window, point, flags); |
return ::ChildWindowFromPointEx(window, point, flags); |
146 |
} |
} |
147 |
HWND GetLastActivePopup()const { |
HWND GetLastActivePopup()const { |
148 |
return ::GetLastActivePopup(window); |
return ::GetLastActivePopup(window); |
149 |
} |
} |
150 |
HWND GetWindow(int command)const { |
HWND GetWindow(int command)const { |
151 |
return ::GetWindow(window, command); |
return ::GetWindow(window, command); |
152 |
} |
} |
153 |
HWND GetTopWindow()const { |
HWND GetTopWindow()const { |
154 |
return ::GetTopWindow(window); |
return ::GetTopWindow(window); |
155 |
} |
} |
156 |
bool IsWindow()const { |
bool IsWindow()const { |
157 |
return ::IsWindow(window) != FALSE; |
return ::IsWindow(window) != FALSE; |
158 |
} |
} |
159 |
bool IsChild(HWND child)const { |
bool IsChild(HWND child)const { |
160 |
return ::IsChild(window, child) != FALSE; |
return ::IsChild(window, child) != FALSE; |
161 |
} |
} |
162 |
bool MoveWindow(int x, int y, int cx, int cy, bool repaint) { |
bool MoveWindow(int x, int y, int cx, int cy, bool repaint) { |
163 |
return ::MoveWindow(window, x, y, cx, cy, repaint) != FALSE; |
return ::MoveWindow(window, x, y, cx, cy, repaint) != FALSE; |
164 |
} |
} |
165 |
bool OpenIcon() { |
bool OpenIcon() { |
166 |
return ::OpenIcon(window) != FALSE; |
return ::OpenIcon(window) != FALSE; |
167 |
} |
} |
168 |
bool ShowOwnedPopups(bool show) { |
bool ShowOwnedPopups(bool show) { |
169 |
return ::ShowOwnedPopups(window, show) != FALSE; |
return ::ShowOwnedPopups(window, show) != FALSE; |
170 |
} |
} |
171 |
bool ShowWindowAsync(int command) { |
bool ShowWindowAsync(int command) { |
172 |
return ::ShowWindowAsync(window, command) != FALSE; |
return ::ShowWindowAsync(window, command) != FALSE; |
173 |
} |
} |
174 |
int GetDlgCtrlID()const { |
int GetDlgCtrlID()const { |
175 |
return ::GetDlgCtrlID(window); |
return ::GetDlgCtrlID(window); |
176 |
} |
} |
177 |
HWND GetDlgItem(int id)const { |
HWND GetDlgItem(int id)const { |
178 |
return ::GetDlgItem(window, id); |
return ::GetDlgItem(window, id); |
179 |
} |
} |
180 |
bool DestroyWindow() { |
bool DestroyWindow() { |
181 |
if (window == NULL || ::DestroyWindow(window) == FALSE) |
if (window == NULL || ::DestroyWindow(window) == FALSE) |
182 |
return false; |
return false; |
183 |
window = NULL; |
window = NULL; |
184 |
return true; |
return true; |
185 |
} |
} |
186 |
bool CloseWindow() { |
bool CloseWindow() { |
187 |
return ::CloseWindow(window) != FALSE; |
return ::CloseWindow(window) != FALSE; |
188 |
} |
} |
189 |
int SetScrollPos(int type, int position, bool redraw) { |
int SetScrollPos(int type, int position, bool redraw) { |
190 |
return ::SetScrollPos(window, type, position, redraw); |
return ::SetScrollPos(window, type, position, redraw); |
191 |
} |
} |
192 |
int GetScrollPos(int type)const { |
int GetScrollPos(int type)const { |
193 |
return ::GetScrollPos(window, type); |
return ::GetScrollPos(window, type); |
194 |
} |
} |
195 |
bool SetScrollRange(int type, int minimum, int maximum, bool redraw) { |
bool SetScrollRange(int type, int minimum, int maximum, bool redraw) { |
196 |
return ::SetScrollRange(window, type, minimum, maximum, redraw) != FALSE; |
return ::SetScrollRange(window, type, minimum, maximum, redraw) != FALSE; |
197 |
} |
} |
198 |
bool GetScrollRange(int type, int& minimum, int& maximum)const { |
bool GetScrollRange(int type, int& minimum, int& maximum)const { |
199 |
return ::GetScrollRange(window, type, &minimum, &maximum) != FALSE; |
return ::GetScrollRange(window, type, &minimum, &maximum) != FALSE; |
200 |
} |
} |
201 |
int SetScrollInfo(int type, const SCROLLINFO& info, bool redraw) { |
int SetScrollInfo(int type, const SCROLLINFO& info, bool redraw) { |
202 |
return ::SetScrollInfo(window, type, &info, redraw); |
return ::SetScrollInfo(window, type, &info, redraw); |
203 |
} |
} |
204 |
bool GetScrollInfo(int type, SCROLLINFO& info)const { |
bool GetScrollInfo(int type, SCROLLINFO& info)const { |
205 |
return ::GetScrollInfo(window, type, &info) != FALSE; |
return ::GetScrollInfo(window, type, &info) != FALSE; |
206 |
} |
} |
207 |
long SetLayeredWindowAttributes(long reserved, int parameters, long attribute) { |
long SetLayeredWindowAttributes(long reserved, int parameters, long attribute) { |
208 |
static const char USER32[] = "user32.dll"; |
static const char USER32[] = "user32.dll"; |
209 |
static const char APINAME[] = "SetLayeredWindowAttributes"; |
static const char APINAME[] = "SetLayeredWindowAttributes"; |
210 |
static DWORD (WINAPI* api)(HWND, DWORD, BYTE, DWORD) |
static DWORD (WINAPI* api)(HWND, DWORD, BYTE, DWORD) |
211 |
= (DWORD (WINAPI*)(HWND, DWORD, BYTE, DWORD)) ::GetProcAddress(::GetModuleHandle(USER32), APINAME); |
= (DWORD (WINAPI*)(HWND, DWORD, BYTE, DWORD)) ::GetProcAddress(::GetModuleHandle(USER32), APINAME); |
212 |
return api != NULL ? (*api)(window, reserved, parameters, attribute) : 0; |
return api != NULL ? (*api)(window, reserved, parameters, attribute) : 0; |
213 |
} |
} |
214 |
long SetLayeredWindowAttributes(int parameters, long attribute) { |
long SetLayeredWindowAttributes(int parameters, long attribute) { |
215 |
return SetLayeredWindowAttributes(0, parameters, attribute); |
return SetLayeredWindowAttributes(0, parameters, attribute); |
216 |
} |
} |
217 |
HWND SetClipboardViewer() { |
HWND SetClipboardViewer() { |
218 |
return ::SetClipboardViewer(window); |
return ::SetClipboardViewer(window); |
219 |
} |
} |
220 |
bool ChangeClipboardChain(HWND newNext) { |
bool ChangeClipboardChain(HWND newNext) { |
221 |
return ::ChangeClipboardChain(window, newNext) != FALSE; |
return ::ChangeClipboardChain(window, newNext) != FALSE; |
222 |
} |
} |
223 |
bool RegisterHotKey(int id, int modifiers, int keycode) { |
bool RegisterHotKey(int id, int modifiers, int keycode) { |
224 |
return ::RegisterHotKey(window, id, modifiers, keycode) != FALSE; |
return ::RegisterHotKey(window, id, modifiers, keycode) != FALSE; |
225 |
} |
} |
226 |
bool UnregisterHotKey(int id) { |
bool UnregisterHotKey(int id) { |
227 |
return ::UnregisterHotKey(window, id) != FALSE; |
return ::UnregisterHotKey(window, id) != FALSE; |
228 |
} |
} |
229 |
int MessageBox(const char* message, const char* caption, int type) { |
int MessageBox(const char* message, const char* caption, int type) { |
230 |
return ::MessageBox(window, message, caption, type); |
return ::MessageBox(window, message, caption, type); |
231 |
} |
} |
232 |
int MessageBox(const char* message, int type) { |
int MessageBox(const char* message, int type) { |
233 |
Window top(window); |
Window top(window); |
234 |
while ((top.getStyle() & WS_CHILD) != 0) { |
while ((top.getStyle() & WS_CHILD) != 0) { |
235 |
top <<= top.GetParent(); |
top <<= top.GetParent(); |
236 |
} |
} |
237 |
return MessageBox(message, top.GetWindowText(), type); |
return MessageBox(message, top.GetWindowText(), type); |
238 |
} |
} |
239 |
long GetClassLong(int index)const { |
long GetClassLong(int index)const { |
240 |
return ::GetClassLong(window, index); |
return ::GetClassLong(window, index); |
241 |
} |
} |
242 |
long SetClassLong(int index, long data) { |
long SetClassLong(int index, long data) { |
243 |
return ::SetClassLong(window, index, data); |
return ::SetClassLong(window, index, data); |
244 |
} |
} |
245 |
|
|
246 |
bool create(long exStyle, const char* classname, const char* title, long style, const RECT& rect, HWND parent, HMENU menu, void* param = NULL) { |
bool create(long exStyle, const char* classname, const char* title, long style, const RECT& rect, HWND parent, HMENU menu, void* param = NULL) { |
247 |
return create(exStyle, classname, title, style, rect, parent, menu, GetInstanceHandle(), param); |
return create(exStyle, classname, title, style, rect, parent, menu, GetInstanceHandle(), param); |
248 |
} |
} |
249 |
bool create(long exStyle, const char* classname, const char* title, long style, const RECT& rect, HWND parent, HMENU menu, HINSTANCE instance, void* param = NULL) { |
bool create(long exStyle, const char* classname, const char* title, long style, const RECT& rect, HWND parent, HMENU menu, HINSTANCE instance, void* param = NULL) { |
250 |
return (window = ::CreateWindowEx(exStyle, classname, title, |
return (window = ::CreateWindowEx(exStyle, classname, title, |
251 |
style, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, |
style, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, |
252 |
parent, menu, instance, param)) != NULL; |
parent, menu, instance, param)) != NULL; |
253 |
} |
} |
254 |
void setRedraw(bool redraw) { |
void setRedraw(bool redraw) { |
255 |
SendMessage(WM_SETREDRAW, redraw); |
SendMessage(WM_SETREDRAW, redraw); |
256 |
} |
} |
257 |
HFONT getFont()const { |
HFONT getFont()const { |
258 |
return (HFONT) SendMessage(WM_GETFONT); |
return (HFONT) SendMessage(WM_GETFONT); |
259 |
} |
} |
260 |
HFONT setFont(HFONT font, bool redraw) { |
HFONT setFont(HFONT font, bool redraw) { |
261 |
return (HFONT) SendMessage(WM_SETFONT, (WPARAM) font, redraw); |
return (HFONT) SendMessage(WM_SETFONT, (WPARAM) font, redraw); |
262 |
} |
} |
263 |
HICON getIcon(bool large) { |
HICON getIcon(bool large) { |
264 |
return (HICON) SendMessage(WM_GETICON, large, 0); |
return (HICON) SendMessage(WM_GETICON, large, 0); |
265 |
} |
} |
266 |
HICON setIcon(HICON icon, bool large) { |
HICON setIcon(HICON icon, bool large) { |
267 |
return (HICON) SendMessage(WM_SETICON, large, (LPARAM) icon); |
return (HICON) SendMessage(WM_SETICON, large, (LPARAM) icon); |
268 |
} |
} |
269 |
long getStyle()const { |
long getStyle()const { |
270 |
return GetWindowLong(GWL_STYLE); |
return GetWindowLong(GWL_STYLE); |
271 |
} |
} |
272 |
long getExStyle()const { |
long getExStyle()const { |
273 |
return GetWindowLong(GWL_EXSTYLE); |
return GetWindowLong(GWL_EXSTYLE); |
274 |
} |
} |
275 |
long setStyle(long style) { |
long setStyle(long style) { |
276 |
return SetWindowLong(GWL_STYLE, style); |
return SetWindowLong(GWL_STYLE, style); |
277 |
} |
} |
278 |
long setExStyle(long exStyle) { |
long setExStyle(long exStyle) { |
279 |
return SetWindowLong(GWL_EXSTYLE, exStyle); |
return SetWindowLong(GWL_EXSTYLE, exStyle); |
280 |
} |
} |
281 |
WNDPROC getWndProc()const { |
WNDPROC getWndProc()const { |
282 |
return (WNDPROC) GetWindowLong(GWL_WNDPROC); |
return (WNDPROC) GetWindowLong(GWL_WNDPROC); |
283 |
} |
} |
284 |
WNDPROC setWndProc(WNDPROC proc) { |
WNDPROC setWndProc(WNDPROC proc) { |
285 |
return (WNDPROC) SetWindowLong(GWL_WNDPROC, (long) proc); |
return (WNDPROC) SetWindowLong(GWL_WNDPROC, (long) proc); |
286 |
} |
} |
287 |
HWND getOwner()const { |
HWND getOwner()const { |
288 |
return (HWND) GetWindowLong(GWL_HWNDPARENT); |
return (HWND) GetWindowLong(GWL_HWNDPARENT); |
289 |
} |
} |
290 |
HWND setOwner(HWND owner) { |
HWND setOwner(HWND owner) { |
291 |
return (HWND) SetWindowLong(GWL_HWNDPARENT, (long) owner); |
return (HWND) SetWindowLong(GWL_HWNDPARENT, (long) owner); |
292 |
} |
} |
293 |
HWND getChildWindow()const { |
HWND getChildWindow()const { |
294 |
return GetWindow(GW_CHILD); |
return GetWindow(GW_CHILD); |
295 |
} |
} |
296 |
HWND getFirstWindow()const { |
HWND getFirstWindow()const { |
297 |
return GetWindow(GW_HWNDFIRST); |
return GetWindow(GW_HWNDFIRST); |
298 |
} |
} |
299 |
HWND getLastWindow()const { |
HWND getLastWindow()const { |
300 |
return GetWindow(GW_HWNDLAST); |
return GetWindow(GW_HWNDLAST); |
301 |
} |
} |
302 |
HWND getNextWindow()const { |
HWND getNextWindow()const { |
303 |
return GetWindow(GW_HWNDNEXT); |
return GetWindow(GW_HWNDNEXT); |
304 |
} |
} |
305 |
HWND getPreviousWindow()const { |
HWND getPreviousWindow()const { |
306 |
return GetWindow(GW_HWNDPREV); |
return GetWindow(GW_HWNDPREV); |
307 |
} |
} |
308 |
HWND getOwnerWindow()const { |
HWND getOwnerWindow()const { |
309 |
return GetWindow(GW_OWNER); |
return GetWindow(GW_OWNER); |
310 |
} |
} |
311 |
#ifndef WS_EX_LAYERED |
#ifndef WS_EX_LAYERED |
312 |
#define WS_EX_LAYERED 0x80000 |
#define WS_EX_LAYERED 0x80000 |
313 |
#endif |
#endif |
314 |
void setAlpha(int alpha) { |
void setAlpha(int alpha) { |
315 |
long exStyle = getExStyle(); |
long exStyle = getExStyle(); |
316 |
if ((exStyle & WS_EX_LAYERED) == 0) |
if ((exStyle & WS_EX_LAYERED) == 0) |
317 |
setExStyle(exStyle | WS_EX_LAYERED); |
setExStyle(exStyle | WS_EX_LAYERED); |
318 |
SetLayeredWindowAttributes(alpha, 2); |
SetLayeredWindowAttributes(alpha, 2); |
319 |
} |
} |
320 |
static const RECT& USEDEFAULT() { |
static const RECT& USEDEFAULT() { |
321 |
static RECT rect = {CW_USEDEFAULT, CW_USEDEFAULT, 0, 0}; |
static RECT rect = {CW_USEDEFAULT, CW_USEDEFAULT, 0, 0}; |
322 |
return rect; |
return rect; |
323 |
} |
} |
324 |
ATOM getClassAtom()const { |
ATOM getClassAtom()const { |
325 |
return (ATOM) GetClassLong(GCW_ATOM); |
return (ATOM) GetClassLong(GCW_ATOM); |
326 |
} |
} |
327 |
long getClassExtra()const { |
long getClassExtra()const { |
328 |
return GetClassLong(GCL_CBCLSEXTRA); |
return GetClassLong(GCL_CBCLSEXTRA); |
329 |
} |
} |
330 |
long getWindowExtra()const { |
long getWindowExtra()const { |
331 |
return GetClassLong(GCL_CBWNDEXTRA); |
return GetClassLong(GCL_CBWNDEXTRA); |
332 |
} |
} |
333 |
HBRUSH getBackgroundBrush()const { |
HBRUSH getBackgroundBrush()const { |
334 |
return (HBRUSH) GetClassLong(GCL_HBRBACKGROUND); |
return (HBRUSH) GetClassLong(GCL_HBRBACKGROUND); |
335 |
} |
} |
336 |
HCURSOR getClassCursor()const { |
HCURSOR getClassCursor()const { |
337 |
return (HCURSOR) GetClassLong(GCL_HCURSOR); |
return (HCURSOR) GetClassLong(GCL_HCURSOR); |
338 |
} |
} |
339 |
HICON getClassIcon()const { |
HICON getClassIcon()const { |
340 |
return (HICON) GetClassLong(GCL_HICON); |
return (HICON) GetClassLong(GCL_HICON); |
341 |
} |
} |
342 |
HICON getClassSmallIcon()const { |
HICON getClassSmallIcon()const { |
343 |
return (HICON) GetClassLong(GCL_HICONSM); |
return (HICON) GetClassLong(GCL_HICONSM); |
344 |
} |
} |
345 |
HINSTANCE getClassInstance()const { |
HINSTANCE getClassInstance()const { |
346 |
return (HINSTANCE) GetClassLong(GCL_HMODULE); |
return (HINSTANCE) GetClassLong(GCL_HMODULE); |
347 |
} |
} |
348 |
int getMenuResourceId()const { |
int getMenuResourceId()const { |
349 |
return GetClassLong(GCL_MENUNAME); |
return GetClassLong(GCL_MENUNAME); |
350 |
} |
} |
351 |
int getClassStyle()const { |
int getClassStyle()const { |
352 |
return GetClassLong(GCL_STYLE); |
return GetClassLong(GCL_STYLE); |
353 |
} |
} |
354 |
WNDPROC getClassWindowProc()const { |
WNDPROC getClassWindowProc()const { |
355 |
return (WNDPROC) GetClassLong(GCL_WNDPROC); |
return (WNDPROC) GetClassLong(GCL_WNDPROC); |
356 |
} |
} |
357 |
}; |
}; |
358 |
|
|
359 |
#pragma comment(lib, "user32.lib") |
#pragma comment(lib, "user32.lib") |
360 |
} |
} |
361 |
|
|
362 |
#endif//_YCL_WINDOWS_H_ |
#endif//_YCL_WINDOWS_H_ |