1 | /* $Id: window.cpp,v 1.140 2004-03-09 10:06:15 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 window apis for OS/2
|
---|
4 | *
|
---|
5 | * Copyright 1999-2001 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
---|
7 | * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
|
---|
8 | *
|
---|
9 | * Parts based on Wine Windows code (windows\win.c, windows\property.c, windows\winpos.c)
|
---|
10 | *
|
---|
11 | * Copyright 1993, 1994, 1995 Alexandre Julliard
|
---|
12 | * 1995, 1996, 1999 Alex Korobka
|
---|
13 | *
|
---|
14 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
15 | *
|
---|
16 | *
|
---|
17 | * TODO: Decide what to do about commands for OS/2 windows (non-Win32 apps)
|
---|
18 | * TODO: ShowOwnedPopups needs to be tested
|
---|
19 | * GetLastActivePopup needs to be rewritten
|
---|
20 | *
|
---|
21 | */
|
---|
22 |
|
---|
23 | #include <odin.h>
|
---|
24 | #include <odinwrap.h>
|
---|
25 | #include <os2sel.h>
|
---|
26 |
|
---|
27 | #include <os2win.h>
|
---|
28 | #include <misc.h>
|
---|
29 | #include <string.h>
|
---|
30 | #include <stdio.h>
|
---|
31 | #include "win32wbase.h"
|
---|
32 | #include "win32wmdiclient.h"
|
---|
33 | #include "win32wdesktop.h"
|
---|
34 | #include "win32dlg.h"
|
---|
35 | #include "oslibwin.h"
|
---|
36 | #include "oslibgdi.h"
|
---|
37 | #include "user32.h"
|
---|
38 | #include "winicon.h"
|
---|
39 | #include "pmwindow.h"
|
---|
40 | #include "oslibmsg.h"
|
---|
41 | #include <win/winpos.h>
|
---|
42 | #include <win/win.h>
|
---|
43 | #include <heapstring.h>
|
---|
44 | #include <winuser32.h>
|
---|
45 | #include "hook.h"
|
---|
46 | #include <wprocess.h>
|
---|
47 | #include <custombuild.h>
|
---|
48 |
|
---|
49 | #define DBG_LOCALLOG DBG_window
|
---|
50 | #include "dbglocal.h"
|
---|
51 |
|
---|
52 | ODINDEBUGCHANNEL(USER32-WINDOW)
|
---|
53 |
|
---|
54 | #ifdef __cplusplus
|
---|
55 | extern "C" {
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | //******************************************************************************
|
---|
59 | //******************************************************************************
|
---|
60 | HWND WIN32API CreateWindowExA(DWORD exStyle,
|
---|
61 | LPCSTR className,
|
---|
62 | LPCSTR windowName,
|
---|
63 | DWORD style,
|
---|
64 | INT x,
|
---|
65 | INT y,
|
---|
66 | INT width,
|
---|
67 | INT height,
|
---|
68 | HWND parent,
|
---|
69 | HMENU menu,
|
---|
70 | HINSTANCE instance,
|
---|
71 | LPVOID data )
|
---|
72 | {
|
---|
73 | Win32BaseWindow *window;
|
---|
74 | ATOM classAtom;
|
---|
75 | CREATESTRUCTA cs;
|
---|
76 | char tmpClass[20];
|
---|
77 |
|
---|
78 | if(exStyle & WS_EX_MDICHILD)
|
---|
79 | return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
---|
80 |
|
---|
81 | /* Find the class atom */
|
---|
82 | if (!(classAtom = GlobalFindAtomA(className)))
|
---|
83 | {
|
---|
84 | if (!HIWORD(className))
|
---|
85 | dprintf(("CreateWindowEx32A: bad class name %04x\n",LOWORD(className)));
|
---|
86 | else
|
---|
87 | dprintf(("CreateWindowEx32A: bad class name '%s'\n", className));
|
---|
88 |
|
---|
89 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
90 | return 0;
|
---|
91 | }
|
---|
92 |
|
---|
93 | // if the pointer to the classname string has the high word cleared,
|
---|
94 | // then it's not a pointer but a number for one of the builtin classes
|
---|
95 | if (!HIWORD(className))
|
---|
96 | {
|
---|
97 | sprintf(tmpClass,"#%d", (int) className);
|
---|
98 | className = tmpClass;
|
---|
99 | }
|
---|
100 |
|
---|
101 | /* Create the window */
|
---|
102 | cs.lpCreateParams = data;
|
---|
103 | cs.hInstance = instance;
|
---|
104 | cs.hMenu = menu;
|
---|
105 | cs.hwndParent = parent;
|
---|
106 | cs.x = x;
|
---|
107 | cs.y = y;
|
---|
108 | cs.cx = width;
|
---|
109 | cs.cy = height;
|
---|
110 | cs.style = style;
|
---|
111 | cs.lpszName = windowName;
|
---|
112 | cs.lpszClass = className;
|
---|
113 | cs.dwExStyle = exStyle;
|
---|
114 |
|
---|
115 | HOOK_CallOdinHookA(HODIN_PREWINDOWCREATEDA, 0, (DWORD)&cs);
|
---|
116 |
|
---|
117 | if(HIWORD(className)) {
|
---|
118 | dprintf(("CreateWindowExA: window %s class %s parent %x (%d,%d) (%d,%d), %x %x menu=%x", windowName, className, parent, x, y, width, height, style, exStyle, menu));
|
---|
119 | }
|
---|
120 | else dprintf(("CreateWindowExA: window %s class %d parent %x (%d,%d) (%d,%d), %x %x menu=%x", windowName, className, parent, x, y, width, height, style, exStyle, menu));
|
---|
121 |
|
---|
122 | if(!stricmp(className, MDICLIENTCLASSNAMEA)) {
|
---|
123 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, FALSE);
|
---|
124 | }
|
---|
125 | else
|
---|
126 | if(!stricmp((char *) className, DIALOG_CLASS_NAMEA))
|
---|
127 | {
|
---|
128 | DLG_TEMPLATE dlgTemplate = {0};
|
---|
129 | dlgTemplate.style = cs.style;
|
---|
130 | dlgTemplate.exStyle = cs.dwExStyle;
|
---|
131 | dlgTemplate.x = cs.x;
|
---|
132 | dlgTemplate.y = cs.y;
|
---|
133 | dlgTemplate.cx = cs.cx;
|
---|
134 | dlgTemplate.cy = cs.cy;
|
---|
135 | dlgTemplate.className = cs.lpszClass;
|
---|
136 | dlgTemplate.caption = cs.lpszName;
|
---|
137 | window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
|
---|
138 | (LPCSTR) &dlgTemplate,
|
---|
139 | cs.hwndParent,
|
---|
140 | NULL,
|
---|
141 | (LPARAM) data,
|
---|
142 | FALSE);
|
---|
143 | }
|
---|
144 | else {
|
---|
145 | window = new Win32BaseWindow( &cs, classAtom, FALSE );
|
---|
146 | }
|
---|
147 | if(window == NULL)
|
---|
148 | {
|
---|
149 | dprintf(("Win32BaseWindow creation failed!!"));
|
---|
150 | return 0;
|
---|
151 | }
|
---|
152 | if(GetLastError() != 0)
|
---|
153 | {
|
---|
154 | dprintf(("Win32BaseWindow error found!!"));
|
---|
155 | RELEASE_WNDOBJ(window);
|
---|
156 | delete window;
|
---|
157 | return 0;
|
---|
158 | }
|
---|
159 | HWND hwnd = window->getWindowHandle();
|
---|
160 |
|
---|
161 | // set myself as last active popup / window
|
---|
162 | window->setLastActive( hwnd );
|
---|
163 |
|
---|
164 | RELEASE_WNDOBJ(window);
|
---|
165 | return hwnd;
|
---|
166 | }
|
---|
167 | //******************************************************************************
|
---|
168 | //******************************************************************************
|
---|
169 | HWND WIN32API CreateWindowExW(DWORD exStyle,
|
---|
170 | LPCWSTR className,
|
---|
171 | LPCWSTR windowName,
|
---|
172 | DWORD style,
|
---|
173 | INT x,
|
---|
174 | INT y,
|
---|
175 | INT width,
|
---|
176 | INT height,
|
---|
177 | HWND parent,
|
---|
178 | HMENU menu,
|
---|
179 | HINSTANCE instance,
|
---|
180 | LPVOID data )
|
---|
181 | {
|
---|
182 | Win32BaseWindow *window;
|
---|
183 | ATOM classAtom;
|
---|
184 | CREATESTRUCTA cs;
|
---|
185 | WCHAR tmpClassW[20];
|
---|
186 |
|
---|
187 | if(exStyle & WS_EX_MDICHILD)
|
---|
188 | return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
---|
189 |
|
---|
190 | /* Find the class atom */
|
---|
191 | if (!(classAtom = GlobalFindAtomW(className)))
|
---|
192 | {
|
---|
193 | if (!HIWORD(className))
|
---|
194 | dprintf(("CreateWindowEx32W: bad class name %04x",LOWORD(className)));
|
---|
195 | else
|
---|
196 | dprintf(("CreateWindowEx32W: bad class name '%ls'", className));
|
---|
197 |
|
---|
198 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
199 | return 0;
|
---|
200 | }
|
---|
201 | #ifdef DEBUG
|
---|
202 | if(HIWORD(className)) {
|
---|
203 | dprintf(("CreateWindowExW: class %ls name %ls parent %x (%d,%d) (%d,%d), %x %x menu=%x", className, HIWORD(windowName) ? windowName : NULL, parent, x, y, width, height, style, exStyle, menu));
|
---|
204 | }
|
---|
205 | else dprintf(("CreateWindowExW: class %d name %ls parent %x (%d,%d) (%d,%d), %x %x menu=%x", className, HIWORD(windowName) ? windowName : NULL, parent, x, y, width, height, style, exStyle, menu));
|
---|
206 | #endif
|
---|
207 | // if the pointer to the classname string has the high word cleared,
|
---|
208 | // then it's not a pointer but a number for one of the builtin classes
|
---|
209 | if (!HIWORD(className))
|
---|
210 | {
|
---|
211 | wsprintfW(tmpClassW, (LPCWSTR)L"#%d", (int) className);
|
---|
212 | className = tmpClassW;
|
---|
213 | }
|
---|
214 |
|
---|
215 | /* Create the window */
|
---|
216 | cs.lpCreateParams = data;
|
---|
217 | cs.hInstance = instance;
|
---|
218 | cs.hMenu = menu;
|
---|
219 | cs.hwndParent = parent;
|
---|
220 | cs.x = x;
|
---|
221 | cs.y = y;
|
---|
222 | cs.cx = width;
|
---|
223 | cs.cy = height;
|
---|
224 | cs.style = style;
|
---|
225 | cs.lpszName = (LPSTR)windowName;
|
---|
226 | cs.lpszClass = (LPSTR)className;
|
---|
227 | cs.dwExStyle = exStyle;
|
---|
228 |
|
---|
229 | if(!lstrcmpiW(className, (LPWSTR)MDICLIENTCLASSNAMEW)) {
|
---|
230 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, TRUE);
|
---|
231 | }
|
---|
232 | else
|
---|
233 | if(!lstrcmpiW(className, (LPWSTR)DIALOG_CLASS_NAMEW))
|
---|
234 | {
|
---|
235 | DLG_TEMPLATE dlgTemplate = {0};
|
---|
236 | dlgTemplate.style = cs.style;
|
---|
237 | dlgTemplate.exStyle = cs.dwExStyle;
|
---|
238 | dlgTemplate.x = cs.x;
|
---|
239 | dlgTemplate.y = cs.y;
|
---|
240 | dlgTemplate.cx = cs.cx;
|
---|
241 | dlgTemplate.cy = cs.cy;
|
---|
242 | dlgTemplate.className = cs.lpszClass;
|
---|
243 | dlgTemplate.caption = cs.lpszName;
|
---|
244 | window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
|
---|
245 | (LPCSTR) &dlgTemplate,
|
---|
246 | cs.hwndParent,
|
---|
247 | NULL,
|
---|
248 | (LPARAM) data,
|
---|
249 | TRUE);
|
---|
250 | }
|
---|
251 | else {
|
---|
252 | window = new Win32BaseWindow( &cs, classAtom, TRUE );
|
---|
253 | }
|
---|
254 | if(window == NULL)
|
---|
255 | {
|
---|
256 | dprintf(("Win32BaseWindow creation failed!!"));
|
---|
257 | return 0;
|
---|
258 | }
|
---|
259 | if(GetLastError() != 0)
|
---|
260 | {
|
---|
261 | dprintf(("Win32BaseWindow error found!!"));
|
---|
262 | RELEASE_WNDOBJ(window);
|
---|
263 | delete window;
|
---|
264 | return 0;
|
---|
265 | }
|
---|
266 | HWND hwnd = window->getWindowHandle();
|
---|
267 |
|
---|
268 | // set myself as last active popup / window
|
---|
269 | window->setLastActive( hwnd );
|
---|
270 |
|
---|
271 | RELEASE_WNDOBJ(window);
|
---|
272 | return hwnd;
|
---|
273 | }
|
---|
274 | //******************************************************************************
|
---|
275 | //******************************************************************************
|
---|
276 | BOOL WIN32API DestroyWindow(HWND hwnd)
|
---|
277 | {
|
---|
278 | Win32BaseWindow *window;
|
---|
279 | BOOL ret;
|
---|
280 |
|
---|
281 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
282 | if(!window) {
|
---|
283 | dprintf(("DestroyWindow, window %x not found", hwnd));
|
---|
284 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
285 | return 0;
|
---|
286 | }
|
---|
287 | ret = window->DestroyWindow();
|
---|
288 | RELEASE_WNDOBJ(window);
|
---|
289 | return ret;
|
---|
290 | }
|
---|
291 | //******************************************************************************
|
---|
292 | //******************************************************************************
|
---|
293 | HWND WIN32API SetActiveWindow(HWND hwnd)
|
---|
294 | {
|
---|
295 | Win32BaseWindow *window;
|
---|
296 | HWND hwndActive;
|
---|
297 |
|
---|
298 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
299 | if(!window) {
|
---|
300 | dprintf(("SetActiveWindow, window %x not found", hwnd));
|
---|
301 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
302 | return 0;
|
---|
303 | }
|
---|
304 | hwndActive = window->SetActiveWindow();
|
---|
305 |
|
---|
306 | // check last active popup window
|
---|
307 | if (hwndActive)
|
---|
308 | {
|
---|
309 | // TODO:
|
---|
310 | // set last active popup window to the ancestor window
|
---|
311 | dprintf(("support for last active popup incorrectly implemented"));
|
---|
312 | }
|
---|
313 |
|
---|
314 | RELEASE_WNDOBJ(window);
|
---|
315 | return hwndActive;
|
---|
316 | }
|
---|
317 | //******************************************************************************
|
---|
318 | //Note: does not set last error if no parent (verified in NT4, SP6)
|
---|
319 | //******************************************************************************
|
---|
320 | HWND WIN32API GetParent(HWND hwnd)
|
---|
321 | {
|
---|
322 | Win32BaseWindow *window;
|
---|
323 | HWND hwndParent;
|
---|
324 |
|
---|
325 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
326 | if(!window) {
|
---|
327 | dprintf(("GetParent, window %x not found", hwnd));
|
---|
328 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
329 | return 0;
|
---|
330 | }
|
---|
331 | dprintf2(("GetParent %x", hwnd));
|
---|
332 | hwndParent = window->GetParent();
|
---|
333 | RELEASE_WNDOBJ(window);
|
---|
334 | return hwndParent;
|
---|
335 | }
|
---|
336 | //******************************************************************************
|
---|
337 | //******************************************************************************
|
---|
338 | HWND WIN32API SetParent(HWND hwndChild, HWND hwndNewParent)
|
---|
339 | {
|
---|
340 | Win32BaseWindow *window;
|
---|
341 | HWND hwndOldParent;
|
---|
342 |
|
---|
343 | window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
|
---|
344 | if(!window) {
|
---|
345 | dprintf(("SetParent, window %x not found", hwndChild));
|
---|
346 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
347 | return 0;
|
---|
348 | }
|
---|
349 | if(hwndNewParent == HWND_DESKTOP) {
|
---|
350 | hwndNewParent = GetDesktopWindow();
|
---|
351 | }
|
---|
352 | else {
|
---|
353 | if(!IsWindow(hwndNewParent)) {
|
---|
354 | RELEASE_WNDOBJ(window);
|
---|
355 | dprintf(("SetParent, parent %x not found", hwndNewParent));
|
---|
356 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
357 | return 0;
|
---|
358 | }
|
---|
359 | }
|
---|
360 | dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
|
---|
361 | hwndOldParent = window->SetParent(hwndNewParent);
|
---|
362 | RELEASE_WNDOBJ(window);
|
---|
363 | return hwndOldParent;
|
---|
364 | }
|
---|
365 | //******************************************************************************
|
---|
366 | //******************************************************************************
|
---|
367 | BOOL WIN32API IsChild(HWND hwndParent, HWND hwnd)
|
---|
368 | {
|
---|
369 | Win32BaseWindow *window;
|
---|
370 | BOOL fIsChild;
|
---|
371 |
|
---|
372 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
373 | if(!window) {
|
---|
374 | dprintf(("IsChild %x, window %x not found", hwndParent, hwnd));
|
---|
375 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
376 | return 0;
|
---|
377 | }
|
---|
378 | dprintf(("IsChild %x %x", hwndParent, hwnd));
|
---|
379 | fIsChild = window->IsChild(hwndParent);
|
---|
380 | RELEASE_WNDOBJ(window);
|
---|
381 | return fIsChild;
|
---|
382 | }
|
---|
383 | //******************************************************************************
|
---|
384 | //******************************************************************************
|
---|
385 | HWND WIN32API GetTopWindow(HWND hwnd)
|
---|
386 | {
|
---|
387 | Win32BaseWindow *window;
|
---|
388 | HWND hwndTop;
|
---|
389 |
|
---|
390 | if(hwnd == HWND_DESKTOP) {
|
---|
391 | windowDesktop->addRef();
|
---|
392 | window = windowDesktop;
|
---|
393 | }
|
---|
394 | else {
|
---|
395 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
396 | if(!window) {
|
---|
397 | dprintf(("GetTopWindow, window %x not found", hwnd));
|
---|
398 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
399 | return 0;
|
---|
400 | }
|
---|
401 | }
|
---|
402 | hwndTop = window->GetTopWindow();
|
---|
403 | dprintf2(("GetTopWindow %x returned %x", hwnd, hwndTop));
|
---|
404 | RELEASE_WNDOBJ(window);
|
---|
405 | return hwndTop;
|
---|
406 | }
|
---|
407 | //******************************************************************************
|
---|
408 | //******************************************************************************
|
---|
409 | BOOL WIN32API IsIconic(HWND hwnd)
|
---|
410 | {
|
---|
411 | Win32BaseWindow *window;
|
---|
412 | BOOL fIsIconic;
|
---|
413 |
|
---|
414 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
415 | if(!window) {
|
---|
416 | dprintf(("IsIconic, window %x not found", hwnd));
|
---|
417 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
418 | return FALSE;
|
---|
419 | }
|
---|
420 | fIsIconic = window->IsWindowIconic();
|
---|
421 | dprintf(("IsIconic %x returned %d", hwnd, fIsIconic));
|
---|
422 | RELEASE_WNDOBJ(window);
|
---|
423 | return fIsIconic;
|
---|
424 | }
|
---|
425 | //******************************************************************************
|
---|
426 | //******************************************************************************
|
---|
427 | HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
|
---|
428 | {
|
---|
429 | Win32BaseWindow *window;
|
---|
430 | HWND hwndRelated;
|
---|
431 |
|
---|
432 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
433 | if(!window) {
|
---|
434 | dprintf(("GetWindow, window %x not found", hwnd));
|
---|
435 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
436 | return 0;
|
---|
437 | }
|
---|
438 | hwndRelated = window->GetWindow(uCmd);
|
---|
439 | RELEASE_WNDOBJ(window);
|
---|
440 | return hwndRelated;
|
---|
441 | }
|
---|
442 |
|
---|
443 | /******************************************************************************
|
---|
444 | * GetWindowInfo (USER32.@)
|
---|
445 | *
|
---|
446 | * Note: tests show that Windows doesn't check cbSize of the structure.
|
---|
447 | */
|
---|
448 | BOOL WINAPI GetWindowInfo( HWND hwnd, PWINDOWINFO pwi)
|
---|
449 | {
|
---|
450 | if (!pwi) return FALSE;
|
---|
451 | if (!IsWindow(hwnd)) return FALSE;
|
---|
452 |
|
---|
453 | GetWindowRect(hwnd, &pwi->rcWindow);
|
---|
454 | GetClientRect(hwnd, &pwi->rcClient);
|
---|
455 | /* translate to screen coordinates */
|
---|
456 | MapWindowPoints(hwnd, 0, (LPPOINT)&pwi->rcClient, 2);
|
---|
457 |
|
---|
458 | pwi->dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
|
---|
459 | pwi->dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
|
---|
460 | pwi->dwWindowStatus = ((GetActiveWindow() == hwnd) ? WS_ACTIVECAPTION : 0);
|
---|
461 |
|
---|
462 | pwi->cxWindowBorders = pwi->rcClient.left - pwi->rcWindow.left;
|
---|
463 | pwi->cyWindowBorders = pwi->rcWindow.bottom - pwi->rcClient.bottom;
|
---|
464 |
|
---|
465 | pwi->atomWindowType = GetClassLongW( hwnd, GCW_ATOM );
|
---|
466 | pwi->wCreatorVersion = 0x0400;
|
---|
467 |
|
---|
468 | return TRUE;
|
---|
469 | }
|
---|
470 | /*****************************************************************************
|
---|
471 | * UpdateLayeredWindow (USER32.@)
|
---|
472 | */
|
---|
473 | BOOL WIN32API UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT *pptDst,SIZE *psize,
|
---|
474 | HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend,
|
---|
475 | DWORD dwFlags)
|
---|
476 | {
|
---|
477 | dprintf(("USER32: UpdateLayeredWindow(%08xh, %08xh, %08xh, %08xh, %08xh, "
|
---|
478 | "%08xh, %08xh, %08xh, %08xh) not implemented\n",
|
---|
479 | hwnd, hdcDst, pptDst, psize, hdcSrc, pptSrc, crKey, pblend, dwFlags));
|
---|
480 | return FALSE;
|
---|
481 | }
|
---|
482 |
|
---|
483 | //******************************************************************************
|
---|
484 | //******************************************************************************
|
---|
485 | BOOL WIN32API EnableWindow(HWND hwnd, BOOL fEnable)
|
---|
486 | {
|
---|
487 | Win32BaseWindow *window;
|
---|
488 | BOOL fEnabled;
|
---|
489 |
|
---|
490 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
491 | if(!window) {
|
---|
492 | dprintf(("EnableWindow, window %x not found", hwnd));
|
---|
493 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
494 | return 0;
|
---|
495 | }
|
---|
496 | dprintf(("EnableWindow %x %d", hwnd, fEnable));
|
---|
497 | fEnabled = window->EnableWindow(fEnable);
|
---|
498 | RELEASE_WNDOBJ(window);
|
---|
499 | return fEnabled;
|
---|
500 | }
|
---|
501 | //******************************************************************************
|
---|
502 | //******************************************************************************
|
---|
503 | BOOL WIN32API BringWindowToTop(HWND hwnd)
|
---|
504 | {
|
---|
505 | dprintf(("BringWindowToTop %x", hwnd));
|
---|
506 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
|
---|
507 | }
|
---|
508 | /***********************************************************************
|
---|
509 | * SetInternalWindowPos (USER32.483)
|
---|
510 | */
|
---|
511 | VOID WIN32API SetInternalWindowPos(HWND hwnd, UINT showCmd, LPRECT lpRect,
|
---|
512 | LPPOINT lpPoint )
|
---|
513 | {
|
---|
514 | if( IsWindow(hwnd) )
|
---|
515 | {
|
---|
516 | WINDOWPLACEMENT wndpl;
|
---|
517 | UINT flags;
|
---|
518 |
|
---|
519 | GetWindowPlacement(hwnd, &wndpl);
|
---|
520 | wndpl.length = sizeof(wndpl);
|
---|
521 | wndpl.showCmd = showCmd;
|
---|
522 | wndpl.flags = 0;
|
---|
523 |
|
---|
524 | if(lpPoint)
|
---|
525 | {
|
---|
526 | wndpl.flags |= WPF_SETMINPOSITION;
|
---|
527 | wndpl.ptMinPosition = *lpPoint;
|
---|
528 | }
|
---|
529 | if(lpRect)
|
---|
530 | {
|
---|
531 | wndpl.rcNormalPosition = *lpRect;
|
---|
532 | }
|
---|
533 | SetWindowPlacement(hwnd, &wndpl);
|
---|
534 | }
|
---|
535 |
|
---|
536 | }
|
---|
537 | /***********************************************************************
|
---|
538 | * GetInternalWindowPos (USER32.245)
|
---|
539 | */
|
---|
540 | UINT WIN32API GetInternalWindowPos(HWND hwnd, LPRECT rectWnd, LPPOINT ptIcon )
|
---|
541 | {
|
---|
542 | WINDOWPLACEMENT wndpl;
|
---|
543 |
|
---|
544 | if(GetWindowPlacement( hwnd, &wndpl ))
|
---|
545 | {
|
---|
546 | if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
|
---|
547 | if (ptIcon) *ptIcon = wndpl.ptMinPosition;
|
---|
548 | return wndpl.showCmd;
|
---|
549 | }
|
---|
550 | return 0;
|
---|
551 | }
|
---|
552 | //******************************************************************************
|
---|
553 | //******************************************************************************
|
---|
554 | HWND GetActiveWindow()
|
---|
555 | {
|
---|
556 | return Win32BaseWindow::GetActiveWindow();
|
---|
557 | }
|
---|
558 | //******************************************************************************
|
---|
559 | //******************************************************************************
|
---|
560 | BOOL WIN32API ShowWindow(HWND hwnd, INT nCmdShow)
|
---|
561 | {
|
---|
562 | Win32BaseWindow *window;
|
---|
563 | BOOL ret;
|
---|
564 |
|
---|
565 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
566 | if(!window) {
|
---|
567 | dprintf(("ShowWindow, window %x not found", hwnd));
|
---|
568 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
569 | return 0;
|
---|
570 | }
|
---|
571 |
|
---|
572 | //PF Start PM restoration routine first if we restore from icon
|
---|
573 | //so all internal PM logic will work - this routine will always
|
---|
574 | //lead to ShowWindow(SW_RESTORE)
|
---|
575 |
|
---|
576 | if ((nCmdShow == SW_RESTORE) && (window->getStyle() & WS_MINIMIZE) && fOS2Look )
|
---|
577 | {
|
---|
578 | dprintf(("ShowWindow: Initiating OS/2 PM restore"));
|
---|
579 | ret = OSLibWinRestoreWindow(window->getOS2FrameWindowHandle());
|
---|
580 | }
|
---|
581 | else
|
---|
582 | ret = window->ShowWindow(nCmdShow);
|
---|
583 | RELEASE_WNDOBJ(window);
|
---|
584 | return ret;
|
---|
585 | }
|
---|
586 | /*****************************************************************************
|
---|
587 | * Name : BOOL WIN32API ShowWindowAsync
|
---|
588 | * Purpose : The ShowWindowAsync function sets the show state of a window
|
---|
589 | * created by a different thread.
|
---|
590 | * Parameters: HWND hwnd handle of window
|
---|
591 | * int nCmdShow show state of window
|
---|
592 | * Variables :
|
---|
593 | * Result : If the window was previously visible, the return value is TRUE.
|
---|
594 | * If the window was previously hidden, the return value is FALSE.
|
---|
595 | * Remark :
|
---|
596 | * Status : UNTESTED STUB
|
---|
597 | *
|
---|
598 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
599 | *****************************************************************************/
|
---|
600 | BOOL WIN32API ShowWindowAsync(HWND hwnd, int nCmdShow)
|
---|
601 | {
|
---|
602 | dprintf(("USER32:ShowWindowAsync (%08xh,%08x) not correctly implemented.\n",
|
---|
603 | hwnd, nCmdShow));
|
---|
604 |
|
---|
605 | return ShowWindow(hwnd, nCmdShow);
|
---|
606 | }
|
---|
607 | //******************************************************************************
|
---|
608 | //******************************************************************************
|
---|
609 | BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, INT x,
|
---|
610 | INT y, INT cx, INT cy, UINT fuFlags)
|
---|
611 | {
|
---|
612 | Win32BaseWindow *window;
|
---|
613 |
|
---|
614 | if (!hwnd)
|
---|
615 | {
|
---|
616 | dprintf(("SetWindowPos: Can't move desktop!"));
|
---|
617 | return TRUE;
|
---|
618 | }
|
---|
619 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
620 | if(!window) {
|
---|
621 | dprintf(("SetWindowPos, window %x not found", hwnd));
|
---|
622 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
623 | return FALSE;
|
---|
624 | }
|
---|
625 | dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
|
---|
626 | BOOL ret = window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
|
---|
627 | RELEASE_WNDOBJ(window);
|
---|
628 | return ret;
|
---|
629 | }
|
---|
630 | //******************************************************************************
|
---|
631 | //NOTE: length must equal structure size or else api fails (verified in NT4, SP6)
|
---|
632 | //******************************************************************************
|
---|
633 | BOOL WIN32API SetWindowPlacement(HWND hwnd, const WINDOWPLACEMENT *winpos)
|
---|
634 | {
|
---|
635 | Win32BaseWindow *window;
|
---|
636 |
|
---|
637 | if(!winpos || winpos->length != sizeof(WINDOWPLACEMENT)) {
|
---|
638 | dprintf(("SetWindowPlacement %x invalid parameter", hwnd));
|
---|
639 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
640 | return FALSE;
|
---|
641 | }
|
---|
642 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
643 | if(!window) {
|
---|
644 | dprintf(("SetWindowPlacement, window %x not found", hwnd));
|
---|
645 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
646 | return FALSE;
|
---|
647 | }
|
---|
648 | dprintf(("USER32: SetWindowPlacement %x %x", hwnd, winpos));
|
---|
649 | BOOL ret = window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
|
---|
650 | RELEASE_WNDOBJ(window);
|
---|
651 | return ret;
|
---|
652 | }
|
---|
653 | //******************************************************************************
|
---|
654 | //NOTE: Length does not need to be correct (even though the SDK docs claim otherwise)
|
---|
655 | // (Verified in NT4, SP6)
|
---|
656 | //******************************************************************************
|
---|
657 | BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT winpos)
|
---|
658 | {
|
---|
659 | Win32BaseWindow *window;
|
---|
660 |
|
---|
661 | if(!winpos) {
|
---|
662 | dprintf(("GetWindowPlacement %x invalid parameter", hwnd));
|
---|
663 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
664 | return FALSE;
|
---|
665 | }
|
---|
666 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
667 | if(!window) {
|
---|
668 | dprintf(("GetWindowPlacement, window %x not found", hwnd));
|
---|
669 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
670 | return FALSE;
|
---|
671 | }
|
---|
672 | dprintf(("USER32: GetWindowPlacement %x %x", hwnd, winpos));
|
---|
673 | BOOL ret = window->GetWindowPlacement(winpos);
|
---|
674 | RELEASE_WNDOBJ(window);
|
---|
675 | return ret;
|
---|
676 | }
|
---|
677 | //******************************************************************************
|
---|
678 | //******************************************************************************
|
---|
679 | BOOL WIN32API IsWindow(HWND hwnd)
|
---|
680 | {
|
---|
681 | Win32BaseWindow *window;
|
---|
682 |
|
---|
683 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
684 | if(!window) {
|
---|
685 | dprintf(("IsWindow, window %x not found", hwnd));
|
---|
686 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
687 | return FALSE;
|
---|
688 | }
|
---|
689 | dprintf2(("IsWindow %x", hwnd));
|
---|
690 | BOOL fIsWindow = window->IsWindow();
|
---|
691 | RELEASE_WNDOBJ(window);
|
---|
692 | return fIsWindow;
|
---|
693 | }
|
---|
694 | //******************************************************************************
|
---|
695 | //******************************************************************************
|
---|
696 | BOOL WIN32API IsWindowEnabled(HWND hwnd)
|
---|
697 | {
|
---|
698 | DWORD dwStyle;
|
---|
699 |
|
---|
700 | if(!IsWindow(hwnd)) {
|
---|
701 | dprintf(("IsWindowEnabled, window %x not found", hwnd));
|
---|
702 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
703 | return 0;
|
---|
704 | }
|
---|
705 | dprintf(("IsWindowEnabled %x", hwnd));
|
---|
706 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
707 | if(dwStyle & WS_DISABLED) {
|
---|
708 | return FALSE;
|
---|
709 | }
|
---|
710 | return TRUE;
|
---|
711 | }
|
---|
712 | //******************************************************************************
|
---|
713 | //******************************************************************************
|
---|
714 | BOOL WIN32API IsWindowVisible(HWND hwnd)
|
---|
715 | {
|
---|
716 | BOOL ret;
|
---|
717 | HWND hwndParent;
|
---|
718 | DWORD dwStyle;
|
---|
719 |
|
---|
720 | if(hwnd == HWND_DESKTOP) {//TODO: verify in NT!
|
---|
721 | dprintf(("IsWindowVisible DESKTOP returned TRUE"));
|
---|
722 | return TRUE; //desktop is always visible
|
---|
723 | }
|
---|
724 | if(!IsWindow(hwnd)) {
|
---|
725 | dprintf(("IsWindowVisible, window %x not found", hwnd));
|
---|
726 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
727 | return 0;
|
---|
728 | }
|
---|
729 | //check visibility of this window
|
---|
730 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
731 | if(!(dwStyle & WS_VISIBLE)) {
|
---|
732 | ret = FALSE;
|
---|
733 | goto end;
|
---|
734 | }
|
---|
735 | ret = TRUE;
|
---|
736 |
|
---|
737 | if(dwStyle & WS_CHILD)
|
---|
738 | {
|
---|
739 | //check visibility of parents
|
---|
740 | hwndParent = GetParent(hwnd);
|
---|
741 | while(hwndParent) {
|
---|
742 | dwStyle = GetWindowLongA(hwndParent, GWL_STYLE);
|
---|
743 | if(!(dwStyle & WS_VISIBLE)) {
|
---|
744 | dprintf(("IsWindowVisible %x returned FALSE (parent %x invisible)", hwnd, hwndParent));
|
---|
745 | return FALSE;
|
---|
746 | }
|
---|
747 | if(!(dwStyle & WS_CHILD)) {
|
---|
748 | break; //GetParent can also return the owner
|
---|
749 | }
|
---|
750 | hwndParent = GetParent(hwndParent);
|
---|
751 | }
|
---|
752 | }
|
---|
753 | end:
|
---|
754 | dprintf(("IsWindowVisible %x returned %d", hwnd, ret));
|
---|
755 | return ret;
|
---|
756 | }
|
---|
757 | //******************************************************************************
|
---|
758 | //******************************************************************************
|
---|
759 | HWND WINAPI GetAncestor( HWND hwnd, UINT type )
|
---|
760 | {
|
---|
761 | HWND hwndAncestor = 0;
|
---|
762 | Win32BaseWindow *window;
|
---|
763 |
|
---|
764 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
765 | if(!window) {
|
---|
766 | dprintf(("GetAncestor, window %x not found", hwnd));
|
---|
767 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
768 | return FALSE;
|
---|
769 | }
|
---|
770 |
|
---|
771 | if (type == GA_PARENT)
|
---|
772 | {
|
---|
773 | LONG dwStyle = GetWindowLongW( hwnd, GWL_STYLE );
|
---|
774 | if(dwStyle & WS_CHILD) {
|
---|
775 | hwndAncestor = GetParent(hwnd);
|
---|
776 | }
|
---|
777 | //else no child -> no parent (GetParent returns owner otherwise!)
|
---|
778 | }
|
---|
779 | else
|
---|
780 | if (type == GA_ROOT)
|
---|
781 | {
|
---|
782 | hwndAncestor = window->GetTopParent();
|
---|
783 | }
|
---|
784 | else
|
---|
785 | if (type == GA_ROOTOWNER)
|
---|
786 | {
|
---|
787 | if(hwnd != GetDesktopWindow())
|
---|
788 | {
|
---|
789 | hwndAncestor = hwnd;
|
---|
790 | for(;;)
|
---|
791 | {
|
---|
792 | HWND parent = GetParent( hwndAncestor );
|
---|
793 | if (!parent) break;
|
---|
794 | hwndAncestor = parent;
|
---|
795 | }
|
---|
796 | }
|
---|
797 | }
|
---|
798 | else dprintf(("Unsupported type %d", type));
|
---|
799 |
|
---|
800 | RELEASE_WNDOBJ(window);
|
---|
801 | return hwndAncestor;
|
---|
802 | }
|
---|
803 | //******************************************************************************
|
---|
804 | BOOL fIgnoreKeystrokes = FALSE;
|
---|
805 | //******************************************************************************
|
---|
806 | void SetFocusChanged()
|
---|
807 | {
|
---|
808 | //Focus has changed; invalidate SetFocus(0) state
|
---|
809 | fIgnoreKeystrokes = FALSE;
|
---|
810 | }
|
---|
811 | //******************************************************************************
|
---|
812 | //******************************************************************************
|
---|
813 | HWND WIN32API SetFocus(HWND hwnd)
|
---|
814 | {
|
---|
815 | Win32BaseWindow *window;
|
---|
816 | Win32BaseWindow *oldfocuswnd;
|
---|
817 | HWND lastFocus, lastFocus_W, hwnd_O, hwndTopParent, hwndTop;
|
---|
818 | BOOL activate, ret;
|
---|
819 | TEB *teb;
|
---|
820 |
|
---|
821 | dprintf(("SetFocus %x", hwnd));
|
---|
822 | teb = GetThreadTEB();
|
---|
823 | if(teb == NULL) {
|
---|
824 | DebugInt3();
|
---|
825 | return 0;
|
---|
826 | }
|
---|
827 | //Special case; SetFocus(0) tells Windows to ignore keystrokes. Pressing
|
---|
828 | //a key now generates WM_SYSKEYDOWN/(WM_SYSCHAR)/WM_SYSKEYUP instead
|
---|
829 | //of WM_KEYDOWN/(WM_CHAR)/WM_KEYUP
|
---|
830 | //WM_KILLFOCUS is sent to the window that currently has focus
|
---|
831 | if(hwnd == 0) {
|
---|
832 | lastFocus_W = GetFocus();
|
---|
833 | if(lastFocus_W == 0) return 0; //nothing to do
|
---|
834 |
|
---|
835 | if(HOOK_CallHooksA(WH_CBT, HCBT_SETFOCUS, 0, (LPARAM)lastFocus_W)) {
|
---|
836 | dprintf(("hook cancelled SetFocus call!"));
|
---|
837 | return 0;
|
---|
838 | }
|
---|
839 | fIgnoreKeystrokes = TRUE;
|
---|
840 | SendMessageA(lastFocus_W, WM_KILLFOCUS, 0, 0);
|
---|
841 |
|
---|
842 | return lastFocus_W;
|
---|
843 | }
|
---|
844 |
|
---|
845 | //SetFocus is not allowed for minimized or disabled windows (this window
|
---|
846 | //or any parent)
|
---|
847 | hwndTop = hwnd;
|
---|
848 | for (;;)
|
---|
849 | {
|
---|
850 | HWND parent;
|
---|
851 |
|
---|
852 | LONG style = GetWindowLongW( hwndTop, GWL_STYLE );
|
---|
853 | if (style & (WS_MINIMIZE | WS_DISABLED)) {
|
---|
854 | dprintf(("SetFocus, %x not allowed on minimized or disabled window (%x)", hwnd, style));
|
---|
855 | return 0;
|
---|
856 | }
|
---|
857 | parent = GetAncestor(hwndTop, GA_PARENT);
|
---|
858 | if (!parent || parent == GetDesktopWindow()) break;
|
---|
859 | hwndTop = parent;
|
---|
860 | }
|
---|
861 |
|
---|
862 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
863 | if(!window) {
|
---|
864 | dprintf(("SetFocus, window %x not found", hwnd));
|
---|
865 | //Note: last error not set (NT4, SP6), returns current focus window
|
---|
866 | //SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
867 | return GetFocus();
|
---|
868 | }
|
---|
869 |
|
---|
870 | hwnd_O = window->getOS2WindowHandle();
|
---|
871 | lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
|
---|
872 |
|
---|
873 | hwndTopParent = window->GetTopParent();
|
---|
874 | activate = FALSE;
|
---|
875 | lastFocus_W = OS2ToWin32Handle(lastFocus);
|
---|
876 | if(lastFocus_W) {
|
---|
877 | oldfocuswnd = Win32BaseWindow::GetWindowFromHandle(lastFocus_W);
|
---|
878 | if(lastFocus_W != hwnd && hwndTopParent != oldfocuswnd->GetTopParent()) {
|
---|
879 | activate = TRUE;
|
---|
880 | }
|
---|
881 | RELEASE_WNDOBJ(oldfocuswnd);
|
---|
882 | }
|
---|
883 | else activate = TRUE;
|
---|
884 |
|
---|
885 | dprintf(("SetFocus %x (%x) -> %x (%x) act %d", lastFocus_W, lastFocus, hwnd, hwnd_O, activate));
|
---|
886 |
|
---|
887 | if(HOOK_CallHooksA(WH_CBT, HCBT_SETFOCUS, hwnd, (LPARAM)lastFocus_W)) {
|
---|
888 | dprintf(("hook cancelled SetFocus call!"));
|
---|
889 | RELEASE_WNDOBJ(window);
|
---|
890 | return 0;
|
---|
891 | }
|
---|
892 |
|
---|
893 | if(!IsWindow(hwnd)) return FALSE; //abort if window destroyed
|
---|
894 |
|
---|
895 | //NOTE: Don't always activate the window or else the z-order will be changed!!
|
---|
896 | ret = (OSLibWinSetFocus(OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
|
---|
897 | RELEASE_WNDOBJ(window);
|
---|
898 |
|
---|
899 | //If keystrokes were ignored and focus is set to the old focus window, then
|
---|
900 | //PM won't send us a WM_SETFOCUS message. (as we don't inform PM for SetFocus(0))
|
---|
901 | if(fIgnoreKeystrokes && lastFocus_W == hwnd) {
|
---|
902 | dprintf(("Manually send WM_SETFOCUS; real focus window hasn't changed"));
|
---|
903 | SendMessageA(lastFocus_W, WM_SETFOCUS, 0, 0);
|
---|
904 | }
|
---|
905 | fIgnoreKeystrokes = FALSE;
|
---|
906 | return ret;
|
---|
907 | }
|
---|
908 | //******************************************************************************
|
---|
909 | //******************************************************************************
|
---|
910 | HWND WIN32API GetFocus()
|
---|
911 | {
|
---|
912 | TEB *teb;
|
---|
913 | HWND hwnd;
|
---|
914 |
|
---|
915 | teb = GetThreadTEB();
|
---|
916 | if(teb == NULL) {
|
---|
917 | DebugInt3();
|
---|
918 | return 0;
|
---|
919 | }
|
---|
920 | //If keystrokes are ignored (SetFocus(0)), then return 0
|
---|
921 | if(fIgnoreKeystrokes) {
|
---|
922 | dprintf(("GetFocus; returning 0 after SetFocus(0) call"));
|
---|
923 | return 0;
|
---|
924 | }
|
---|
925 | hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
|
---|
926 | hwnd = OS2ToWin32Handle(hwnd);
|
---|
927 | dprintf(("USER32: GetFocus %x\n", hwnd));
|
---|
928 | return hwnd;
|
---|
929 | }
|
---|
930 | //******************************************************************************
|
---|
931 | //******************************************************************************
|
---|
932 | BOOL WIN32API GetGUIThreadInfo(DWORD dwThreadId, GUITHREADINFO *lpThreadInfo)
|
---|
933 | {
|
---|
934 | dprintf(("!WARNING!: GetGUIThreadInfo not completely implemented!!"));
|
---|
935 |
|
---|
936 | if(!lpThreadInfo || lpThreadInfo->cbSize != sizeof(GUITHREADINFO)) {
|
---|
937 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
938 | return FALSE;
|
---|
939 | }
|
---|
940 | //dwThreadId == 0 -> current thread
|
---|
941 | if(!dwThreadId) dwThreadId = GetCurrentThreadId();
|
---|
942 |
|
---|
943 | lpThreadInfo->flags;
|
---|
944 | lpThreadInfo->hwndActive = GetActiveWindow();
|
---|
945 | if(lpThreadInfo->hwndActive) {
|
---|
946 | if(dwThreadId != GetWindowThreadProcessId(lpThreadInfo->hwndActive, NULL))
|
---|
947 | {//this thread doesn't own the active window (TODO: correct??)
|
---|
948 | lpThreadInfo->hwndActive = 0;
|
---|
949 | }
|
---|
950 | }
|
---|
951 | lpThreadInfo->hwndFocus = GetFocus();
|
---|
952 | lpThreadInfo->hwndCapture = GetCapture();
|
---|
953 | lpThreadInfo->flags = 0; //TODO:
|
---|
954 | lpThreadInfo->hwndMenuOwner = 0; //TODO: Handle to the window that owns any active menus
|
---|
955 | lpThreadInfo->hwndMoveSize = 0; //TODO: Handle to the window in a move or size loop.
|
---|
956 | lpThreadInfo->hwndCaret = 0; //TODO: Handle to the window that is displaying the caret
|
---|
957 | lpThreadInfo->rcCaret.left = 0;
|
---|
958 | lpThreadInfo->rcCaret.top = 0;
|
---|
959 | lpThreadInfo->rcCaret.right = 0;
|
---|
960 | lpThreadInfo->rcCaret.bottom = 0;
|
---|
961 |
|
---|
962 | SetLastError(ERROR_SUCCESS);
|
---|
963 | return TRUE;
|
---|
964 | }
|
---|
965 | //******************************************************************************
|
---|
966 | //******************************************************************************
|
---|
967 | BOOL WIN32API IsZoomed(HWND hwnd)
|
---|
968 | {
|
---|
969 | DWORD style;
|
---|
970 |
|
---|
971 | style = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
972 | dprintf(("USER32: IsZoomed %x returned %d", hwnd, ((style & WS_MAXIMIZE) != 0)));
|
---|
973 |
|
---|
974 | return (style & WS_MAXIMIZE) != 0;
|
---|
975 | }
|
---|
976 | //******************************************************************************
|
---|
977 | //******************************************************************************
|
---|
978 | BOOL WIN32API LockWindowUpdate(HWND hwnd)
|
---|
979 | {
|
---|
980 | return OSLibWinLockWindowUpdate(Win32ToOS2Handle(hwnd));
|
---|
981 | }
|
---|
982 | //******************************************************************************
|
---|
983 | //******************************************************************************
|
---|
984 | BOOL WIN32API GetWindowRect(HWND hwnd, PRECT pRect)
|
---|
985 | {
|
---|
986 | Win32BaseWindow *window;
|
---|
987 |
|
---|
988 | if(pRect == NULL) {
|
---|
989 | dprintf(("GetWindowRect %x invalid parameter!", hwnd));
|
---|
990 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
991 | return FALSE;
|
---|
992 | }
|
---|
993 |
|
---|
994 | if(hwnd == HWND_DESKTOP) {
|
---|
995 | windowDesktop->addRef();
|
---|
996 | window = windowDesktop;
|
---|
997 | }
|
---|
998 | else window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
999 |
|
---|
1000 | if(!window) {
|
---|
1001 | dprintf(("GetWindowRect, window %x not found", hwnd));
|
---|
1002 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1003 | return FALSE;
|
---|
1004 | }
|
---|
1005 | *pRect = *window->getWindowRect();
|
---|
1006 |
|
---|
1007 | //convert from parent coordinates to screen (if necessary)
|
---|
1008 | if(window->getParent()) {
|
---|
1009 | MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
|
---|
1010 | }
|
---|
1011 | RELEASE_WNDOBJ(window);
|
---|
1012 | dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
---|
1013 | return TRUE;
|
---|
1014 | }
|
---|
1015 | //******************************************************************************
|
---|
1016 | //******************************************************************************
|
---|
1017 | INT WIN32API GetWindowTextLengthA(HWND hwnd)
|
---|
1018 | {
|
---|
1019 | Win32BaseWindow *window;
|
---|
1020 |
|
---|
1021 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1022 | if(!window) {
|
---|
1023 | dprintf(("GetWindowTextLengthA, window %x not found", hwnd));
|
---|
1024 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1025 | return 0;
|
---|
1026 | }
|
---|
1027 | dprintf(("GetWindowTextLengthA %x", hwnd));
|
---|
1028 | int ret = window->GetWindowTextLengthA();
|
---|
1029 | RELEASE_WNDOBJ(window);
|
---|
1030 | return ret;
|
---|
1031 | }
|
---|
1032 | //******************************************************************************
|
---|
1033 | //******************************************************************************
|
---|
1034 | int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
|
---|
1035 | {
|
---|
1036 | Win32BaseWindow *window;
|
---|
1037 | int rc;
|
---|
1038 |
|
---|
1039 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1040 | if(!window) {
|
---|
1041 | dprintf(("GetWindowTextA, window %x not found", hwnd));
|
---|
1042 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1043 | return 0;
|
---|
1044 | }
|
---|
1045 | rc = window->GetWindowTextA(lpsz, cch);
|
---|
1046 | dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
|
---|
1047 | RELEASE_WNDOBJ(window);
|
---|
1048 | return rc;
|
---|
1049 | }
|
---|
1050 | //******************************************************************************
|
---|
1051 | //******************************************************************************
|
---|
1052 | int WIN32API GetWindowTextLengthW( HWND hwnd)
|
---|
1053 | {
|
---|
1054 | Win32BaseWindow *window;
|
---|
1055 |
|
---|
1056 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1057 | if(!window) {
|
---|
1058 | dprintf(("GetWindowTextLengthW, window %x not found", hwnd));
|
---|
1059 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1060 | return 0;
|
---|
1061 | }
|
---|
1062 | dprintf(("GetWindowTextLengthW %x", hwnd));
|
---|
1063 | int ret = window->GetWindowTextLengthW();
|
---|
1064 | RELEASE_WNDOBJ(window);
|
---|
1065 | return ret;
|
---|
1066 | }
|
---|
1067 | //******************************************************************************
|
---|
1068 | //******************************************************************************
|
---|
1069 | int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
|
---|
1070 | {
|
---|
1071 | Win32BaseWindow *window;
|
---|
1072 |
|
---|
1073 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1074 | if(!window) {
|
---|
1075 | dprintf(("GetWindowTextW, window %x not found", hwnd));
|
---|
1076 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1077 | return 0;
|
---|
1078 | }
|
---|
1079 | int rc = window->GetWindowTextW(lpsz, cch);
|
---|
1080 | RELEASE_WNDOBJ(window);
|
---|
1081 | dprintf(("GetWindowTextW %x %ls", hwnd, lpsz));
|
---|
1082 | return rc;
|
---|
1083 | }
|
---|
1084 | //******************************************************************************
|
---|
1085 | //******************************************************************************
|
---|
1086 | BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
|
---|
1087 | {
|
---|
1088 | Win32BaseWindow *window;
|
---|
1089 |
|
---|
1090 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1091 | if(!window) {
|
---|
1092 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
---|
1093 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1094 | return 0;
|
---|
1095 | }
|
---|
1096 | dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
|
---|
1097 | BOOL ret = window->SetWindowTextA((LPSTR)lpsz);
|
---|
1098 | RELEASE_WNDOBJ(window);
|
---|
1099 | return ret;
|
---|
1100 | }
|
---|
1101 | //******************************************************************************
|
---|
1102 | //******************************************************************************
|
---|
1103 | BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
|
---|
1104 | {
|
---|
1105 | Win32BaseWindow *window;
|
---|
1106 |
|
---|
1107 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1108 | if(!window) {
|
---|
1109 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
---|
1110 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1111 | return 0;
|
---|
1112 | }
|
---|
1113 | dprintf(("SetWindowTextW %x %ls", hwnd, lpsz));
|
---|
1114 | BOOL ret = window->SetWindowTextW((LPWSTR)lpsz);
|
---|
1115 | RELEASE_WNDOBJ(window);
|
---|
1116 | return ret;
|
---|
1117 | }
|
---|
1118 | /*******************************************************************
|
---|
1119 | * InternalGetWindowText (USER32.326)
|
---|
1120 | */
|
---|
1121 | int WIN32API InternalGetWindowText(HWND hwnd,
|
---|
1122 | LPWSTR lpString,
|
---|
1123 | INT nMaxCount )
|
---|
1124 | {
|
---|
1125 | dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
|
---|
1126 | hwnd, lpString, nMaxCount));
|
---|
1127 |
|
---|
1128 | return GetWindowTextW(hwnd, lpString,nMaxCount);
|
---|
1129 | }
|
---|
1130 | //******************************************************************************
|
---|
1131 | //TODO: Correct?
|
---|
1132 | //******************************************************************************
|
---|
1133 | BOOL WIN32API SetForegroundWindow(HWND hwnd)
|
---|
1134 | {
|
---|
1135 | dprintf((" SetForegroundWindow %x", hwnd));
|
---|
1136 |
|
---|
1137 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
---|
1138 | }
|
---|
1139 | //******************************************************************************
|
---|
1140 | //******************************************************************************
|
---|
1141 | BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
|
---|
1142 | {
|
---|
1143 | HWND hwndWin32 = hwnd;
|
---|
1144 | Win32BaseWindow *window;
|
---|
1145 |
|
---|
1146 | if (!pRect)
|
---|
1147 | {
|
---|
1148 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1149 | return FALSE;
|
---|
1150 | }
|
---|
1151 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1152 | if(!window) {
|
---|
1153 | dprintf(("GetClientRect, window %x not found", hwnd));
|
---|
1154 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1155 | return FALSE;
|
---|
1156 | }
|
---|
1157 | window->getClientRect(pRect);
|
---|
1158 | dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
---|
1159 | RELEASE_WNDOBJ(window);
|
---|
1160 | return TRUE;
|
---|
1161 | }
|
---|
1162 | //******************************************************************************
|
---|
1163 | //******************************************************************************
|
---|
1164 | BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
|
---|
1165 | {
|
---|
1166 | return AdjustWindowRectEx(rect, style, menu, 0);
|
---|
1167 | }
|
---|
1168 | //******************************************************************************
|
---|
1169 | //Calculate window rectangle based on given client rectangle, style, menu and extended style
|
---|
1170 | //******************************************************************************
|
---|
1171 | BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
|
---|
1172 | {
|
---|
1173 | if(style == 0 && menu == FALSE && exStyle == 0) {
|
---|
1174 | dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d) -> no change required", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
|
---|
1175 | return TRUE; //nothing needs to be changed (VERIFIED in NT 4)
|
---|
1176 | }
|
---|
1177 | dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
|
---|
1178 | /* Correct the window style */
|
---|
1179 | if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
|
---|
1180 | style |= WS_CAPTION;
|
---|
1181 |
|
---|
1182 | //SvL: Include WS_POPUP -> otherwise HAS_THINFRAME is true for popup windows
|
---|
1183 | // Also include WS_CHILD -> otherwise HAS_THICKFRAME doesn't work correctly
|
---|
1184 | style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_POPUP);
|
---|
1185 | exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
|
---|
1186 | if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
|
---|
1187 |
|
---|
1188 | //Adjust rect outer (Win32BaseWindow::AdjustRectOuter)
|
---|
1189 | if (HAS_THICKFRAME(style,exStyle))
|
---|
1190 | InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
|
---|
1191 | else
|
---|
1192 | if (HAS_DLGFRAME(style,exStyle))
|
---|
1193 | InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
|
---|
1194 | else
|
---|
1195 | if (HAS_THINFRAME(style))
|
---|
1196 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
1197 |
|
---|
1198 | if ((style & WS_CAPTION) == WS_CAPTION)
|
---|
1199 | {
|
---|
1200 | if (exStyle & WS_EX_TOOLWINDOW)
|
---|
1201 | rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
|
---|
1202 | else
|
---|
1203 | rect->top -= GetSystemMetrics(SM_CYCAPTION);
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 | if (menu)
|
---|
1207 | rect->top -= GetSystemMetrics(SM_CYMENU);
|
---|
1208 |
|
---|
1209 | //Adjust rect inner (Win32BaseWindow::AdjustRectInner)
|
---|
1210 | if(!(style & WS_ICONIC)) {
|
---|
1211 | if (exStyle & WS_EX_CLIENTEDGE)
|
---|
1212 | InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
|
---|
1213 |
|
---|
1214 | if (exStyle & WS_EX_STATICEDGE)
|
---|
1215 | InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
1216 |
|
---|
1217 | //SvL: scrollbars aren't checked *UNLESS* the style includes a border (any border)
|
---|
1218 | // --> VERIFIED IN NT4, SP6 (fixes MFC apps with scrollbars + bar controls)
|
---|
1219 | if(style & (WS_THICKFRAME|WS_BORDER|WS_DLGFRAME)) {
|
---|
1220 | if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
|
---|
1221 | if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
|
---|
1222 | }
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
|
---|
1226 |
|
---|
1227 | return TRUE;
|
---|
1228 | }
|
---|
1229 | //******************************************************************************
|
---|
1230 | /* Coordinate Space and Transformation Functions */
|
---|
1231 | //******************************************************************************
|
---|
1232 | /*******************************************************************
|
---|
1233 | * WINPOS_GetWinOffset
|
---|
1234 | *
|
---|
1235 | * Calculate the offset between the origin of the two windows. Used
|
---|
1236 | * to implement MapWindowPoints.
|
---|
1237 | */
|
---|
1238 | static void WINPOS_GetWinOffset( Win32BaseWindow *wndFrom, Win32BaseWindow *wndTo,
|
---|
1239 | POINT *offset )
|
---|
1240 | {
|
---|
1241 | Win32BaseWindow *window;
|
---|
1242 |
|
---|
1243 | offset->x = offset->y = 0;
|
---|
1244 |
|
---|
1245 | /* Translate source window origin to screen coords */
|
---|
1246 | if(wndFrom != windowDesktop)
|
---|
1247 | {
|
---|
1248 | window = wndFrom;
|
---|
1249 | while(window)
|
---|
1250 | {
|
---|
1251 | offset->x += window->getClientRectPtr()->left + window->getWindowRect()->left;
|
---|
1252 | offset->y += window->getClientRectPtr()->top + window->getWindowRect()->top;
|
---|
1253 | window = window->getParent();
|
---|
1254 | }
|
---|
1255 | }
|
---|
1256 |
|
---|
1257 | /* Translate origin to destination window coords */
|
---|
1258 | if(wndTo != windowDesktop)
|
---|
1259 | {
|
---|
1260 | window = wndTo;
|
---|
1261 | while(window)
|
---|
1262 | {
|
---|
1263 | offset->x -= window->getClientRectPtr()->left + window->getWindowRect()->left;
|
---|
1264 | offset->y -= window->getClientRectPtr()->top + window->getWindowRect()->top;
|
---|
1265 | window = window->getParent();
|
---|
1266 | }
|
---|
1267 | }
|
---|
1268 | }
|
---|
1269 | //******************************************************************************
|
---|
1270 | //******************************************************************************
|
---|
1271 | int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
|
---|
1272 | UINT cPoints)
|
---|
1273 | {
|
---|
1274 | Win32BaseWindow *wndfrom, *wndto;
|
---|
1275 | int retval = 0;
|
---|
1276 | POINT offset;
|
---|
1277 |
|
---|
1278 | SetLastError(0);
|
---|
1279 | if(lpPoints == NULL || cPoints == 0) {
|
---|
1280 | dprintf(("MapWindowPoints error: lpPoints %p, cPoints %d", lpPoints, cPoints));
|
---|
1281 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1282 | return 0;
|
---|
1283 | }
|
---|
1284 | if(hwndTo == hwndFrom)
|
---|
1285 | return 0; //nothing to do
|
---|
1286 |
|
---|
1287 | if(hwndFrom == HWND_DESKTOP)
|
---|
1288 | {
|
---|
1289 | windowDesktop->addRef();
|
---|
1290 | wndfrom = windowDesktop;
|
---|
1291 | }
|
---|
1292 | else {
|
---|
1293 | wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
|
---|
1294 | if(!wndfrom) {
|
---|
1295 | dprintf(("MapWindowPoints, window %x not found", hwndFrom));
|
---|
1296 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1297 | return 0;
|
---|
1298 | }
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | if(hwndTo == HWND_DESKTOP)
|
---|
1302 | {
|
---|
1303 | windowDesktop->addRef();
|
---|
1304 | wndto = windowDesktop;
|
---|
1305 | }
|
---|
1306 | else {
|
---|
1307 | wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
|
---|
1308 | if(!wndto) {
|
---|
1309 | dprintf(("MapWindowPoints, window %x not found", hwndTo));
|
---|
1310 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1311 | return 0;
|
---|
1312 | }
|
---|
1313 | }
|
---|
1314 |
|
---|
1315 | dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
|
---|
1316 | WINPOS_GetWinOffset(wndfrom, wndto, &offset);
|
---|
1317 |
|
---|
1318 | RELEASE_WNDOBJ(wndto);
|
---|
1319 | RELEASE_WNDOBJ(wndfrom);
|
---|
1320 | for(int i=0;i<cPoints;i++)
|
---|
1321 | {
|
---|
1322 | lpPoints[i].x += offset.x;
|
---|
1323 | lpPoints[i].y += offset.y;
|
---|
1324 | }
|
---|
1325 | retval = ((LONG)offset.y << 16) | offset.x;
|
---|
1326 | return retval;
|
---|
1327 | }
|
---|
1328 | //******************************************************************************
|
---|
1329 | //******************************************************************************
|
---|
1330 | BOOL WIN32API ScreenToClient(HWND hwnd, LPPOINT pt)
|
---|
1331 | {
|
---|
1332 | PRECT rcl;
|
---|
1333 | BOOL rc;
|
---|
1334 |
|
---|
1335 | if(hwnd == HWND_DESKTOP) {
|
---|
1336 | return (TRUE); //nothing to do
|
---|
1337 | }
|
---|
1338 | if (!IsWindow(hwnd)) {
|
---|
1339 | dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
|
---|
1340 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1341 | return FALSE;
|
---|
1342 | }
|
---|
1343 | SetLastError(0);
|
---|
1344 | #ifdef DEBUG
|
---|
1345 | POINT tmp = *pt;
|
---|
1346 | #endif
|
---|
1347 | MapWindowPoints(0, hwnd, pt, 1);
|
---|
1348 | dprintf2(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
|
---|
1349 | return TRUE;
|
---|
1350 | }
|
---|
1351 | //******************************************************************************
|
---|
1352 | //******************************************************************************
|
---|
1353 | HWND WIN32API GetDesktopWindow(void)
|
---|
1354 | {
|
---|
1355 | HWND hDesktopWindow = windowDesktop->getWindowHandle();
|
---|
1356 | dprintf2(("USER32: GetDesktopWindow, returned %x\n", hDesktopWindow));
|
---|
1357 | return hDesktopWindow;
|
---|
1358 | }
|
---|
1359 | //******************************************************************************
|
---|
1360 | //******************************************************************************
|
---|
1361 | HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
|
---|
1362 | {
|
---|
1363 | return FindWindowExA( NULL, NULL, lpszClass, lpszWindow );
|
---|
1364 | }
|
---|
1365 | //******************************************************************************
|
---|
1366 | //******************************************************************************
|
---|
1367 | HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
|
---|
1368 | {
|
---|
1369 | return FindWindowExW( NULL, NULL, lpClassName, lpWindowName );
|
---|
1370 | }
|
---|
1371 | //******************************************************************************
|
---|
1372 | //******************************************************************************
|
---|
1373 | HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
|
---|
1374 | {
|
---|
1375 | ATOM atom = 0;
|
---|
1376 |
|
---|
1377 | if (lpszClass)
|
---|
1378 | {
|
---|
1379 | /* If the atom doesn't exist, then no class */
|
---|
1380 | /* with this name exists either. */
|
---|
1381 | if (!(atom = GlobalFindAtomA( lpszClass )))
|
---|
1382 | {
|
---|
1383 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
|
---|
1384 | return 0;
|
---|
1385 | }
|
---|
1386 | }
|
---|
1387 | return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, (LPSTR)lpszWindow);
|
---|
1388 | }
|
---|
1389 | /*****************************************************************************
|
---|
1390 | * Name : HWND WIN32API FindWindowExW
|
---|
1391 | * Purpose : The FindWindowEx function retrieves the handle of a window whose
|
---|
1392 | * class name and window name match the specified strings. The
|
---|
1393 | * function searches child windows, beginning with the one following
|
---|
1394 | * the given child window.
|
---|
1395 | * Parameters: HWND hwndParent handle of parent window
|
---|
1396 | * HWND hwndChildAfter handle of a child window
|
---|
1397 | * LPCTSTR lpszClass address of class name
|
---|
1398 | * LPCTSTR lpszWindow address of window name
|
---|
1399 | * Variables :
|
---|
1400 | * Result : If the function succeeds, the return value is the handle of the
|
---|
1401 | * window that has the specified class and window names.
|
---|
1402 | * If the function fails, the return value is NULL. To get extended
|
---|
1403 | * error information, call GetLastError.
|
---|
1404 | * Remark :
|
---|
1405 | *
|
---|
1406 | *****************************************************************************/
|
---|
1407 |
|
---|
1408 | HWND WIN32API FindWindowExW(HWND hwndParent,
|
---|
1409 | HWND hwndChildAfter,
|
---|
1410 | LPCWSTR lpszClass,
|
---|
1411 | LPCWSTR lpszWindow)
|
---|
1412 | {
|
---|
1413 | ATOM atom = 0;
|
---|
1414 | char *buffer;
|
---|
1415 | HWND hwnd;
|
---|
1416 |
|
---|
1417 | if (lpszClass)
|
---|
1418 | {
|
---|
1419 | /* If the atom doesn't exist, then no class */
|
---|
1420 | /* with this name exists either. */
|
---|
1421 | if (!(atom = GlobalFindAtomW( lpszClass )))
|
---|
1422 | {
|
---|
1423 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
|
---|
1424 | return 0;
|
---|
1425 | }
|
---|
1426 | }
|
---|
1427 | buffer = HEAP_strdupWtoA( GetProcessHeap(), 0, lpszWindow );
|
---|
1428 | hwnd = Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, buffer);
|
---|
1429 | HeapFree( GetProcessHeap(), 0, buffer );
|
---|
1430 | return hwnd;
|
---|
1431 | }
|
---|
1432 | //******************************************************************************
|
---|
1433 | //******************************************************************************
|
---|
1434 | BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
|
---|
1435 | {
|
---|
1436 | dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
|
---|
1437 | // return OSLibWinFlashWindow(Win32ToOS2Handle(hwnd), fFlash);
|
---|
1438 | return 1;
|
---|
1439 | }
|
---|
1440 | //******************************************************************************
|
---|
1441 | //******************************************************************************
|
---|
1442 | BOOL WIN32API FlashWindowEx( PFLASHWINFO pfwi)
|
---|
1443 | {
|
---|
1444 | dprintf(("FlashWindow %p %d\n", pfwi));
|
---|
1445 | return 1;
|
---|
1446 | }
|
---|
1447 | //******************************************************************************
|
---|
1448 | //******************************************************************************
|
---|
1449 | BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
|
---|
1450 | BOOL repaint )
|
---|
1451 | {
|
---|
1452 | int flags = SWP_NOZORDER | SWP_NOACTIVATE;
|
---|
1453 |
|
---|
1454 | if (!repaint) flags |= SWP_NOREDRAW;
|
---|
1455 | dprintf(("MoveWindow: %x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
|
---|
1456 |
|
---|
1457 | return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
|
---|
1458 | }
|
---|
1459 | //******************************************************************************
|
---|
1460 | //******************************************************************************
|
---|
1461 | BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
|
---|
1462 | {
|
---|
1463 | PRECT rcl;
|
---|
1464 |
|
---|
1465 | if(hwnd == HWND_DESKTOP) {
|
---|
1466 | return(TRUE); //nothing to do
|
---|
1467 | }
|
---|
1468 | if(!IsWindow(hwnd)) {
|
---|
1469 | dprintf(("warning: ClientToScreen window %x not found!", hwnd));
|
---|
1470 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1471 | return (FALSE);
|
---|
1472 | }
|
---|
1473 | #ifdef DEBUG
|
---|
1474 | POINT tmp = *pt;
|
---|
1475 | #endif
|
---|
1476 | MapWindowPoints(hwnd, 0, pt, 1);
|
---|
1477 | dprintf2(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
|
---|
1478 |
|
---|
1479 | return TRUE;
|
---|
1480 | }
|
---|
1481 | //******************************************************************************
|
---|
1482 | //Note: count 0 is a legal parameter (verified in NT4)
|
---|
1483 | //******************************************************************************
|
---|
1484 | HDWP WIN32API BeginDeferWindowPos(int count)
|
---|
1485 | {
|
---|
1486 | HDWP handle;
|
---|
1487 | DWP *pDWP;
|
---|
1488 |
|
---|
1489 | if (count < 0)
|
---|
1490 | {
|
---|
1491 | dprintf(("USER32: BeginDeferWindowPos invalid param %d", count));
|
---|
1492 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1493 | return 0;
|
---|
1494 | }
|
---|
1495 | dprintf(("USER32: BeginDeferWindowPos %d", count));
|
---|
1496 | if(count == 0)
|
---|
1497 | count = 8; // change to any non-zero value
|
---|
1498 |
|
---|
1499 | handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS));
|
---|
1500 | if (!handle)
|
---|
1501 | return 0;
|
---|
1502 |
|
---|
1503 | pDWP = (DWP *) handle;
|
---|
1504 | pDWP->actualCount = 0;
|
---|
1505 | pDWP->suggestedCount = count;
|
---|
1506 | pDWP->valid = TRUE;
|
---|
1507 | pDWP->wMagic = DWP_MAGIC;
|
---|
1508 | pDWP->hwndParent = 0;
|
---|
1509 | return handle;
|
---|
1510 | }
|
---|
1511 | /***********************************************************************
|
---|
1512 | * DeferWindowPos (USER32.128)
|
---|
1513 | *
|
---|
1514 | * TODO: SvL: Does this need to be thread safe?
|
---|
1515 | *
|
---|
1516 | */
|
---|
1517 | HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
|
---|
1518 | INT x, INT y, INT cx, INT cy,
|
---|
1519 | UINT flags )
|
---|
1520 | {
|
---|
1521 | DWP *pDWP;
|
---|
1522 | int i;
|
---|
1523 | HDWP newhdwp = hdwp,retvalue;
|
---|
1524 |
|
---|
1525 | pDWP = (DWP *)hdwp;
|
---|
1526 | if (!pDWP) {
|
---|
1527 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1528 | return 0;
|
---|
1529 | }
|
---|
1530 |
|
---|
1531 | if (hwnd == GetDesktopWindow())
|
---|
1532 | return 0;
|
---|
1533 |
|
---|
1534 | if(!IsWindow(hwnd)) {
|
---|
1535 | dprintf(("DeferWindowPos, window %x not found", hwnd));
|
---|
1536 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1537 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
---|
1538 | return 0;
|
---|
1539 | }
|
---|
1540 |
|
---|
1541 | dprintf(("USER32: DeferWindowPos hdwp %x hwnd %x hwndAfter %x (%d,%d)(%d,%d) %x", hdwp, hwnd, hwndAfter,
|
---|
1542 | x, y, cx, cy, flags));
|
---|
1543 |
|
---|
1544 | /* Numega Bounds Checker Demo dislikes the following code.
|
---|
1545 | In fact, I've not been able to find any "same parent" requirement in any docu
|
---|
1546 | [AM 980509]
|
---|
1547 | */
|
---|
1548 | #if 0
|
---|
1549 | /* All the windows of a DeferWindowPos() must have the same parent */
|
---|
1550 | parent = pWnd->parent->hwndSelf;
|
---|
1551 | if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
|
---|
1552 | else if (parent != pDWP->hwndParent)
|
---|
1553 | {
|
---|
1554 | USER_HEAP_FREE( hdwp );
|
---|
1555 | retvalue = 0;
|
---|
1556 | goto END;
|
---|
1557 | }
|
---|
1558 | #endif
|
---|
1559 |
|
---|
1560 | for (i = 0; i < pDWP->actualCount; i++)
|
---|
1561 | {
|
---|
1562 | if (pDWP->winPos[i].hwnd == hwnd)
|
---|
1563 | {
|
---|
1564 | /* Merge with the other changes */
|
---|
1565 | if (!(flags & SWP_NOZORDER))
|
---|
1566 | {
|
---|
1567 | pDWP->winPos[i].hwndInsertAfter = hwndAfter;
|
---|
1568 | }
|
---|
1569 | if (!(flags & SWP_NOMOVE))
|
---|
1570 | {
|
---|
1571 | pDWP->winPos[i].x = x;
|
---|
1572 | pDWP->winPos[i].y = y;
|
---|
1573 | }
|
---|
1574 | if (!(flags & SWP_NOSIZE))
|
---|
1575 | {
|
---|
1576 | pDWP->winPos[i].cx = cx;
|
---|
1577 | pDWP->winPos[i].cy = cy;
|
---|
1578 | }
|
---|
1579 | pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
|
---|
1580 | SWP_NOZORDER | SWP_NOREDRAW |
|
---|
1581 | SWP_NOACTIVATE | SWP_NOCOPYBITS|
|
---|
1582 | SWP_NOOWNERZORDER);
|
---|
1583 | pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
|
---|
1584 | SWP_FRAMECHANGED);
|
---|
1585 | retvalue = hdwp;
|
---|
1586 | goto END;
|
---|
1587 | }
|
---|
1588 | }
|
---|
1589 | if (pDWP->actualCount >= pDWP->suggestedCount)
|
---|
1590 | {
|
---|
1591 | //DWP structure already contains WINDOWPOS, allocated with (count-1)
|
---|
1592 | //in BeginDeferWindowPos; pDWP->suggestedCount alloc increases it by one
|
---|
1593 | newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
|
---|
1594 | sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
|
---|
1595 | if (!newhdwp)
|
---|
1596 | {
|
---|
1597 | retvalue = 0;
|
---|
1598 | goto END;
|
---|
1599 | }
|
---|
1600 | pDWP = (DWP *) newhdwp;
|
---|
1601 | pDWP->suggestedCount++;
|
---|
1602 | }
|
---|
1603 | pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
|
---|
1604 | pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
|
---|
1605 | pDWP->winPos[pDWP->actualCount].x = x;
|
---|
1606 | pDWP->winPos[pDWP->actualCount].y = y;
|
---|
1607 | pDWP->winPos[pDWP->actualCount].cx = cx;
|
---|
1608 | pDWP->winPos[pDWP->actualCount].cy = cy;
|
---|
1609 | pDWP->winPos[pDWP->actualCount].flags = flags;
|
---|
1610 | pDWP->actualCount++;
|
---|
1611 | retvalue = newhdwp;
|
---|
1612 | END:
|
---|
1613 | return retvalue;
|
---|
1614 | }
|
---|
1615 | //******************************************************************************
|
---|
1616 | //******************************************************************************
|
---|
1617 | BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
|
---|
1618 | {
|
---|
1619 | DWP *pDWP;
|
---|
1620 | WINDOWPOS *winpos;
|
---|
1621 | BOOL res = TRUE;
|
---|
1622 | int i;
|
---|
1623 |
|
---|
1624 | pDWP = (DWP *) hdwp;
|
---|
1625 | if (!pDWP) {
|
---|
1626 | dprintf(("**EndDeferWindowPos invalid parameter\n"));
|
---|
1627 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1628 | return FALSE;
|
---|
1629 | }
|
---|
1630 | dprintf(("**EndDeferWindowPos for %d windows", pDWP->actualCount));
|
---|
1631 | for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
|
---|
1632 | {
|
---|
1633 | dprintf(("**EndDeferWindowPos %x (%d,%d) (%d,%d) %x", winpos->hwnd, winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags));
|
---|
1634 | if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
|
---|
1635 | winpos->x, winpos->y, winpos->cx,
|
---|
1636 | winpos->cy, winpos->flags )))
|
---|
1637 | break;
|
---|
1638 | }
|
---|
1639 | dprintf(("**EndDeferWindowPos DONE"));
|
---|
1640 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
---|
1641 | return res;
|
---|
1642 | }
|
---|
1643 | //******************************************************************************
|
---|
1644 | //******************************************************************************
|
---|
1645 | HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
|
---|
1646 | {
|
---|
1647 | dprintf(("USER32: ChildWindowFromPoint\n"));
|
---|
1648 | return ChildWindowFromPointEx(hwnd, pt, 0);
|
---|
1649 | }
|
---|
1650 | /*****************************************************************************
|
---|
1651 | * Name : HWND WIN32API ChildWindowFromPointEx
|
---|
1652 | * Purpose : pt: client coordinates
|
---|
1653 | * Parameters:
|
---|
1654 | * Variables :
|
---|
1655 | * Result : If the function succeeds, the return value is the window handle.
|
---|
1656 | * If the function fails, the return value is zero
|
---|
1657 | * Remark :
|
---|
1658 | * Status : COMPLETELY IMPLEMENTED AND TESTED
|
---|
1659 | *
|
---|
1660 | * Author : Rene Pronk [Sun, 1999/08/08 23:30]
|
---|
1661 | *****************************************************************************/
|
---|
1662 | HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
|
---|
1663 | {
|
---|
1664 | RECT rect;
|
---|
1665 | HWND hWnd;
|
---|
1666 |
|
---|
1667 | dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
|
---|
1668 | hwndParent, pt, uFlags));
|
---|
1669 |
|
---|
1670 | if (GetWindowRect (hwndParent, &rect) == 0) {
|
---|
1671 | // oops, invalid handle
|
---|
1672 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1673 | return NULL;
|
---|
1674 | }
|
---|
1675 |
|
---|
1676 | ClientToScreen(hwndParent, &pt);
|
---|
1677 | if (PtInRect (&rect, pt) == 0) {
|
---|
1678 | // point is outside window
|
---|
1679 | return NULL;
|
---|
1680 | }
|
---|
1681 |
|
---|
1682 | // get first child
|
---|
1683 | hWnd = GetWindow (hwndParent, GW_CHILD);
|
---|
1684 |
|
---|
1685 | while (hWnd != NULL)
|
---|
1686 | {
|
---|
1687 | // do I need to skip this window?
|
---|
1688 | if (((uFlags & CWP_SKIPINVISIBLE) &&
|
---|
1689 | (IsWindowVisible (hWnd) == FALSE)) ||
|
---|
1690 | ((uFlags & CWP_SKIPDISABLED) &&
|
---|
1691 | (IsWindowEnabled (hWnd) == FALSE)) ||
|
---|
1692 | ((uFlags & CWP_SKIPTRANSPARENT) &&
|
---|
1693 | (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
|
---|
1694 | {
|
---|
1695 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
---|
1696 | continue;
|
---|
1697 | }
|
---|
1698 |
|
---|
1699 | // is the point in this window's rect?
|
---|
1700 | GetWindowRect (hWnd, &rect);
|
---|
1701 | if (PtInRect (&rect,pt) == FALSE) {
|
---|
1702 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
---|
1703 | continue;
|
---|
1704 | }
|
---|
1705 |
|
---|
1706 | dprintf(("ChildWindowFromPointEx returned %x", hWnd));
|
---|
1707 | // found it!
|
---|
1708 | return hWnd;
|
---|
1709 | }
|
---|
1710 | // the point is in the parentwindow but the parentwindow has no child
|
---|
1711 | // at this coordinate
|
---|
1712 | dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
|
---|
1713 | return hwndParent;
|
---|
1714 | }
|
---|
1715 | //******************************************************************************
|
---|
1716 | //******************************************************************************
|
---|
1717 | BOOL WIN32API CloseWindow(HWND hwnd)
|
---|
1718 | {
|
---|
1719 | Win32BaseWindow *window;
|
---|
1720 |
|
---|
1721 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1722 | if(!window) {
|
---|
1723 | dprintf(("CloseWindow, window %x not found", hwnd));
|
---|
1724 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1725 | return 0;
|
---|
1726 | }
|
---|
1727 | dprintf(("CloseWindow %x\n", hwnd));
|
---|
1728 | BOOL ret = window->CloseWindow();
|
---|
1729 | RELEASE_WNDOBJ(window);
|
---|
1730 | return ret;
|
---|
1731 | }
|
---|
1732 | //******************************************************************************
|
---|
1733 | //******************************************************************************
|
---|
1734 | static BOOL IsPointInWindow(HWND hwnd, POINT point)
|
---|
1735 | {
|
---|
1736 | RECT rectWindow;
|
---|
1737 | DWORD hittest, dwStyle, dwExStyle;
|
---|
1738 |
|
---|
1739 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
1740 | dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
|
---|
1741 |
|
---|
1742 | GetWindowRect(hwnd, &rectWindow);
|
---|
1743 |
|
---|
1744 | /* If point is in window, and window is visible, and it */
|
---|
1745 | /* is enabled (or it's a top-level window), then explore */
|
---|
1746 | /* its children. Otherwise, go to the next window. */
|
---|
1747 |
|
---|
1748 | if( (dwStyle & WS_VISIBLE) &&
|
---|
1749 | ((dwExStyle & (WS_EX_LAYERED | WS_EX_TRANSPARENT)) != (WS_EX_LAYERED | WS_EX_TRANSPARENT)) &&
|
---|
1750 | (!(dwStyle & WS_DISABLED) || ((dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) &&
|
---|
1751 | ((point.x >= rectWindow.left) && (point.x < rectWindow.right) &&
|
---|
1752 | (point.y >= rectWindow.top) && (point.y < rectWindow.bottom))
|
---|
1753 | #if 1
|
---|
1754 | )
|
---|
1755 | #else
|
---|
1756 | &&
|
---|
1757 | (wndPtr->hrgnWnd ? PtInRegion(wndPtr->hrgnWnd, 1))
|
---|
1758 | #endif
|
---|
1759 | {
|
---|
1760 | DWORD dwThreadId = GetCurrentThreadId();
|
---|
1761 |
|
---|
1762 | //Don't send WM_NCHITTEST if this window doesn't belong to the current thread
|
---|
1763 | if(dwThreadId != GetWindowThreadProcessId(hwnd, NULL))
|
---|
1764 | {
|
---|
1765 | return TRUE;
|
---|
1766 | }
|
---|
1767 | hittest = SendMessageA(hwnd, WM_NCHITTEST, 0, MAKELONG(point.x, point.y));
|
---|
1768 | if(hittest != HTTRANSPARENT) {
|
---|
1769 | return TRUE;
|
---|
1770 | }
|
---|
1771 | }
|
---|
1772 | return FALSE;
|
---|
1773 | }
|
---|
1774 | //******************************************************************************
|
---|
1775 | //TODO: Does this return handles of hidden or disabled windows?
|
---|
1776 | //******************************************************************************
|
---|
1777 | HWND WIN32API WindowFromPoint( POINT point)
|
---|
1778 | {
|
---|
1779 | HWND hwndOS2, hwnd;
|
---|
1780 | POINT wPoint;
|
---|
1781 |
|
---|
1782 | wPoint.x = point.x;
|
---|
1783 | wPoint.y = mapScreenY(point.y);
|
---|
1784 |
|
---|
1785 | hwndOS2 = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&wPoint);
|
---|
1786 | if(hwndOS2)
|
---|
1787 | {
|
---|
1788 | hwnd = OS2ToWin32Handle(hwndOS2);
|
---|
1789 | while(hwnd)
|
---|
1790 | {
|
---|
1791 | if(IsPointInWindow(hwnd, point)) {
|
---|
1792 | dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwnd));
|
---|
1793 | return hwnd;
|
---|
1794 | }
|
---|
1795 | #if 0
|
---|
1796 | //TODO: breaks a lot of things
|
---|
1797 | hwnd = GetWindow(hwnd, GW_HWNDNEXT);
|
---|
1798 | #else
|
---|
1799 | //try siblings
|
---|
1800 | HWND hwndSibling;
|
---|
1801 | HWND hwndParent = GetParent(hwnd);
|
---|
1802 |
|
---|
1803 | if(hwndParent) {
|
---|
1804 | hwndSibling = GetWindow(hwndParent, GW_CHILD);
|
---|
1805 | while(hwndSibling) {
|
---|
1806 | if(hwndSibling != hwnd) {
|
---|
1807 | if(IsPointInWindow(hwndSibling, point)) {
|
---|
1808 | dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwndSibling));
|
---|
1809 | return hwndSibling;
|
---|
1810 | }
|
---|
1811 | }
|
---|
1812 | hwndSibling = GetWindow(hwndSibling, GW_HWNDNEXT);
|
---|
1813 | }
|
---|
1814 | }
|
---|
1815 | hwnd = hwndParent;
|
---|
1816 | #endif
|
---|
1817 | }
|
---|
1818 | }
|
---|
1819 | dprintf(("WindowFromPoint (%d,%d) %x->1\n", point.x, point.y, hwndOS2));
|
---|
1820 | return windowDesktop->getWindowHandle();
|
---|
1821 | }
|
---|
1822 | //******************************************************************************
|
---|
1823 | //******************************************************************************
|
---|
1824 | BOOL WIN32API IsWindowUnicode(HWND hwnd)
|
---|
1825 | {
|
---|
1826 | Win32BaseWindow *window;
|
---|
1827 |
|
---|
1828 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1829 | if(!window) {
|
---|
1830 | dprintf(("IsWindowUnicode, window %x not found", hwnd));
|
---|
1831 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1832 | return 0;
|
---|
1833 | }
|
---|
1834 | BOOL ret = window->IsWindowUnicode();
|
---|
1835 | RELEASE_WNDOBJ(window);
|
---|
1836 | return ret;
|
---|
1837 | }
|
---|
1838 | /***********************************************************************
|
---|
1839 | * SwitchToThisWindow (USER32.539)
|
---|
1840 | */
|
---|
1841 | VOID WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore )
|
---|
1842 | {
|
---|
1843 | ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
|
---|
1844 | }
|
---|
1845 | //******************************************************************************
|
---|
1846 | //******************************************************************************
|
---|
1847 | BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1848 | {
|
---|
1849 | return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
|
---|
1850 | }
|
---|
1851 | //******************************************************************************
|
---|
1852 | //******************************************************************************
|
---|
1853 | BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1854 | {
|
---|
1855 | Win32BaseWindow *window;
|
---|
1856 | BOOL ret = TRUE;
|
---|
1857 | ULONG henum;
|
---|
1858 | HWND hwndNext;
|
---|
1859 |
|
---|
1860 | if(lpfn == NULL) {
|
---|
1861 | dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
|
---|
1862 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1863 | return FALSE;
|
---|
1864 | }
|
---|
1865 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1866 | if(!window) {
|
---|
1867 | dprintf(("EnumChildWindows, window %x not found", hwnd));
|
---|
1868 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1869 | return FALSE;
|
---|
1870 | }
|
---|
1871 | ret = window->EnumChildWindows(lpfn, lParam);
|
---|
1872 | RELEASE_WNDOBJ(window);
|
---|
1873 | return ret;
|
---|
1874 | }
|
---|
1875 | //******************************************************************************
|
---|
1876 | //******************************************************************************
|
---|
1877 | BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1878 | {
|
---|
1879 | return windowDesktop->EnumWindows(lpfn, lParam);
|
---|
1880 | }
|
---|
1881 | //******************************************************************************
|
---|
1882 | //******************************************************************************
|
---|
1883 | UINT WIN32API ArrangeIconicWindows( HWND parent)
|
---|
1884 | {
|
---|
1885 | RECT rectParent;
|
---|
1886 | HWND hwndChild;
|
---|
1887 | INT x, y, xspacing, yspacing;
|
---|
1888 |
|
---|
1889 | dprintf(("USER32: ArrangeIconicWindows %x", parent));
|
---|
1890 | dprintf(("USER32: TODO: icon title!!"));
|
---|
1891 |
|
---|
1892 | GetClientRect(parent, &rectParent);
|
---|
1893 | x = rectParent.left;
|
---|
1894 | y = rectParent.bottom;
|
---|
1895 | xspacing = GetSystemMetrics(SM_CXICONSPACING);
|
---|
1896 | yspacing = GetSystemMetrics(SM_CYICONSPACING);
|
---|
1897 |
|
---|
1898 | hwndChild = GetWindow( parent, GW_CHILD );
|
---|
1899 | while (hwndChild)
|
---|
1900 | {
|
---|
1901 | if( IsIconic( hwndChild ) )
|
---|
1902 | {
|
---|
1903 | // WND *wndPtr = WIN_FindWndPtr(hwndChild);
|
---|
1904 |
|
---|
1905 | // WINPOS_ShowIconTitle( wndPtr, FALSE );
|
---|
1906 |
|
---|
1907 | SetWindowPos( hwndChild, 0, x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2,
|
---|
1908 | y - yspacing - GetSystemMetrics(SM_CYICON)/2, 0, 0,
|
---|
1909 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
|
---|
1910 | // if( IsWindow(hwndChild) )
|
---|
1911 | // WINPOS_ShowIconTitle(wndPtr , TRUE );
|
---|
1912 | // WIN_ReleaseWndPtr(wndPtr);
|
---|
1913 |
|
---|
1914 | if (x <= rectParent.right - xspacing) x += xspacing;
|
---|
1915 | else
|
---|
1916 | {
|
---|
1917 | x = rectParent.left;
|
---|
1918 | y -= yspacing;
|
---|
1919 | }
|
---|
1920 | }
|
---|
1921 | hwndChild = GetWindow( hwndChild, GW_HWNDNEXT );
|
---|
1922 | }
|
---|
1923 | return yspacing;
|
---|
1924 | }
|
---|
1925 | //******************************************************************************
|
---|
1926 | //restores iconized window to previous size/position
|
---|
1927 | //******************************************************************************
|
---|
1928 | BOOL WIN32API OpenIcon(HWND hwnd)
|
---|
1929 | {
|
---|
1930 | dprintf(("USER32: OpenIcon %x", hwnd));
|
---|
1931 |
|
---|
1932 | if(!IsIconic(hwnd))
|
---|
1933 | return FALSE;
|
---|
1934 | ShowWindow(hwnd, SW_SHOWNORMAL);
|
---|
1935 | return TRUE;
|
---|
1936 | }
|
---|
1937 | //******************************************************************************
|
---|
1938 | //SDK: Windows can only be shown with ShowOwnedPopups if they were previously
|
---|
1939 | // hidden with the same api
|
---|
1940 | //TODO: -> needs testing
|
---|
1941 | //******************************************************************************
|
---|
1942 | BOOL WIN32API ShowOwnedPopups(HWND hwndOwner, BOOL fShow)
|
---|
1943 | {
|
---|
1944 | Win32BaseWindow *window, *owner;
|
---|
1945 | HWND hwnd;
|
---|
1946 |
|
---|
1947 | owner = Win32BaseWindow::GetWindowFromHandle(hwndOwner);
|
---|
1948 | if(!owner) {
|
---|
1949 | dprintf(("ShowOwnedPopups, window %x not found", hwndOwner));
|
---|
1950 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1951 | return FALSE;
|
---|
1952 | }
|
---|
1953 | dprintf(("USER32: ShowOwnedPopups %x %d", hwndOwner, fShow));
|
---|
1954 |
|
---|
1955 | hwnd = GetWindow(GetDesktopWindow(), GW_CHILD);
|
---|
1956 | while(hwnd) {
|
---|
1957 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1958 | if(window) {
|
---|
1959 | if(window == owner && (window->getStyle() & WS_POPUP))
|
---|
1960 | {
|
---|
1961 | if(fShow) {
|
---|
1962 | if(window->getFlags() & WIN_NEEDS_SHOW_OWNEDPOPUP)
|
---|
1963 | {
|
---|
1964 | /*
|
---|
1965 | * In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING,
|
---|
1966 | * regardless of the state of the owner
|
---|
1967 | */
|
---|
1968 | SendMessageA(hwnd, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
|
---|
1969 | window->setFlags(window->getFlags() & ~WIN_NEEDS_SHOW_OWNEDPOPUP);
|
---|
1970 | }
|
---|
1971 | }
|
---|
1972 | else
|
---|
1973 | {
|
---|
1974 | if(IsWindowVisible(hwnd))
|
---|
1975 | {
|
---|
1976 | /*
|
---|
1977 | * In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING,
|
---|
1978 | * regardless of the state of the owner
|
---|
1979 | */
|
---|
1980 | SendMessageA(hwnd, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
|
---|
1981 | window->setFlags(window->getFlags() | WIN_NEEDS_SHOW_OWNEDPOPUP);
|
---|
1982 | }
|
---|
1983 | }
|
---|
1984 | }
|
---|
1985 | RELEASE_WNDOBJ(window);
|
---|
1986 | }
|
---|
1987 | else dprintf(("WARNING: window %x is not valid", hwnd));
|
---|
1988 |
|
---|
1989 | hwnd = GetWindow(hwnd, GW_HWNDNEXT);
|
---|
1990 | }
|
---|
1991 | RELEASE_WNDOBJ(owner);
|
---|
1992 | return TRUE;
|
---|
1993 | }
|
---|
1994 | //******************************************************************************
|
---|
1995 | //******************************************************************************
|
---|
1996 | HWND WIN32API GetForegroundWindow()
|
---|
1997 | {
|
---|
1998 | HWND hwnd;
|
---|
1999 |
|
---|
2000 | hwnd = OS2ToWin32Handle(OSLibWinQueryActiveWindow());
|
---|
2001 | return hwnd;
|
---|
2002 | }
|
---|
2003 | //******************************************************************************
|
---|
2004 |
|
---|
2005 | /******************************************************************************
|
---|
2006 | * The return value identifies the most recently active pop-up window.
|
---|
2007 | * The return value is the same as the hWnd parameter, if any of the
|
---|
2008 | * following conditions are met:
|
---|
2009 | *
|
---|
2010 | * - The window identified by hWnd was most recently active.
|
---|
2011 | * - The window identified by hWnd does not own any pop-up windows.
|
---|
2012 | * - The window identified by hWnd is not a top-level window or it is
|
---|
2013 | * owned by another window.
|
---|
2014 | */
|
---|
2015 | HWND WIN32API GetLastActivePopup(HWND hWnd)
|
---|
2016 | {
|
---|
2017 | Win32BaseWindow *owner;
|
---|
2018 |
|
---|
2019 | owner = Win32BaseWindow::GetWindowFromHandle(hWnd);
|
---|
2020 | if(!owner)
|
---|
2021 | {
|
---|
2022 | dprintf(("GetLastActivePopup, window %x not found", hWnd));
|
---|
2023 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2024 | return hWnd;
|
---|
2025 | }
|
---|
2026 |
|
---|
2027 | HWND hwndRetVal = owner->getLastActive();
|
---|
2028 | if (!IsWindow( hwndRetVal ))
|
---|
2029 | hwndRetVal = owner->getWindowHandle();
|
---|
2030 |
|
---|
2031 | RELEASE_WNDOBJ(owner);
|
---|
2032 |
|
---|
2033 | return hwndRetVal;
|
---|
2034 | }
|
---|
2035 | //******************************************************************************
|
---|
2036 | //******************************************************************************
|
---|
2037 | DWORD WIN32API GetWindowThreadProcessId(HWND hwnd, PDWORD lpdwProcessId)
|
---|
2038 | {
|
---|
2039 | Win32BaseWindow *window;
|
---|
2040 | DWORD dwThreadId;
|
---|
2041 |
|
---|
2042 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2043 | if(!window) {
|
---|
2044 | dprintf(("GetWindowThreadProcessId, window %x not found", hwnd));
|
---|
2045 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2046 | return 0;
|
---|
2047 | }
|
---|
2048 | dwThreadId = window->getThreadId();
|
---|
2049 | if(lpdwProcessId) {
|
---|
2050 | *lpdwProcessId = window->getProcessId();
|
---|
2051 | }
|
---|
2052 | RELEASE_WNDOBJ(window);
|
---|
2053 |
|
---|
2054 | return dwThreadId;
|
---|
2055 | }
|
---|
2056 | //******************************************************************************
|
---|
2057 | //******************************************************************************
|
---|
2058 | DWORD WIN32API GetWindowContextHelpId(HWND hwnd)
|
---|
2059 | {
|
---|
2060 | Win32BaseWindow *window;
|
---|
2061 |
|
---|
2062 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2063 | if(!window) {
|
---|
2064 | dprintf(("GetWindowContextHelpId, window %x not found", hwnd));
|
---|
2065 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2066 | return 0;
|
---|
2067 | }
|
---|
2068 | dprintf(("GetWindowContextHelpId %x", hwnd));
|
---|
2069 | DWORD ret = window->getWindowContextHelpId();
|
---|
2070 | RELEASE_WNDOBJ(window);
|
---|
2071 | return ret;
|
---|
2072 | }
|
---|
2073 | //******************************************************************************
|
---|
2074 | //******************************************************************************
|
---|
2075 | BOOL WIN32API SetWindowContextHelpId(HWND hwnd, DWORD dwContextHelpId)
|
---|
2076 | {
|
---|
2077 | Win32BaseWindow *window;
|
---|
2078 |
|
---|
2079 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2080 | if(!window) {
|
---|
2081 | dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
|
---|
2082 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2083 | return 0;
|
---|
2084 | }
|
---|
2085 | dprintf(("SetWindowContextHelpId %x %d", hwnd, dwContextHelpId));
|
---|
2086 | window->setWindowContextHelpId(dwContextHelpId);
|
---|
2087 | RELEASE_WNDOBJ(window);
|
---|
2088 | return(TRUE);
|
---|
2089 | }
|
---|
2090 | //******************************************************************************
|
---|
2091 | //******************************************************************************
|
---|
2092 | HANDLE WIN32API GetPropA(HWND hwnd, LPCSTR str )
|
---|
2093 | {
|
---|
2094 | Win32BaseWindow *window;
|
---|
2095 |
|
---|
2096 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2097 | if(!window) {
|
---|
2098 | dprintf(("GetPropA, window %x not found", hwnd));
|
---|
2099 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2100 | return 0;
|
---|
2101 | }
|
---|
2102 | HANDLE ret = window->getProp(str);
|
---|
2103 | RELEASE_WNDOBJ(window);
|
---|
2104 | return ret;
|
---|
2105 | }
|
---|
2106 | //******************************************************************************
|
---|
2107 | //******************************************************************************
|
---|
2108 | HANDLE WIN32API GetPropW(HWND hwnd, LPCWSTR str)
|
---|
2109 | {
|
---|
2110 | Win32BaseWindow *window;
|
---|
2111 | LPSTR strA;
|
---|
2112 | HANDLE ret;
|
---|
2113 |
|
---|
2114 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2115 | if(!window) {
|
---|
2116 | dprintf(("GetPropW, window %x not found", hwnd));
|
---|
2117 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2118 | return 0;
|
---|
2119 | }
|
---|
2120 |
|
---|
2121 | if(HIWORD(str)) {
|
---|
2122 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
2123 | }
|
---|
2124 | else strA = (LPSTR)str;
|
---|
2125 |
|
---|
2126 | ret = window->getProp(strA);
|
---|
2127 |
|
---|
2128 | RELEASE_WNDOBJ(window);
|
---|
2129 | if(HIWORD(str)) HeapFree( GetProcessHeap(), 0, strA );
|
---|
2130 | return ret;
|
---|
2131 | }
|
---|
2132 | //******************************************************************************
|
---|
2133 | //******************************************************************************
|
---|
2134 | BOOL WIN32API SetPropA(HWND hwnd, LPCSTR str, HANDLE handle )
|
---|
2135 | {
|
---|
2136 | Win32BaseWindow *window;
|
---|
2137 |
|
---|
2138 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2139 | if(!window) {
|
---|
2140 | dprintf(("SetPropA, window %x not found", hwnd));
|
---|
2141 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2142 | return FALSE;
|
---|
2143 | }
|
---|
2144 | BOOL ret = window->setProp(str, handle);
|
---|
2145 | RELEASE_WNDOBJ(window);
|
---|
2146 | return ret;
|
---|
2147 | }
|
---|
2148 | //******************************************************************************
|
---|
2149 | //******************************************************************************
|
---|
2150 | BOOL SetPropW(HWND hwnd, LPCWSTR str, HANDLE handle )
|
---|
2151 | {
|
---|
2152 | BOOL ret;
|
---|
2153 | LPSTR strA;
|
---|
2154 |
|
---|
2155 | if (!HIWORD(str))
|
---|
2156 | return SetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str), handle );
|
---|
2157 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
2158 | ret = SetPropA( hwnd, strA, handle );
|
---|
2159 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
2160 | return ret;
|
---|
2161 | }
|
---|
2162 | //******************************************************************************
|
---|
2163 | //******************************************************************************
|
---|
2164 | HANDLE WIN32API RemovePropA(HWND hwnd, LPCSTR str)
|
---|
2165 | {
|
---|
2166 | Win32BaseWindow *window;
|
---|
2167 |
|
---|
2168 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2169 | if(!window) {
|
---|
2170 | dprintf(("RemovePropA, window %x not found", hwnd));
|
---|
2171 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2172 | return 0;
|
---|
2173 | }
|
---|
2174 | HANDLE ret = window->removeProp(str);
|
---|
2175 | RELEASE_WNDOBJ(window);
|
---|
2176 | return ret;
|
---|
2177 | }
|
---|
2178 | //******************************************************************************
|
---|
2179 | //******************************************************************************
|
---|
2180 | HANDLE WIN32API RemovePropW(HWND hwnd, LPCWSTR str)
|
---|
2181 | {
|
---|
2182 | LPSTR strA;
|
---|
2183 | HANDLE ret;
|
---|
2184 |
|
---|
2185 | if (!HIWORD(str))
|
---|
2186 | return RemovePropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
|
---|
2187 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
2188 | ret = RemovePropA( hwnd, strA );
|
---|
2189 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
2190 | return ret;
|
---|
2191 | }
|
---|
2192 | //******************************************************************************
|
---|
2193 | //******************************************************************************
|
---|
2194 | INT WIN32API EnumPropsA(HWND hwnd, PROPENUMPROCA func )
|
---|
2195 | {
|
---|
2196 | return EnumPropsExA( hwnd, (PROPENUMPROCEXA)func, 0 );
|
---|
2197 | }
|
---|
2198 | //******************************************************************************
|
---|
2199 | //******************************************************************************
|
---|
2200 | INT WIN32API EnumPropsW(HWND hwnd, PROPENUMPROCW func )
|
---|
2201 | {
|
---|
2202 | return EnumPropsExW( hwnd, (PROPENUMPROCEXW)func, 0 );
|
---|
2203 | }
|
---|
2204 | //******************************************************************************
|
---|
2205 | //******************************************************************************
|
---|
2206 | INT WIN32API EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam)
|
---|
2207 | {
|
---|
2208 | Win32BaseWindow *window;
|
---|
2209 |
|
---|
2210 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2211 | if(!window) {
|
---|
2212 | dprintf(("EnumPropsExA, window %x not found", hwnd));
|
---|
2213 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2214 | return -1;
|
---|
2215 | }
|
---|
2216 | INT ret = window->enumPropsExA(func, lParam);
|
---|
2217 | RELEASE_WNDOBJ(window);
|
---|
2218 | return ret;
|
---|
2219 | }
|
---|
2220 | //******************************************************************************
|
---|
2221 | //******************************************************************************
|
---|
2222 | INT WIN32API EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
|
---|
2223 | {
|
---|
2224 | Win32BaseWindow *window;
|
---|
2225 |
|
---|
2226 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
2227 | if(!window) {
|
---|
2228 | dprintf(("EnumPropsExA, window %x not found", hwnd));
|
---|
2229 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2230 | return -1;
|
---|
2231 | }
|
---|
2232 | INT ret = window->enumPropsExW(func, lParam);
|
---|
2233 | RELEASE_WNDOBJ(window);
|
---|
2234 | return ret;
|
---|
2235 | }
|
---|
2236 | //******************************************************************************
|
---|
2237 | //The GetWindowModuleFileName function retrieves the full path and file name of
|
---|
2238 | //the module associated with the specified window handle.
|
---|
2239 | //******************************************************************************
|
---|
2240 | UINT WIN32API GetWindowModuleFileNameA(HWND hwnd, LPTSTR lpszFileName, UINT cchFileNameMax)
|
---|
2241 | {
|
---|
2242 | WNDPROC lpfnWindowProc;
|
---|
2243 |
|
---|
2244 | if (!IsWindow(hwnd)) {
|
---|
2245 | dprintf(("warning: GetWindowModuleFileName: window %x not found!", hwnd));
|
---|
2246 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2247 | return 0;
|
---|
2248 | }
|
---|
2249 | lpfnWindowProc = (WNDPROC)GetWindowLongA(hwnd, GWL_WNDPROC);
|
---|
2250 | return GetProcModuleFileNameA((ULONG)lpfnWindowProc, lpszFileName, cchFileNameMax);
|
---|
2251 | }
|
---|
2252 | //******************************************************************************
|
---|
2253 | //******************************************************************************
|
---|
2254 |
|
---|
2255 |
|
---|
2256 | /*****************************************************************************
|
---|
2257 | * Name : BOOL WIN32API AnyPopup
|
---|
2258 | * Purpose : The AnyPopup function indicates whether an owned, visible,
|
---|
2259 | * top-level pop-up, or overlapped window exists on the screen. The
|
---|
2260 | * function searches the entire Windows screen, not just the calling
|
---|
2261 | * application's client area.
|
---|
2262 | * Parameters: VOID
|
---|
2263 | * Variables :
|
---|
2264 | * Result : If a pop-up window exists, the return value is TRUE even if the
|
---|
2265 | * pop-up window is completely covered by other windows. Otherwise,
|
---|
2266 | * it is FALSE.
|
---|
2267 | * Remark : AnyPopup is a Windows version 1.x function and is retained for
|
---|
2268 | * compatibility purposes. It is generally not useful.
|
---|
2269 | * Status : UNTESTED STUB
|
---|
2270 | *
|
---|
2271 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
2272 | *****************************************************************************/
|
---|
2273 | BOOL WIN32API AnyPopup()
|
---|
2274 | {
|
---|
2275 | dprintf(("USER32:AnyPopup() not implemented.\n"));
|
---|
2276 |
|
---|
2277 | return (FALSE);
|
---|
2278 | }
|
---|
2279 |
|
---|
2280 | #ifdef __cplusplus
|
---|
2281 | } // extern "C"
|
---|
2282 | #endif
|
---|