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