Mercurial > projects > dynamin
annotate dynamin/gui/windows_window.d @ 12:7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 18 Jul 2009 01:37:06 -0500 |
parents | aa4efef0f0b1 |
children | ef81af74a306 |
rev | line source |
---|---|
0 | 1 // Written in the D programming language |
2 // www.digitalmars.com/d/ | |
3 | |
4 /* | |
5 * The contents of this file are subject to the Mozilla Public License Version | |
6 * 1.1 (the "License"); you may not use this file except in compliance with | |
7 * the License. You may obtain a copy of the License at | |
8 * http://www.mozilla.org/MPL/ | |
9 * | |
10 * Software distributed under the License is distributed on an "AS IS" basis, | |
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 * for the specific language governing rights and limitations under the | |
13 * License. | |
14 * | |
15 * The Original Code is the Dynamin library. | |
16 * | |
17 * The Initial Developer of the Original Code is Jordan Miner. | |
18 * Portions created by the Initial Developer are Copyright (C) 2006-2009 | |
19 * the Initial Developer. All Rights Reserved. | |
20 * | |
21 * Contributor(s): | |
22 * Jordan Miner <jminer7@gmail.com> | |
23 * | |
24 */ | |
25 | |
26 module dynamin.gui.windows_window; | |
27 | |
28 public import dynamin.c.windows; | |
29 public import dynamin.c.cairo; | |
30 public import dynamin.c.cairo_win32; | |
31 public import dynamin.all_core; | |
32 public import dynamin.all_gui; | |
33 public import dynamin.gui.window; | |
34 public import dynamin.gui.key; | |
35 public import dynamin.all_painting; | |
36 public import tango.io.Stdout; | |
12
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
37 public import tango.core.sync.Semaphore; |
0 | 38 |
39 /// | |
40 enum WindowsVersion { | |
41 /// | |
42 Windows95, /// | |
43 Windows98, /// | |
44 WindowsMe, /// | |
45 Windows2000,/// | |
46 WindowsXP, /// | |
47 WindowsVista | |
48 } | |
49 /** | |
50 * Returns true if the version of Windows that is runninng now is the | |
51 * specified version or newer. | |
52 */ | |
53 bool checkWindowsVersion(WindowsVersion ver) { | |
54 // Windows Server "Longhorn" is 6.0 | |
55 // Windows Vista is 6.0 | |
56 // Windows Server 2003 is 5.2 | |
57 // Windows XP is 5.1 | |
58 // Windows Me is 4.90 | |
59 // Windows 98 is 4.10 | |
60 // Windows 95 is 4.0 | |
61 // Windows NT is 4.0 | |
62 OSVERSIONINFO info; | |
63 info.dwOSVersionInfoSize = OSVERSIONINFO.sizeof; | |
64 GetVersionEx(&info); | |
65 DWORD major, minor; | |
66 switch(ver) { | |
67 case WindowsVersion.Windows95: major = 4; minor = 0; break; | |
68 case WindowsVersion.Windows98: major = 4; minor = 10; break; | |
69 case WindowsVersion.WindowsMe: major = 4; minor = 90; break; | |
70 case WindowsVersion.Windows2000: major = 5; minor = 0; break; | |
71 case WindowsVersion.WindowsXP: major = 5; minor = 1; break; | |
72 case WindowsVersion.WindowsVista: major = 6; minor = 0; break; | |
73 } | |
74 return info.dwMajorVersion > major || | |
75 (info.dwMajorVersion == major && info.dwMinorVersion >= minor); | |
76 } | |
77 /* unittest { | |
78 Stdout.format("Windows95 or newer: {}", checkWindowsVersion(WindowsVersion.Windows95)).newline; | |
79 Stdout.format("Windows98 or newer: {}", checkWindowsVersion(WindowsVersion.Windows98)).newline; | |
80 Stdout.format("WindowsMe or newer: {}", checkWindowsVersion(WindowsVersion.WindowsMe)).newline; | |
81 Stdout.format("Windows2000 or newer: {}", checkWindowsVersion(WindowsVersion.Windows2000)).newline; | |
82 Stdout.format("WindowsXP or newer: {}", checkWindowsVersion(WindowsVersion.WindowsXP)).newline; | |
83 } */ | |
84 | |
85 // TODO: the way I have stored references using SetProp() will not work | |
86 // if/when D gets a copying collector. I will need to store a key with | |
87 // SetProp() and use that key to store the reference in either an | |
88 // array or a hashtable. | |
89 Window[HWND] windows; | |
90 void setControl(HWND hwnd, Window win) { | |
91 if(win is null) | |
92 windows.remove(hwnd); | |
93 else | |
94 windows[hwnd] = win; | |
95 } | |
96 /** | |
97 * Returns: the Dynamin NativeControl that wraps the specified handle | |
98 */ | |
99 // TODO: change return type to NativeControl | |
100 Window getControl(HWND hwnd) { | |
101 assert(IsWindow(hwnd), "Invalid HWND"); | |
102 auto tmp = hwnd in windows; | |
103 return tmp is null ? null : *tmp; | |
104 } | |
105 | |
106 template ApplicationBackend() { | |
107 void backend_run(Window w) { | |
108 bool isWindowVisible() { | |
109 if(w is null) return true; | |
110 return w.visible; | |
111 } | |
112 MSG msg; | |
113 BOOL ret; | |
114 while(isWindowVisible() && (ret = GetMessage(&msg, null, 0, 0)) != 0) { | |
115 if(ret == -1) | |
116 Stdout("GetMessage() failed!").newline; | |
117 TranslateMessage(&msg); | |
118 DispatchMessage(&msg); | |
119 } | |
120 } | |
12
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
121 void backend_invoke(void delegate() dg) { |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
122 PostMessage(msgWnd, WM_USER + 7, |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
123 cast(word)dg.ptr, cast(word)dg.funcptr); |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
124 } |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
125 void backend_invokeNow(void delegate() dg) { |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
126 SendMessage(msgWnd, WM_USER + 7, |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
127 cast(word)dg.ptr, cast(word)dg.funcptr); |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
128 } |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
129 |
0 | 130 } |
131 /* | |
132 * The reason backends use the backend_ prefix and: | |
133 * mixin Backend(); | |
134 * instead of using just the method name and | |
135 * mixin Backend() backend; | |
136 * is that D mistakenly calls the method in the class, rather than | |
137 * the one mixed-in...causing infinite recursion/stack overflow | |
138 */ | |
139 //{{{ WindowBackend | |
140 template WindowBackend() { | |
141 HWND _handle; | |
142 bool backend_handleCreated() { return _handle !is null; } | |
143 //WS_CAPTION == WS_BORDER | WS_DLGFRAME; | |
144 void backend_recreateHandle() { | |
145 LONG style, exStyle; | |
146 backend_getWindowStyles(style, exStyle); | |
147 style &= ~WS_VISIBLE; // don't create visible | |
148 // TODO: set the owner with CreateWindowEx | |
149 HWND newHandle = CreateWindowEx(exStyle, "DynaminWindow", _text.toWcharPtr(), | |
150 style, cast(int)x, cast(int)y, cast(int)width, cast(int)height, | |
151 null, null, GetModuleHandle(null), null); | |
152 if(!newHandle) | |
153 Stdout("CreateWindowEx() failed").newline; | |
154 setControl(newHandle, this); | |
155 | |
156 // Windows does not completely obey the styles given in CreateWindowEx() | |
157 SetWindowLong(newHandle, GWL_STYLE, style); | |
158 SetWindowLong(newHandle, GWL_EXSTYLE, exStyle); | |
159 SetWindowPos(newHandle, null, 0, 0, 0, 0, | |
160 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); | |
161 | |
162 if(handleCreated) { | |
163 // TODO: move native children to new window? | |
164 | |
165 // set z-order to right above old window | |
166 // SetWindowPos() puts the window above the specified | |
167 // window in the z-order | |
168 SetWindowPos(newHandle, _handle, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); | |
169 if(IsWindowVisible(_handle)) | |
170 ShowWindow(newHandle, SW_SHOWNA); | |
171 DestroyWindow(_handle); | |
172 } | |
173 _handle = newHandle; | |
174 backend_nativeToBorderSize(); | |
175 } | |
176 extern(C) static void freeDC(void* hdc) { | |
177 ReleaseDC(null, hdc); | |
178 } | |
179 Graphics backend_quickCreateGraphics() { | |
180 HDC hdc = GetDC(handle); | |
181 cairo_surface_t* surface = cairo_win32_surface_create(hdc); | |
182 cairo_surface_set_user_data(surface, cast(cairo_user_data_key_t*)1, | |
183 hdc, &freeDC); | |
184 cairo_t* cr = cairo_create(surface); | |
185 cairo_surface_destroy(surface); | |
186 cairo_translate(cr, -borderSize.left, -borderSize.top); | |
187 auto g = new Graphics(cr); | |
188 cairo_destroy(cr); | |
189 return g; | |
190 } | |
191 void backend_visible(bool b) { | |
192 //if not created, create the handle by calling Handle() | |
193 ShowWindow(handle, b ? SW_SHOW : SW_HIDE); | |
194 } | |
195 void backend_borderStyle(WindowBorderStyle border) { | |
196 backend_updateWindowStyles(); | |
197 } | |
198 void backend_repaint(Rect rect) { | |
199 RECT wrect; | |
200 wrect.left = cast(int)(rect.x-_borderSize.left); | |
201 wrect.top = cast(int)(rect.y-_borderSize.top); | |
202 wrect.right = wrect.left+cast(int)rect.width; | |
203 wrect.bottom = wrect.top+cast(int)rect.height; | |
204 InvalidateRect(handle, &wrect, false); | |
205 } | |
206 void backend_resizable(bool b) { | |
207 backend_updateWindowStyles(); | |
208 } | |
209 void backend_contentMinSizeChanged() { | |
210 } | |
211 void backend_contentMaxSizeChanged() { | |
212 backend_updateWindowStyles(); | |
213 } | |
214 void backend_location(Point pt) { | |
215 SetWindowPos(handle, null, | |
216 cast(int)pt.x, cast(int)pt.y, 0, 0, | |
217 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); | |
218 } | |
219 void backend_size(Size size) { | |
220 SetWindowPos(handle, null, | |
221 0, 0, cast(int)size.width, cast(int)size.height, | |
222 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); | |
223 } | |
224 void backend_text(string str) { | |
225 SetWindowText(handle, str.toWcharPtr()); | |
226 } | |
227 //{{{ backend specific | |
228 | |
229 void backend_nativeToLocationSize() { | |
230 RECT winRect; | |
231 GetWindowRect(handle, &winRect); | |
232 _location.x = winRect.left; | |
233 _location.y = winRect.top; | |
234 _size.width = winRect.right-winRect.left; | |
235 _size.height = winRect.bottom-winRect.top; | |
236 } | |
237 package void backend_nativeToBorderSize() { | |
238 RECT clientRect, winRect; | |
239 POINT clientLoc; | |
240 GetClientRect(handle, &clientRect); | |
241 GetWindowRect(handle, &winRect); | |
242 ClientToScreen(handle, &clientLoc); | |
243 _borderSize.left = clientLoc.x-winRect.left; | |
244 _borderSize.top = clientLoc.y-winRect.top; | |
245 _borderSize.right = winRect.right-clientLoc.x-clientRect.right; | |
246 _borderSize.bottom = winRect.bottom-clientLoc.y-clientRect.bottom; | |
247 backend_nativeToLocationSize(); | |
248 } | |
249 void backend_getWindowStyles(out LONG style, out LONG exStyle) { | |
250 if(handleCreated) { | |
251 style = GetWindowLong(handle, GWL_STYLE); | |
252 exStyle = GetWindowLong(handle, GWL_EXSTYLE); | |
253 } | |
254 void SetIf(LONG s, bool b) { | |
255 // if condition satisfied, add style, otherwise clear style | |
256 b ? (style |= s) : (style &= ~s); | |
257 } | |
258 SetIf(WS_DLGFRAME, borderStyle != WindowBorderStyle.None); | |
259 SetIf(WS_BORDER, borderStyle != WindowBorderStyle.None); | |
260 SetIf(WS_THICKFRAME, | |
261 resizable && borderStyle != WindowBorderStyle.None); | |
262 SetIf(WS_MINIMIZEBOX, borderStyle == WindowBorderStyle.Normal); | |
263 SetIf(WS_MAXIMIZEBOX, | |
264 borderStyle == WindowBorderStyle.Normal && resizable && | |
265 content.maxWidth == 0 && content.maxHeight == 0); | |
266 SetIf(WS_SYSMENU, borderStyle != WindowBorderStyle.None); | |
267 if(borderStyle == WindowBorderStyle.Tool) | |
268 exStyle |= WS_EX_TOOLWINDOW; | |
269 else | |
270 exStyle &= ~WS_EX_TOOLWINDOW; | |
271 } | |
272 void backend_updateWindowStyles() { | |
273 if(!handleCreated) | |
274 return; | |
275 LONG style, exStyle; | |
276 backend_getWindowStyles(style, exStyle); | |
277 SetWindowLong(handle, GWL_STYLE, style); | |
278 SetWindowLong(handle, GWL_EXSTYLE, exStyle); | |
279 SetWindowPos(handle, null, 0, 0, 0, 0, | |
280 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); | |
281 } | |
282 //--FixedToorWindow-- | |
283 //Style: 0x16c80000 | |
284 //ExStyle: 0x10180 | |
285 //--SizableToorWindow-- | |
286 //Style: 0x16cc0000 | |
287 //ExStyle: 0x10180 | |
288 //--FixedDialog-- | |
289 //Style: 0x16c80000 | |
290 //ExStyle: 0x10101 | |
291 //--None-- | |
292 //Style: 0x16010000 | |
293 //ExStyle: 0x10000 | |
294 //--FixedSingle-- | |
295 //Style: 0x16c80000 | |
296 //ExStyle: 0x10100 | |
297 //--Sizable-- | |
298 //Style: 0x16cc0000 | |
299 //ExStyle: 0x10100 | |
300 //}}} | |
301 } | |
302 //}}} | |
303 | |
304 //{{{ Ux class | |
305 class Ux { | |
306 static: | |
307 private: | |
308 HMODULE uxLib = null; | |
309 // TODO: these are the wrong calling convention!! | |
310 extern(Windows) { | |
311 BOOL function() _IsAppThemed; | |
312 BOOL function() _IsThemeActive; | |
313 HTHEME function(HWND hwnd, LPCWSTR pszClassList) _OpenThemeData; | |
314 HRESULT function(HTHEME hTheme) _CloseThemeData; | |
315 HRESULT function(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, | |
316 RECT* pRect, RECT* pClipRect) _DrawThemeBackground; | |
317 } | |
318 static this() { | |
319 uxLib = LoadLibrary("uxtheme"); | |
320 if(uxLib) { | |
321 _IsAppThemed = cast(typeof(_IsAppThemed)) | |
322 GetProcAddress(uxLib, "IsAppThemed"); | |
323 _IsThemeActive = cast(typeof(_IsThemeActive)) | |
324 GetProcAddress(uxLib, "IsThemeActive"); | |
325 _OpenThemeData = cast(typeof(_OpenThemeData)) | |
326 GetProcAddress(uxLib, "OpenThemeData"); | |
327 _CloseThemeData = cast(typeof(_CloseThemeData)) | |
328 GetProcAddress(uxLib, "CloseThemeData"); | |
329 _DrawThemeBackground = cast(typeof(_DrawThemeBackground)) | |
330 GetProcAddress(uxLib, "DrawThemeBackground"); | |
331 } | |
332 } | |
333 HTHEME[string] cache; | |
334 // opens an HTHEME for the specified controlName and caches it | |
335 // next time, just returns the HTHEME from the cache | |
336 HTHEME getHTHEME(string controlName) { | |
337 HTHEME* hthemePtr = controlName in cache; | |
338 HTHEME htheme = controlName in cache; | |
339 if(hthemePtr) { | |
340 htheme = *hthemePtr; | |
341 } else { | |
342 htheme = _OpenThemeData(null, controlName.toWcharPtr()); | |
343 if(!htheme) { | |
344 if(_IsThemeActive()) | |
345 throw new Exception("invalid uxtheme controlName"); | |
346 else | |
347 throw new Exception("no theme active"); | |
348 } | |
349 cache[controlName] = htheme; | |
350 } | |
351 return htheme; | |
352 } | |
353 // This is called when the WM_THEMECHANGED message is sent | |
354 package void themeChanged() { | |
355 foreach(htheme; cache.values) | |
356 _CloseThemeData(htheme); | |
357 cache = null; | |
358 updateThemeActive = true; | |
359 } | |
360 bool themeActive; | |
361 bool updateThemeActive = true; | |
362 public: | |
363 // cache this value, as this function was showing up in profiles | |
364 bool isThemeActive() { | |
365 if(updateThemeActive) { | |
366 themeActive = uxLib && _IsThemeActive() && _IsAppThemed(); | |
367 updateThemeActive = false; | |
368 } | |
369 return themeActive; | |
370 } | |
371 // draw directly onto the HDC with the uxTheme API if the following | |
372 // three conditions are met: | |
373 // - the Graphics must be drawing to an HDC (duh) | |
374 // - there cannot be a scale or rotation...translation can be handled | |
375 // - the clip must be a pixel-aligned rectangle | |
376 bool drawBackground(Graphics g, Rect rect, string controlName, int part, int state) { | |
377 if(!uxLib) | |
378 throw new Exception("UxPaintBackground(): uxtheme library not found!"); | |
379 HTHEME htheme = getHTHEME(controlName); | |
380 static if(true) { | |
381 | |
382 HDC hdc = cairo_win32_surface_get_dc(cairo_get_target(g.handle)); | |
383 //HDC hdc = null; | |
384 bool isMatrixTranslationOnly() { | |
385 cairo_matrix_t matrix; | |
386 cairo_get_matrix(g.handle, &matrix); | |
387 return matrix.xx == 1 && matrix.xy == 0 && | |
388 matrix.xy == 0 && matrix.yy == 1; | |
389 } | |
390 bool isClipIntegerRect(cairo_rectangle_list_t* list) { | |
391 return list.status != CAIRO_STATUS_CLIP_NOT_REPRESENTABLE; | |
392 } | |
393 RECT locRect; | |
394 auto list = cairo_copy_clip_rectangle_list(g.handle); | |
395 scope(exit) cairo_rectangle_list_destroy(list); | |
396 if(hdc && isMatrixTranslationOnly() && isClipIntegerRect(list)) { | |
397 double x = rect.x, y = rect.y; | |
398 double right = rect.right, bottom = rect.bottom; | |
399 cairo_user_to_device(g.handle, &x, &y); | |
400 cairo_user_to_device(g.handle, &right, &bottom); | |
401 locRect.left = cast(int)x; | |
402 locRect.top = cast(int)y; | |
403 locRect.right = cast(int)right; | |
404 locRect.bottom = cast(int)bottom; | |
405 cairo_surface_flush(cairo_get_target(g.handle)); | |
406 | |
407 RECT clip; | |
408 for(int i = 0; i < list.num_rectangles; ++i) { | |
409 cairo_user_to_device(g.handle, &(list.rectangles[i].x), &(list.rectangles[i].y)); | |
410 clip.left = cast(int)list.rectangles[i].x; | |
411 clip.top = cast(int)list.rectangles[i].y; | |
412 clip.right = clip.left + cast(int)list.rectangles[i].width; | |
413 clip.bottom = clip.top + cast(int)list.rectangles[i].height; | |
414 _DrawThemeBackground(htheme, hdc, part, state, &locRect, &clip); | |
415 } | |
416 | |
417 cairo_surface_mark_dirty(cairo_get_target(g.handle)); | |
418 } else { | |
419 assert(0, "So far, visual styles are supported only with no rotation, no scaling, a rectangular clip, and HDC surfaces."); | |
420 static if(0) { | |
421 BITMAPINFO bmi; | |
422 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
423 bmi.bmiHeader.biWidth = width; | |
424 bmi.bmiHeader.biHeight = -height; // top-down DIB | |
425 bmi.bmiHeader.biPlanes = 1; | |
426 bmi.bmiHeader.biBitCount = 32; | |
427 bmi.bmiHeader.biCompression = BI_RGB; | |
428 //bmi.bmiHeader.biSizeImage = width * height * 4; | |
429 hbmpBlack = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, | |
430 &bmpBits, NULL, 0); | |
431 hbmpWhite = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, | |
432 &bmpBits, NULL, 0); | |
433 //draw on a black background and on a white background | |
434 //calculate alpha and colors and draw that image with cairo | |
435 // DO TESTS WITH ROTATION AND SCALING | |
436 _DrawThemeBackground(htheme, hdc, part, state, null/*change*/, null); | |
437 DeleteObject(hbmpBlack); | |
438 DeleteObject(hbmpWhite); | |
439 } | |
440 } | |
441 | |
442 } | |
443 return false; | |
444 } | |
445 } | |
446 //}}} | |
447 | |
448 //{{{ module constructor and destructor | |
449 HWND msgWnd; | |
450 static this() { | |
451 assert(cairo_version() >= CAIRO_VERSION_ENCODE(1, 4, 0), | |
452 "cairo version 1.4.0 or newer is required"); | |
453 | |
454 /* create window classes */ | |
455 WNDCLASSEX wc; | |
456 wc.cbSize = wc.sizeof; | |
457 wc.style = 0; | |
458 wc.hInstance = GetModuleHandle(null); | |
459 | |
460 wc.lpfnWndProc = &dynaminMsgWindowProc; | |
461 wc.lpszClassName = "DynaminMsgWindow"; | |
462 if(!RegisterClassExW(&wc)) | |
463 Stdout("RegisterClassEx() failed registering class 'DynaminMsgWindow'").newline; | |
464 | |
465 wc.lpfnWndProc = &dynaminWindowProc; | |
466 //wc.hbrBackground = cast(HBRUSH)16; | |
467 | |
468 wc.lpszClassName = "DynaminWindow"; | |
469 if(!RegisterClassEx(&wc)) | |
470 Stdout("RegisterClassEx() failed registering class 'DynaminWindow'").newline; | |
471 | |
472 wc.style = CS_SAVEBITS; | |
473 wc.lpszClassName = "DynaminPopup"; | |
474 if(!RegisterClassExW(&wc)) | |
475 Stdout("RegisterClassEx() failed registering class 'DynaminPopup'").newline; | |
476 | |
477 | |
478 msgWnd = CreateWindowEx(0, "DynaminMsgWindow", "", | |
479 0, | |
480 0, 0, 0, 0, | |
481 null, null, GetModuleHandle(null), null); | |
482 if(!msgWnd) | |
483 Stdout("CreateWindowEx() failed").newline; | |
484 | |
485 /* initialize COM */ | |
486 auto ret = CoInitializeEx(null, COINIT_APARTMENTTHREADED); | |
487 if(ret != S_OK && ret != S_FALSE) | |
488 Stdout("Failed to initialize COM").newline; | |
489 | |
490 } | |
491 static ~this() { | |
492 CoUninitialize(); | |
493 } | |
494 //}}} | |
495 | |
496 //{{{ dynaminWindowProc() | |
497 extern(Windows) | |
498 LRESULT dynaminWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { | |
499 //used in WM_MOVING | |
500 static int dragX, dragY; //the cursor location in window coordinates when the drag was started | |
501 static bool trackingMouseLeave = false; | |
502 auto c = getControl(hwnd); | |
503 //{{{ helper functions | |
504 void createMouseEvent(MouseButton button, void delegate(MouseEventArgs args) func) { | |
505 scope args = new MouseEventArgs( | |
506 cast(short)LOWORD(lParam)+c.borderSize.left, | |
507 cast(short)HIWORD(lParam)+c.borderSize.top, button); | |
508 func(args); | |
509 } | |
510 void snapSide(inout int sideToSnap, float side1, float side2) { | |
511 if(sideToSnap >= side1-c.snapDistance && sideToSnap <= side1+c.snapDistance) | |
512 sideToSnap = cast(int)side1; | |
513 if(sideToSnap >= side2-c.snapDistance && sideToSnap <= side2+c.snapDistance) | |
514 sideToSnap = cast(int)side2; | |
515 } | |
516 auto emptyFunc = (Rect snapRect) {}; | |
517 // used to snap vertical sides, left and right | |
518 void snapVSide(inout int side, RECT* rect, void delegate(Rect snapRect) func = emptyFunc) { | |
519 if(c.snapRects is null) | |
520 return; | |
521 foreach(snapRect; c.snapRects) { | |
522 if(rect.bottom >= snapRect.y && rect.top <= snapRect.bottom) { | |
523 snapSide(side, snapRect.x, snapRect.right); | |
524 func(snapRect); | |
525 } | |
526 } | |
527 } | |
528 // used to snap horizontal sides, top and bottom | |
529 void snapHSide(inout int side, RECT* rect, void delegate(Rect snapRect) func = emptyFunc) { | |
530 if(c.snapRects is null) | |
531 return; | |
532 foreach(snapRect; c.snapRects) { | |
533 if(rect.right >= snapRect.x && rect.left <= snapRect.right) { | |
534 snapSide(side, snapRect.y, snapRect.bottom); | |
535 func(snapRect); | |
536 } | |
537 } | |
538 } | |
539 MouseButton getFromXBUTTONX() { | |
540 switch(HIWORD(wParam)) { | |
541 case XBUTTON1: return MouseButton.XButton1; | |
542 case XBUTTON2: return MouseButton.XButton2; | |
543 default: return MouseButton.None; | |
544 } | |
545 } | |
546 //}}} | |
547 switch(uMsg) { | |
548 case WM_ENTERSIZEMOVE: //when the user starts moving or resizing the window | |
549 //{{{ | |
550 POINT cursor; | |
551 GetCursorPos(&cursor); | |
552 RECT rect; | |
553 GetWindowRect(hwnd, &rect); | |
554 dragX = cursor.x-rect.left; | |
555 dragY = cursor.y-rect.top; | |
556 return 0; | |
557 //}}} | |
558 case WM_MOVING: | |
559 //{{{ | |
560 if(c.snapRects is null || c.snapRects.length == 0) | |
561 break; | |
562 RECT* rect = cast(RECT*)lParam; | |
563 int rectWidth = rect.right-rect.left; | |
564 int rectHeight = rect.bottom-rect.top; | |
565 POINT cursor; | |
566 GetCursorPos(&cursor); | |
567 rect.left = cursor.x-dragX; | |
568 rect.top = cursor.y-dragY; | |
569 void updateRightAndBottom() { | |
570 rect.right = rect.left+rectWidth; | |
571 rect.bottom = rect.top+rectHeight; | |
572 } | |
573 updateRightAndBottom(); | |
574 snapVSide(rect.left, rect, (Rect snapRect) { | |
575 snapSide(rect.left, snapRect.x-rectWidth, snapRect.right-rectWidth); | |
576 }); | |
577 updateRightAndBottom(); | |
578 snapHSide(rect.top, rect, (Rect snapRect) { | |
579 snapSide(rect.top, snapRect.y-rectHeight, snapRect.bottom-rectHeight); | |
580 }); | |
581 updateRightAndBottom(); | |
582 snapVSide(rect.left, rect, (Rect snapRect) { | |
583 snapSide(rect.left, snapRect.x-rectWidth, snapRect.right-rectWidth); | |
584 }); | |
585 updateRightAndBottom(); | |
586 return true; | |
587 //}}} | |
588 case WM_SIZING: | |
589 //{{{ | |
590 Size minSize = c.content.minSize+c.borderSize; | |
591 Size maxSize = c.content.maxSize+c.borderSize; | |
592 RECT* rect = cast(RECT*)lParam; | |
593 switch(wParam) { | |
594 case WMSZ_TOPLEFT: | |
595 snapHSide(rect.top, rect); | |
596 goto case WMSZ_LEFT; | |
597 case WMSZ_BOTTOMLEFT: | |
598 snapHSide(rect.bottom, rect); | |
599 case WMSZ_LEFT: | |
600 snapVSide(rect.left, rect); | |
601 // adjust left according to min and max | |
602 if(c.content.maxWidth != 0) | |
603 rect.left = max(rect.left, rect.right-cast(int)maxSize.width); | |
604 if(c.content.minWidth != 0) | |
605 rect.left = min(rect.left, rect.right-cast(int)minSize.width); | |
606 break; | |
607 case WMSZ_TOPRIGHT: | |
608 snapHSide(rect.top, rect); | |
609 goto case WMSZ_RIGHT; | |
610 case WMSZ_BOTTOMRIGHT: | |
611 snapHSide(rect.bottom, rect); | |
612 case WMSZ_RIGHT: | |
613 snapVSide(rect.right, rect); | |
614 // adjust right according to min and max | |
615 if(c.content.maxWidth != 0) | |
616 rect.right = min(rect.right, rect.left+cast(int)maxSize.width); | |
617 if(c.content.minWidth != 0) | |
618 rect.right = max(rect.right, rect.left+cast(int)minSize.width); | |
619 break; | |
620 default: break; | |
621 } | |
622 switch(wParam) { | |
623 case WMSZ_TOPLEFT: //already snapped left above | |
624 case WMSZ_TOPRIGHT: //already snapped right above | |
625 case WMSZ_TOP: | |
626 snapHSide(rect.top, rect); | |
627 // adjust top according to min and max | |
628 if(c.content.maxHeight != 0) | |
629 rect.top = max(rect.top, rect.bottom-cast(int)maxSize.height); | |
630 if(c.content.minHeight != 0) | |
631 rect.top = min(rect.top, rect.bottom-cast(int)minSize.height); | |
632 break; | |
633 case WMSZ_BOTTOMLEFT: //already snapped left above | |
634 case WMSZ_BOTTOMRIGHT: //already snapped right above | |
635 case WMSZ_BOTTOM: | |
636 snapHSide(rect.bottom, rect); | |
637 // adjust bottom according to min and max | |
638 if(c.content.maxHeight != 0) | |
639 rect.bottom = min(rect.bottom, rect.top+cast(int)maxSize.height); | |
640 if(c.content.minHeight != 0) | |
641 rect.bottom = max(rect.bottom, rect.top+cast(int)minSize.height); | |
642 break; | |
643 default: break; | |
644 } | |
645 return true; | |
646 //}}} | |
647 case WM_MOVE: | |
648 RECT rect; | |
649 GetWindowRect(hwnd, &rect); | |
650 c._location = Point(rect.left, rect.top); | |
651 scope args = new EventArgs(); | |
652 c.moved(args); | |
653 return 0; | |
654 case WM_SIZE: | |
655 if(wParam == SIZE_MINIMIZED) | |
656 break; | |
657 RECT rect; | |
658 GetWindowRect(hwnd, &rect); | |
659 c._size = Size(rect.right-rect.left, rect.bottom-rect.top); | |
660 c.backend_nativeToBorderSize(); | |
661 scope args = new EventArgs(); | |
662 c.resized(args); | |
663 return 0; | |
664 case WM_MOUSEMOVE: | |
665 if(!trackingMouseLeave) { | |
666 TRACKMOUSEEVENT tme; | |
667 tme.cbSize = TRACKMOUSEEVENT.sizeof; | |
668 tme.dwFlags = TME_LEAVE; | |
669 tme.hWndTrack = hwnd; | |
670 tme.dwHoverTime = 0; | |
671 TrackMouseEvent(&tme); | |
672 trackingMouseLeave = true; | |
673 } | |
674 auto pt = Point(cast(short)LOWORD(lParam)+c.borderSize.left, cast(short)HIWORD(lParam)+c.borderSize.top); | |
675 Control captor = getCaptorControl(); | |
676 if(captor) | |
677 pt = c.contentToContent(pt, captor); | |
678 else | |
679 captor = c; | |
680 scope event = new MouseEventArgs( | |
681 pt.x, pt.y, MouseButton.None); | |
682 if(wParam & | |
683 (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON | | |
684 MK_XBUTTON1 | MK_XBUTTON2)) { | |
685 captor.mouseDragged(event); | |
686 } else { | |
687 captor.mouseMoved(event); | |
688 } | |
689 return 0; | |
690 case WM_MOUSELEAVE: | |
691 trackingMouseLeave = false; | |
692 setHotControl(null); | |
693 return 0; | |
694 case WM_LBUTTONDOWN: | |
695 SetCapture(hwnd); | |
696 createMouseEvent(MouseButton.Left, (MouseEventArgs args) { | |
697 c.mouseDown(args); | |
698 }); | |
699 return 0; | |
700 case WM_MBUTTONDOWN: | |
701 SetCapture(hwnd); | |
702 createMouseEvent(MouseButton.Middle, (MouseEventArgs args) { | |
703 c.mouseDown(args); | |
704 }); | |
705 return 0; | |
706 case WM_RBUTTONDOWN: | |
707 SetCapture(hwnd); | |
708 createMouseEvent(MouseButton.Right, (MouseEventArgs args) { | |
709 c.mouseDown(args); | |
710 }); | |
711 return 0; | |
712 case WM_XBUTTONDOWN: | |
713 SetCapture(hwnd); | |
714 auto button = getFromXBUTTONX(); | |
715 if(!button) break; | |
716 createMouseEvent(button, (MouseEventArgs args) { | |
717 c.mouseDown(args); | |
718 }); | |
719 return true; | |
720 case WM_LBUTTONUP: | |
721 ReleaseCapture(); | |
722 createMouseEvent(MouseButton.Left, (MouseEventArgs args) { | |
723 c.mouseUp(args); | |
724 }); | |
725 return 0; | |
726 case WM_MBUTTONUP: | |
727 ReleaseCapture(); | |
728 createMouseEvent(MouseButton.Middle, (MouseEventArgs args) { | |
729 c.mouseUp(args); | |
730 }); | |
731 return 0; | |
732 case WM_RBUTTONUP: | |
733 ReleaseCapture(); | |
734 createMouseEvent(MouseButton.Right, (MouseEventArgs args) { | |
735 c.mouseUp(args); | |
736 }); | |
737 return 0; | |
738 case WM_XBUTTONUP: | |
739 ReleaseCapture(); | |
740 auto button = getFromXBUTTONX(); | |
741 if(!button) break; | |
742 createMouseEvent(button, (MouseEventArgs args) { | |
743 c.mouseUp(args); | |
744 }); | |
745 return true; | |
746 case WM_MOUSEWHEEL: | |
747 int scrollLines; | |
748 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0); | |
749 if(scrollLines == 0xFFFFFFFF) | |
750 scrollLines = 3; | |
751 int delta = -cast(short)HIWORD(wParam); | |
752 auto screenPt = Point(LOWORD(lParam), HIWORD(lParam)); | |
753 auto des = c.getDescendantAtPoint(c.screenToContent(screenPt)); | |
754 des.mouseTurned( | |
755 new MouseTurnedEventArgs(delta, delta*scrollLines/120.0) ); | |
756 return 0; | |
757 case WM_SYSKEYDOWN: | |
758 //Stdout.format("WM_SYSKEYDOWN: {:x}", cast(int)wParam).newline; | |
759 if(wParam == 0x79) return 0; | |
760 break; | |
761 case WM_KEYDOWN: | |
762 //Stdout.format("WM_KEYDOWN: {:x}", cast(int)wParam).newline; | |
763 Control focused = c.focusedControl ? c.focusedControl : c; | |
764 focused.keyDown(new KeyEventArgs( | |
765 VKToKey(wParam), cast(bool)(lParam & (1 << 30)) )); | |
766 return 0; | |
767 case WM_SYSKEYUP: | |
768 //Stdout.format("WM_SYSKEYUP: {:x}", cast(int)wParam).newline; | |
769 if(wParam == 0x79) return 0; | |
770 break; | |
771 case WM_KEYUP: | |
772 //Stdout.format("WM_KEYUP: {:x}", cast(int)wParam).newline; | |
773 Control focused = c.focusedControl ? c.focusedControl : c; | |
774 focused.keyUp(new KeyEventArgs( VKToKey(wParam), false )); | |
775 return 0; | |
776 case WM_CHAR: | |
777 // DO NOT use the repeat count from the lParam to send multiple events | |
778 // I hate when programs do that | |
779 | |
780 //stop backspace and escape and shift+enter | |
781 if(wParam == 0x08 || wParam == 0x1B || wParam == 0x0A) | |
782 break; | |
783 // don't process characters typed while control is down | |
784 if(HIBYTE(GetKeyState(VK_CONTROL))) | |
785 break; | |
786 if(wParam == 0x0D) // change \r to \n | |
787 wParam = 0x0A; | |
788 bool repeat; | |
789 repeat = cast(bool)(lParam & (1 << 30)); | |
790 Control focused = c.focusedControl ? c.focusedControl : c; | |
791 focused.keyTyped(new KeyTypedEventArgs(cast(dchar)wParam, repeat)); | |
792 return 0; | |
793 case WM_PRINT: | |
794 paintToHDC(cast(HDC)wParam, getControl(hwnd), null); | |
795 return 0; | |
796 case WM_PAINT: | |
797 PAINTSTRUCT ps; | |
798 BeginPaint(hwnd, &ps); | |
799 RECT* clip = &ps.rcPaint; | |
800 | |
801 HDC hdcBuffer = CreateCompatibleDC(ps.hdc); | |
802 HBITMAP hbmpBuffer = CreateCompatibleBitmap(ps.hdc, | |
803 clip.right-clip.left, clip.bottom-clip.top); | |
804 HBITMAP hbmpDefault = SelectObject(hdcBuffer, hbmpBuffer); | |
805 | |
806 paintToHDC(hdcBuffer, getControl(hwnd), clip); | |
807 | |
808 BitBlt(ps.hdc, clip.left, clip.top, clip.right-clip.left, clip.bottom-clip.top, | |
809 hdcBuffer, 0, 0, SRCCOPY); | |
810 SelectObject(hdcBuffer, hbmpDefault); | |
811 DeleteDC(hdcBuffer); | |
812 DeleteObject(hbmpBuffer); | |
813 | |
814 EndPaint(hwnd, &ps); | |
815 return 0; | |
816 case WM_CLOSE: | |
817 c.visible = false; | |
818 //DestroyWindow(hwnd); | |
819 //PostQuitMessage(0); | |
820 return 0; | |
821 case WM_DESTROY: | |
822 return 0; | |
823 default: | |
824 break; | |
825 } | |
826 return DefWindowProc(hwnd, uMsg, wParam, lParam); | |
827 } | |
828 //}}} | |
829 | |
830 //{{{ paintToHDC() | |
831 void paintToHDC(HDC hdc, Window w, RECT* clip) { | |
832 cairo_surface_t* surface = cairo_win32_surface_create(hdc); | |
833 cairo_t* cr = cairo_create(surface); | |
834 cairo_surface_destroy(surface); | |
835 | |
836 if(clip) { | |
837 cairo_translate(cr, | |
838 -clip.left-w.borderSize.left, -clip.top-w.borderSize.top); | |
839 | |
840 //cairo_rectangle(cr, clip.left, clip.top, clip.right-clip.left, clip.bottom-clip.top); | |
841 } | |
842 //if(w.Opaque) { | |
843 //cairo_set_source_rgb(cr, w.content.backColor.R/255.0, w.content.backColor.G/255.0, w.content.backColor.B/255.0); | |
844 //cairo_paint(cr); | |
845 //} | |
846 | |
847 //cairo_set_source_rgb(cr, .3, .3, .3); | |
848 //cairo_paint(cr); | |
849 | |
850 //cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); | |
851 //cairo_paint(cr); | |
852 //cairo_set_operator(cr, CAIRO_OPERATOR_OVER); | |
853 | |
854 cairo_set_source_rgb(cr, 0, 0, 0); | |
855 cairo_set_line_width(cr, 1.0); | |
856 | |
857 //HBITMAP hbmp = LoadImage(null, cast(wchar*)cast(ushort)OIC_WARNING, | |
858 // IMAGE_ICON, 0, 0, LR_SHARED); | |
859 //if(hbmp == null) | |
860 // Stdout.format("LoadImage failed. GetLastError()={}", GetLastError()).newline; | |
861 | |
862 //auto imgSurface = cairo_image_surface_create_for_data(); | |
863 //cairo_set_source_surface(cr, imgSurface, 50, 50); | |
864 //cairo_paint(cr); | |
865 //cairo_surface_destroy(imgSurface); | |
866 | |
867 auto g = new Graphics(cr); | |
868 scope args = new PaintingEventArgs(g); | |
869 w.painting(args); | |
870 delete g; | |
871 cairo_destroy(cr); | |
872 } | |
873 //}}} | |
874 | |
875 //{{{ VKToKey() | |
876 Key VKToKey(int code) { | |
877 switch(code) { | |
878 case VK_F1: return Key.F1; | |
879 case VK_F2: return Key.F2; | |
880 case VK_F3: return Key.F3; | |
881 case VK_F4: return Key.F4; | |
882 case VK_F5: return Key.F5; | |
883 case VK_F6: return Key.F6; | |
884 case VK_F7: return Key.F7; | |
885 case VK_F8: return Key.F8; | |
886 case VK_F9: return Key.F9; | |
887 case VK_F10: return Key.F10; | |
888 case VK_F11: return Key.F11; | |
889 case VK_F12: return Key.F12; | |
890 | |
891 case VK_ESCAPE: return Key.Escape; | |
892 case VK_TAB: return Key.Tab; | |
893 case VK_BACK: return Key.Backspace; | |
894 case VK_RETURN: return Key.Enter; | |
895 case VK_SPACE: return Key.Space; | |
896 | |
897 case VK_LEFT: return Key.Left; | |
898 case VK_RIGHT: return Key.Right; | |
899 case VK_UP: return Key.Up; | |
900 case VK_DOWN: return Key.Down; | |
901 | |
902 case VK_INSERT: return Key.Insert; | |
903 case VK_DELETE: return Key.Delete; | |
904 case VK_HOME: return Key.Home; | |
905 case VK_END: return Key.End; | |
906 case VK_PRIOR: return Key.PageUp; | |
907 case VK_NEXT: return Key.PageDown; | |
908 | |
909 case VK_SNAPSHOT: return Key.PrintScreen; | |
910 case VK_PAUSE: return Key.Pause; | |
911 | |
912 case VK_CAPITAL: return Key.CapsLock; | |
913 case VK_NUMLOCK: return Key.NumLock; | |
914 case VK_SCROLL: return Key.ScrollLock; | |
915 | |
916 case VK_NUMPAD0: return Key.NumPad0; | |
917 case VK_NUMPAD1: return Key.NumPad1; | |
918 case VK_NUMPAD2: return Key.NumPad2; | |
919 case VK_NUMPAD3: return Key.NumPad3; | |
920 case VK_NUMPAD4: return Key.NumPad4; | |
921 case VK_NUMPAD5: return Key.NumPad5; | |
922 case VK_NUMPAD6: return Key.NumPad6; | |
923 case VK_NUMPAD7: return Key.NumPad7; | |
924 case VK_NUMPAD8: return Key.NumPad8; | |
925 case VK_NUMPAD9: return Key.NumPad9; | |
926 case VK_DIVIDE: return Key.NumPadDivide; | |
927 case VK_MULTIPLY: return Key.NumPadMultiply; | |
928 case VK_SUBTRACT: return Key.NumPadSubtract; | |
929 case VK_ADD: return Key.NumPadAdd; | |
930 case VK_DECIMAL: return Key.NumPadDecimal; | |
931 | |
932 case VK_OEM_3: return Key.Backquote; | |
933 case VK_OEM_MINUS: return Key.Minus; | |
934 case VK_OEM_PLUS: return Key.Equals; | |
935 case VK_OEM_4: return Key.OpenBracket; | |
936 case VK_OEM_6: return Key.CloseBracket; | |
937 case VK_OEM_5: return Key.Backslash; | |
938 case VK_OEM_1: return Key.Semicolon; | |
939 case VK_OEM_7: return Key.Quote; | |
940 case VK_OEM_COMMA: return Key.Comma; | |
941 case VK_OEM_PERIOD: return Key.Period; | |
942 case VK_OEM_2: return Key.Slash; | |
943 | |
944 //case VK_APPS: return Key.Menu; | |
945 | |
946 case VK_SHIFT: return Key.Shift; | |
947 case VK_CONTROL: return Key.Control; | |
948 case VK_MENU: return Key.Alt; | |
949 | |
950 //case VK_: return Key.; | |
951 default: | |
952 if(code >= 0x30 && code <= 0x39) // Key.D0 - Key.D9 | |
953 return cast(Key)code; | |
954 if(code >= 0x41 && code <= 0x5A) // Key.A - Key.Z | |
955 return cast(Key)code; | |
956 return cast(Key)0; | |
957 } | |
958 } | |
959 //}}} | |
960 | |
961 // Use the msgWnd for the following: | |
962 // Timers | |
963 // Clipboard.DataChanged event | |
964 // Clipboard? | |
965 // Taskbar created event using RegisterWindowMessage("TaskbarCreated") | |
966 // different settings changed events? | |
967 // screen saver enabled? | |
968 extern(Windows) | |
969 LRESULT dynaminMsgWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { | |
970 switch(uMsg) { | |
971 case WM_THEMECHANGED: | |
972 Ux.themeChanged(); | |
973 return 0; | |
974 case WM_POWERBROADCAST: | |
975 if(wParam == PBT_APMRESUMESUSPEND || wParam == PBT_APMRESUMECRITICAL) | |
976 Environment.backend_increaseTimerRes(); | |
977 return 0; | |
12
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
978 case WM_USER + 7: |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
979 void delegate() dg; |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
980 dg.ptr = cast(void*)wParam; |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
981 dg.funcptr = cast(void function())lParam; |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
982 dg(); |
7a7e5f9bd1ae
Implement invoke() and invokeNow() on Windows.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
983 return 0; |
0 | 984 case WM_TIMER: |
985 case WM_CHANGECBCHAIN: | |
986 case WM_DRAWCLIPBOARD: | |
987 case WM_TIMECHANGE: //?? | |
988 default: | |
989 break; | |
990 } | |
991 return DefWindowProc(hwnd, uMsg, wParam, lParam); | |
992 } | |
993 |