1 | /* $Id: window.cpp,v 1.74 2000-09-04 18:23:58 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 window apis for OS/2
|
---|
4 | *
|
---|
5 | * Copyright 1999 Sander van Leeuwen
|
---|
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 | *
|
---|
19 | */
|
---|
20 |
|
---|
21 | #include <os2win.h>
|
---|
22 | #include <misc.h>
|
---|
23 | #include <string.h>
|
---|
24 | #include <stdio.h>
|
---|
25 | #include <win32wbase.h>
|
---|
26 | #include <win32wmdiclient.h>
|
---|
27 | #include <win32wdesktop.h>
|
---|
28 | #include "win32dlg.h"
|
---|
29 | #include <oslibwin.h>
|
---|
30 | #include <oslibgdi.h>
|
---|
31 | #include "user32.h"
|
---|
32 | #include "winicon.h"
|
---|
33 | #include <win\winpos.h>
|
---|
34 | #include <heapstring.h>
|
---|
35 |
|
---|
36 | #define DBG_LOCALLOG DBG_window
|
---|
37 | #include "dbglocal.h"
|
---|
38 |
|
---|
39 | //******************************************************************************
|
---|
40 | //******************************************************************************
|
---|
41 | HWND WIN32API CreateWindowExA(DWORD exStyle, LPCSTR className,
|
---|
42 | LPCSTR windowName, DWORD style, INT x,
|
---|
43 | INT y, INT width, INT height,
|
---|
44 | HWND parent, HMENU menu,
|
---|
45 | HINSTANCE instance, LPVOID data )
|
---|
46 | {
|
---|
47 | Win32BaseWindow *window;
|
---|
48 | ATOM classAtom;
|
---|
49 | CREATESTRUCTA cs;
|
---|
50 | char tmpClass[20];
|
---|
51 |
|
---|
52 | if(exStyle & WS_EX_MDICHILD)
|
---|
53 | return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
---|
54 |
|
---|
55 | #if 1
|
---|
56 | /* Find the class atom */
|
---|
57 | if (!(classAtom = GlobalFindAtomA(className)))
|
---|
58 | {
|
---|
59 | if (!HIWORD(className))
|
---|
60 | dprintf(("CreateWindowEx32A: bad class name %04x\n",LOWORD(className)));
|
---|
61 | else
|
---|
62 | dprintf(("CreateWindowEx32A: bad class name '%s'\n", className));
|
---|
63 |
|
---|
64 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
65 | return 0;
|
---|
66 | }
|
---|
67 |
|
---|
68 | if (!HIWORD(className))
|
---|
69 | {
|
---|
70 | sprintf(tmpClass,"#%d", (int) className);
|
---|
71 | className = tmpClass;
|
---|
72 | }
|
---|
73 | #else
|
---|
74 | /* Find the class atom */
|
---|
75 | if (!HIWORD(className) || !(classAtom = GlobalFindAtomA(className)))
|
---|
76 | {
|
---|
77 | if (!HIWORD(className))
|
---|
78 | {
|
---|
79 | sprintf(tmpClass,"#%d", (int) className);
|
---|
80 | classAtom = GlobalFindAtomA(tmpClass);
|
---|
81 | className = tmpClass;
|
---|
82 | }
|
---|
83 | if (!classAtom)
|
---|
84 | {
|
---|
85 | if (!HIWORD(className)) {
|
---|
86 | dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
|
---|
87 | }
|
---|
88 | else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
|
---|
89 |
|
---|
90 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
91 | return 0;
|
---|
92 | }
|
---|
93 | }
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | /* Create the window */
|
---|
97 | cs.lpCreateParams = data;
|
---|
98 | cs.hInstance = instance;
|
---|
99 | cs.hMenu = menu;
|
---|
100 | cs.hwndParent = parent;
|
---|
101 | cs.x = x;
|
---|
102 | cs.y = y;
|
---|
103 | cs.cx = width;
|
---|
104 | cs.cy = height;
|
---|
105 | cs.style = style;
|
---|
106 | cs.lpszName = windowName;
|
---|
107 | cs.lpszClass = className;
|
---|
108 | cs.dwExStyle = exStyle;
|
---|
109 | if(HIWORD(className)) {
|
---|
110 | dprintf(("CreateWindowExA: class %s parent %x (%d,%d) (%d,%d), %x %x menu=%x", className, parent, x, y, width, height, style, exStyle, menu));
|
---|
111 | }
|
---|
112 | else dprintf(("CreateWindowExA: class %d parent %x (%d,%d) (%d,%d), %x %x menu=%x", className, parent, x, y, width, height, style, exStyle, menu));
|
---|
113 |
|
---|
114 | if(!strcmpi(className, MDICLIENTCLASSNAMEA)) {
|
---|
115 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, FALSE);
|
---|
116 | }
|
---|
117 | else
|
---|
118 | if(!strcmpi((char *) className, DIALOG_CLASS_NAMEA))
|
---|
119 | {
|
---|
120 | DLG_TEMPLATE dlgTemplate = {0};
|
---|
121 | dlgTemplate.style = cs.style;
|
---|
122 | dlgTemplate.exStyle = cs.dwExStyle;
|
---|
123 | dlgTemplate.x = cs.x;
|
---|
124 | dlgTemplate.y = cs.y;
|
---|
125 | dlgTemplate.cx = cs.cx;
|
---|
126 | dlgTemplate.cy = cs.cy;
|
---|
127 | dlgTemplate.className = cs.lpszClass;
|
---|
128 | dlgTemplate.caption = cs.lpszName;
|
---|
129 | window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
|
---|
130 | (LPCSTR) &dlgTemplate,
|
---|
131 | cs.hwndParent,
|
---|
132 | NULL,
|
---|
133 | (LPARAM) data,
|
---|
134 | FALSE);
|
---|
135 | }
|
---|
136 | else {
|
---|
137 | window = new Win32BaseWindow( &cs, classAtom, FALSE );
|
---|
138 | }
|
---|
139 | if(window == NULL)
|
---|
140 | {
|
---|
141 | dprintf(("Win32BaseWindow creation failed!!"));
|
---|
142 | return 0;
|
---|
143 | }
|
---|
144 | if(GetLastError() != 0)
|
---|
145 | {
|
---|
146 | dprintf(("Win32BaseWindow error found!!"));
|
---|
147 | delete window;
|
---|
148 | return 0;
|
---|
149 | }
|
---|
150 | return window->getWindowHandle();
|
---|
151 | }
|
---|
152 | //******************************************************************************
|
---|
153 | //******************************************************************************
|
---|
154 | HWND WIN32API CreateWindowExW(DWORD exStyle, LPCWSTR className,
|
---|
155 | LPCWSTR windowName, DWORD style, INT x,
|
---|
156 | INT y, INT width, INT height,
|
---|
157 | HWND parent, HMENU menu,
|
---|
158 | HINSTANCE instance, LPVOID data )
|
---|
159 | {
|
---|
160 | Win32BaseWindow *window;
|
---|
161 | ATOM classAtom;
|
---|
162 | CREATESTRUCTA cs;
|
---|
163 | char tmpClassA[20];
|
---|
164 | WCHAR tmpClassW[20];
|
---|
165 |
|
---|
166 | if(exStyle & WS_EX_MDICHILD)
|
---|
167 | return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
---|
168 |
|
---|
169 | /* Find the class atom */
|
---|
170 | if (!HIWORD(className) || !(classAtom = GlobalFindAtomW(className)))
|
---|
171 | {
|
---|
172 | if (!HIWORD(className))
|
---|
173 | {
|
---|
174 | sprintf(tmpClassA,"#%d", (int) className);
|
---|
175 | AsciiToUnicode(tmpClassA, tmpClassW);
|
---|
176 | classAtom = GlobalFindAtomW(tmpClassW);
|
---|
177 | className = (LPCWSTR)tmpClassW;
|
---|
178 | }
|
---|
179 | if (!classAtom)
|
---|
180 | {
|
---|
181 | if (!HIWORD(className)) {
|
---|
182 | dprintf(("CreateWindowEx32W: bad class name %04x\n", LOWORD(className)));
|
---|
183 | }
|
---|
184 | else dprintf(("CreateWindowEx32W: bad class name "));
|
---|
185 |
|
---|
186 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
187 | return 0;
|
---|
188 | }
|
---|
189 | }
|
---|
190 | if(HIWORD(className)) {
|
---|
191 | dprintf(("CreateWindowExW: class %ls name %x parent %x (%d,%d) (%d,%d), %x %x", className, windowName, parent, x, y, width, height, style, exStyle));
|
---|
192 | }
|
---|
193 | else dprintf(("CreateWindowExW: class %d name %x parent %x (%d,%d) (%d,%d), %x %x", className, windowName, parent, x, y, width, height, style, exStyle));
|
---|
194 |
|
---|
195 | /* Create the window */
|
---|
196 | cs.lpCreateParams = data;
|
---|
197 | cs.hInstance = instance;
|
---|
198 | cs.hMenu = menu;
|
---|
199 | cs.hwndParent = parent;
|
---|
200 | cs.x = x;
|
---|
201 | cs.y = y;
|
---|
202 | cs.cx = width;
|
---|
203 | cs.cy = height;
|
---|
204 | cs.style = style;
|
---|
205 | cs.lpszName = (LPSTR)windowName;
|
---|
206 | cs.lpszClass = (LPSTR)className;
|
---|
207 | cs.dwExStyle = exStyle;
|
---|
208 |
|
---|
209 | if(!lstrcmpiW(className, (LPWSTR)MDICLIENTCLASSNAMEW)) {
|
---|
210 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, TRUE);
|
---|
211 | }
|
---|
212 | else
|
---|
213 | if(!lstrcmpiW(className, (LPWSTR)DIALOG_CLASS_NAMEW))
|
---|
214 | {
|
---|
215 | DLG_TEMPLATE dlgTemplate = {0};
|
---|
216 | dlgTemplate.style = cs.style;
|
---|
217 | dlgTemplate.exStyle = cs.dwExStyle;
|
---|
218 | dlgTemplate.x = cs.x;
|
---|
219 | dlgTemplate.y = cs.y;
|
---|
220 | dlgTemplate.cx = cs.cx;
|
---|
221 | dlgTemplate.cy = cs.cy;
|
---|
222 | dlgTemplate.className = cs.lpszClass;
|
---|
223 | dlgTemplate.caption = cs.lpszName;
|
---|
224 | window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
|
---|
225 | (LPCSTR) &dlgTemplate,
|
---|
226 | cs.hwndParent,
|
---|
227 | NULL,
|
---|
228 | (LPARAM) data,
|
---|
229 | TRUE);
|
---|
230 | }
|
---|
231 | else {
|
---|
232 | window = new Win32BaseWindow( &cs, classAtom, TRUE );
|
---|
233 | }
|
---|
234 | if(window == NULL)
|
---|
235 | {
|
---|
236 | dprintf(("Win32BaseWindow creation failed!!"));
|
---|
237 | return 0;
|
---|
238 | }
|
---|
239 | if(GetLastError() != 0)
|
---|
240 | {
|
---|
241 | dprintf(("Win32BaseWindow error found!!"));
|
---|
242 | delete window;
|
---|
243 | return 0;
|
---|
244 | }
|
---|
245 | return window->getWindowHandle();
|
---|
246 | }
|
---|
247 | //******************************************************************************
|
---|
248 | //******************************************************************************
|
---|
249 | HWND WIN32API CreateMDIWindowA(LPCSTR lpszClassName, LPCSTR lpszWindowName,
|
---|
250 | DWORD dwStyle, int x, int y, int nWidth,
|
---|
251 | int nHeight, HWND hwndParent,
|
---|
252 | HINSTANCE hInstance, LPARAM lParam )
|
---|
253 | {
|
---|
254 | HWND hwnd;
|
---|
255 | MDICREATESTRUCTA cs;
|
---|
256 | Win32BaseWindow *window;
|
---|
257 |
|
---|
258 | window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
|
---|
259 | if(!window) {
|
---|
260 | dprintf(("CreateMDIWindowA, window %x not found", hwndParent));
|
---|
261 | return 0;
|
---|
262 | }
|
---|
263 |
|
---|
264 | dprintf(("USER32: CreateMDIWindowA\n"));
|
---|
265 | cs.szClass = lpszClassName;
|
---|
266 | cs.szTitle = lpszWindowName;
|
---|
267 | cs.hOwner = hInstance;
|
---|
268 | cs.x = x;
|
---|
269 | cs.y = y;
|
---|
270 | cs.cx = nHeight;
|
---|
271 | cs.cy = nWidth;
|
---|
272 | cs.style = dwStyle;
|
---|
273 | cs.lParam = lParam;
|
---|
274 |
|
---|
275 | return window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
|
---|
276 | }
|
---|
277 | //******************************************************************************
|
---|
278 | //******************************************************************************
|
---|
279 | HWND WIN32API CreateMDIWindowW(LPCWSTR lpszClassName, LPCWSTR lpszWindowName,
|
---|
280 | DWORD dwStyle, int x, int y, int nWidth,
|
---|
281 | int nHeight, HWND hwndParent,
|
---|
282 | HINSTANCE hInstance, LPARAM lParam )
|
---|
283 | {
|
---|
284 | HWND hwnd;
|
---|
285 | MDICREATESTRUCTW cs;
|
---|
286 | Win32BaseWindow *window;
|
---|
287 |
|
---|
288 | window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
|
---|
289 | if(!window) {
|
---|
290 | dprintf(("CreateMDIWindowW, window %x not found", hwndParent));
|
---|
291 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
292 | return 0;
|
---|
293 | }
|
---|
294 |
|
---|
295 | dprintf(("USER32: CreateMDIWindowW\n"));
|
---|
296 | cs.szClass = lpszClassName;
|
---|
297 | cs.szTitle = lpszWindowName;
|
---|
298 | cs.hOwner = hInstance;
|
---|
299 | cs.x = x;
|
---|
300 | cs.y = y;
|
---|
301 | cs.cx = nHeight;
|
---|
302 | cs.cy = nWidth;
|
---|
303 | cs.style = dwStyle;
|
---|
304 | cs.lParam = lParam;
|
---|
305 |
|
---|
306 | return window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
|
---|
307 | }
|
---|
308 | //******************************************************************************
|
---|
309 | //******************************************************************************
|
---|
310 | BOOL WIN32API DestroyWindow(HWND hwnd)
|
---|
311 | {
|
---|
312 | Win32BaseWindow *window;
|
---|
313 |
|
---|
314 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
315 | if(!window) {
|
---|
316 | dprintf(("DestroyWindow, window %x not found", hwnd));
|
---|
317 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
318 | return 0;
|
---|
319 | }
|
---|
320 | if(window->isDesktopWindow()) {
|
---|
321 | dprintf(("WARNING: Trying to destroy desktop window!"));
|
---|
322 | return FALSE;
|
---|
323 | }
|
---|
324 | return window->DestroyWindow();
|
---|
325 | }
|
---|
326 | //******************************************************************************
|
---|
327 | //******************************************************************************
|
---|
328 | HWND WIN32API SetActiveWindow( HWND hwnd)
|
---|
329 | {
|
---|
330 | Win32BaseWindow *window;
|
---|
331 |
|
---|
332 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
333 | if(!window) {
|
---|
334 | dprintf(("SetActiveWindow, window %x not found", hwnd));
|
---|
335 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
336 | return 0;
|
---|
337 | }
|
---|
338 | return window->SetActiveWindow();
|
---|
339 | }
|
---|
340 | //******************************************************************************
|
---|
341 | //******************************************************************************
|
---|
342 | HWND WIN32API GetParent( HWND hwnd)
|
---|
343 | {
|
---|
344 | Win32BaseWindow *window;
|
---|
345 |
|
---|
346 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
347 | if(!window) {
|
---|
348 | dprintf(("GetParent, window %x not found", hwnd));
|
---|
349 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
350 | return 0;
|
---|
351 | }
|
---|
352 | // dprintf(("GetParent %x", hwnd));
|
---|
353 | return window->GetParent();
|
---|
354 | }
|
---|
355 | //******************************************************************************
|
---|
356 | //******************************************************************************
|
---|
357 | HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
|
---|
358 | {
|
---|
359 | Win32BaseWindow *window, *parent;
|
---|
360 |
|
---|
361 | window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
|
---|
362 | if(!window) {
|
---|
363 | dprintf(("SetParent, window %x not found", hwndChild));
|
---|
364 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
365 | return 0;
|
---|
366 | }
|
---|
367 | if(hwndNewParent == HWND_DESKTOP) {
|
---|
368 | hwndNewParent = GetDesktopWindow();
|
---|
369 | }
|
---|
370 | else {
|
---|
371 | parent = Win32BaseWindow::GetWindowFromHandle(hwndNewParent);
|
---|
372 | if(!window) {
|
---|
373 | dprintf(("SetParent, parent %x not found", hwndNewParent));
|
---|
374 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
375 | return 0;
|
---|
376 | }
|
---|
377 | }
|
---|
378 | dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
|
---|
379 | return window->SetParent(hwndNewParent);
|
---|
380 | }
|
---|
381 | //******************************************************************************
|
---|
382 | //******************************************************************************
|
---|
383 | BOOL WIN32API IsChild( HWND hwndParent, HWND hwnd)
|
---|
384 | {
|
---|
385 | Win32BaseWindow *window;
|
---|
386 |
|
---|
387 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
388 | if(!window) {
|
---|
389 | dprintf(("IsChild %x, window %x not found", hwndParent, hwnd));
|
---|
390 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
391 | return 0;
|
---|
392 | }
|
---|
393 | dprintf(("IsChild %x %x", hwndParent, hwnd));
|
---|
394 | return window->IsChild(hwndParent);
|
---|
395 | }
|
---|
396 | //******************************************************************************
|
---|
397 | //******************************************************************************
|
---|
398 | HWND WIN32API GetTopWindow( HWND hwnd)
|
---|
399 | {
|
---|
400 | Win32BaseWindow *window;
|
---|
401 |
|
---|
402 | if(hwnd == HWND_DESKTOP) {
|
---|
403 | window = windowDesktop;
|
---|
404 | }
|
---|
405 | else {
|
---|
406 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
407 | if(!window) {
|
---|
408 | dprintf(("GetTopWindow, window %x not found", hwnd));
|
---|
409 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
410 | return 0;
|
---|
411 | }
|
---|
412 | }
|
---|
413 | return window->GetTopWindow();
|
---|
414 | }
|
---|
415 | //******************************************************************************
|
---|
416 | //******************************************************************************
|
---|
417 | BOOL WIN32API IsIconic( HWND hwnd)
|
---|
418 | {
|
---|
419 | Win32BaseWindow *window;
|
---|
420 | BOOL rc;
|
---|
421 |
|
---|
422 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
423 | if(!window) {
|
---|
424 | dprintf(("IsIconic, window %x not found", hwnd));
|
---|
425 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
426 | return FALSE;
|
---|
427 | }
|
---|
428 | rc = window->IsWindowIconic();
|
---|
429 | dprintf(("IsIconic %x returned %d", hwnd, rc));
|
---|
430 | return rc;
|
---|
431 | }
|
---|
432 | //******************************************************************************
|
---|
433 | //******************************************************************************
|
---|
434 | HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
|
---|
435 | {
|
---|
436 | Win32BaseWindow *window;
|
---|
437 | HWND rc;
|
---|
438 |
|
---|
439 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
440 | if(!window) {
|
---|
441 | dprintf(("GetWindow, window %x not found", hwnd));
|
---|
442 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
443 | return 0;
|
---|
444 | }
|
---|
445 | rc = window->GetWindow(uCmd);
|
---|
446 | return rc;
|
---|
447 | }
|
---|
448 | //******************************************************************************
|
---|
449 | //******************************************************************************
|
---|
450 | BOOL WIN32API EnableWindow( HWND hwnd, BOOL fEnable)
|
---|
451 | {
|
---|
452 | Win32BaseWindow *window;
|
---|
453 |
|
---|
454 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
455 | if(!window) {
|
---|
456 | dprintf(("EnableWindow, window %x not found", hwnd));
|
---|
457 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
458 | return 0;
|
---|
459 | }
|
---|
460 | dprintf(("EnableWindow %x %d", hwnd, fEnable));
|
---|
461 | return window->EnableWindow(fEnable);
|
---|
462 | }
|
---|
463 | //******************************************************************************
|
---|
464 | //******************************************************************************
|
---|
465 | BOOL WIN32API BringWindowToTop(HWND hwnd)
|
---|
466 | {
|
---|
467 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
|
---|
468 | }
|
---|
469 | /***********************************************************************
|
---|
470 | * SetInternalWindowPos (USER32.483)
|
---|
471 | */
|
---|
472 | void WIN32API SetInternalWindowPos(HWND hwnd,
|
---|
473 | UINT showCmd,
|
---|
474 | LPRECT lpRect,
|
---|
475 | LPPOINT lpPoint )
|
---|
476 | {
|
---|
477 | dprintf(("USER32: SetInternalWindowPos(%08xh,%08xh,%08xh,%08xh)",
|
---|
478 | hwnd, showCmd, lpRect, lpPoint));
|
---|
479 |
|
---|
480 | if( IsWindow(hwnd) )
|
---|
481 | {
|
---|
482 | WINDOWPLACEMENT wndpl;
|
---|
483 | UINT flags;
|
---|
484 |
|
---|
485 | GetWindowPlacement(hwnd, &wndpl);
|
---|
486 | wndpl.length = sizeof(wndpl);
|
---|
487 | wndpl.showCmd = showCmd;
|
---|
488 | wndpl.flags = 0;
|
---|
489 |
|
---|
490 | if(lpPoint)
|
---|
491 | {
|
---|
492 | wndpl.flags |= WPF_SETMINPOSITION;
|
---|
493 | wndpl.ptMinPosition = *lpPoint;
|
---|
494 | }
|
---|
495 | if(lpRect)
|
---|
496 | {
|
---|
497 | wndpl.rcNormalPosition = *lpRect;
|
---|
498 | }
|
---|
499 | SetWindowPlacement( hwnd, &wndpl);
|
---|
500 | }
|
---|
501 |
|
---|
502 | }
|
---|
503 | /***********************************************************************
|
---|
504 | * GetInternalWindowPos (USER32.245)
|
---|
505 | */
|
---|
506 | UINT WIN32API GetInternalWindowPos(HWND hwnd,
|
---|
507 | LPRECT rectWnd,
|
---|
508 | LPPOINT ptIcon )
|
---|
509 | {
|
---|
510 | WINDOWPLACEMENT wndpl;
|
---|
511 |
|
---|
512 | dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
|
---|
513 | hwnd,
|
---|
514 | rectWnd,
|
---|
515 | ptIcon));
|
---|
516 |
|
---|
517 | if(GetWindowPlacement( hwnd, &wndpl ))
|
---|
518 | {
|
---|
519 | if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
|
---|
520 | if (ptIcon) *ptIcon = wndpl.ptMinPosition;
|
---|
521 | return wndpl.showCmd;
|
---|
522 | }
|
---|
523 | return 0;
|
---|
524 | }
|
---|
525 | //******************************************************************************
|
---|
526 | //******************************************************************************
|
---|
527 | HWND WIN32API GetActiveWindow()
|
---|
528 | {
|
---|
529 | return Win32BaseWindow::GetActiveWindow();
|
---|
530 | }
|
---|
531 | //******************************************************************************
|
---|
532 | //******************************************************************************
|
---|
533 | BOOL WIN32API ShowWindow(HWND hwnd, int nCmdShow)
|
---|
534 | {
|
---|
535 | Win32BaseWindow *window;
|
---|
536 |
|
---|
537 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
538 | if(!window) {
|
---|
539 | dprintf(("ShowWindow, window %x not found", hwnd));
|
---|
540 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
541 | return 0;
|
---|
542 | }
|
---|
543 | return window->ShowWindow(nCmdShow);
|
---|
544 | }
|
---|
545 | /*****************************************************************************
|
---|
546 | * Name : BOOL WIN32API ShowWindowAsync
|
---|
547 | * Purpose : The ShowWindowAsync function sets the show state of a window
|
---|
548 | * created by a different thread.
|
---|
549 | * Parameters: HWND hwnd handle of window
|
---|
550 | * int nCmdShow show state of window
|
---|
551 | * Variables :
|
---|
552 | * Result : If the window was previously visible, the return value is TRUE.
|
---|
553 | * If the window was previously hidden, the return value is FALSE.
|
---|
554 | * Remark :
|
---|
555 | * Status : UNTESTED STUB
|
---|
556 | *
|
---|
557 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
558 | *****************************************************************************/
|
---|
559 | BOOL WIN32API ShowWindowAsync (HWND hwnd,
|
---|
560 | int nCmdShow)
|
---|
561 | {
|
---|
562 | dprintf(("USER32:ShowWindowAsync (%08xh,%08x) not correctly implemented.\n",
|
---|
563 | hwnd,
|
---|
564 | nCmdShow));
|
---|
565 |
|
---|
566 | return ShowWindow(hwnd, nCmdShow);
|
---|
567 | }
|
---|
568 | //******************************************************************************
|
---|
569 | //******************************************************************************
|
---|
570 | BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
|
---|
571 | {
|
---|
572 | Win32BaseWindow *window;
|
---|
573 |
|
---|
574 | if (!hwnd)
|
---|
575 | {
|
---|
576 | dprintf(("SetWindowPos: Can't move desktop!"));
|
---|
577 | return TRUE;
|
---|
578 | }
|
---|
579 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
580 | if(!window) {
|
---|
581 | dprintf(("SetWindowPos, window %x not found", hwnd));
|
---|
582 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
583 | return FALSE;
|
---|
584 | }
|
---|
585 | dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
|
---|
586 | return window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
|
---|
587 | }
|
---|
588 | //******************************************************************************
|
---|
589 | //******************************************************************************
|
---|
590 | BOOL WIN32API SetWindowPlacement(HWND hwnd, const WINDOWPLACEMENT *winpos)
|
---|
591 | {
|
---|
592 | Win32BaseWindow *window;
|
---|
593 |
|
---|
594 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
595 | if(!window) {
|
---|
596 | dprintf(("SetWindowPlacement, window %x not found", hwnd));
|
---|
597 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
598 | return FALSE;
|
---|
599 | }
|
---|
600 | if(!winpos) {
|
---|
601 | dprintf(("SetWindowPlacement %x invalid parameter", hwnd));
|
---|
602 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
603 | return FALSE;
|
---|
604 | }
|
---|
605 | dprintf(("USER32: SetWindowPlacement %x %x", hwnd, winpos));
|
---|
606 | return window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
|
---|
607 | }
|
---|
608 | //******************************************************************************
|
---|
609 | //******************************************************************************
|
---|
610 | BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT winpos)
|
---|
611 | {
|
---|
612 | Win32BaseWindow *window;
|
---|
613 |
|
---|
614 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
615 | if(!window) {
|
---|
616 | dprintf(("GetWindowPlacement, window %x not found", hwnd));
|
---|
617 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
618 | return FALSE;
|
---|
619 | }
|
---|
620 | if(!winpos) {
|
---|
621 | dprintf(("GetWindowPlacement %x invalid parameter", hwnd));
|
---|
622 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
623 | return FALSE;
|
---|
624 | }
|
---|
625 | dprintf(("USER32: GetWindowPlacement %x %x", hwnd, winpos));
|
---|
626 | return window->GetWindowPlacement(winpos);
|
---|
627 | }
|
---|
628 | //******************************************************************************
|
---|
629 | //******************************************************************************
|
---|
630 | BOOL WIN32API IsWindow( HWND hwnd)
|
---|
631 | {
|
---|
632 | Win32BaseWindow *window;
|
---|
633 |
|
---|
634 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
635 | if(!window) {
|
---|
636 | dprintf(("IsWindow, window %x not found", hwnd));
|
---|
637 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
638 | return FALSE;
|
---|
639 | }
|
---|
640 | dprintf(("IsWindow %x", hwnd));
|
---|
641 | return window->IsWindow();
|
---|
642 | }
|
---|
643 | //******************************************************************************
|
---|
644 | //******************************************************************************
|
---|
645 | BOOL WIN32API IsWindowEnabled( HWND hwnd)
|
---|
646 | {
|
---|
647 | Win32BaseWindow *window;
|
---|
648 |
|
---|
649 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
650 | if(!window) {
|
---|
651 | dprintf(("IsWindowEnabled, window %x not found", hwnd));
|
---|
652 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
653 | return 0;
|
---|
654 | }
|
---|
655 | dprintf(("IsWindowEnabled %x", hwnd));
|
---|
656 | return window->IsWindowEnabled();
|
---|
657 | }
|
---|
658 | //******************************************************************************
|
---|
659 | //******************************************************************************
|
---|
660 | BOOL WIN32API IsWindowVisible( HWND hwnd)
|
---|
661 | {
|
---|
662 | Win32BaseWindow *window;
|
---|
663 | BOOL rc;
|
---|
664 |
|
---|
665 | if (hwnd)
|
---|
666 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
667 | else
|
---|
668 | window = windowDesktop;
|
---|
669 | if(!window) {
|
---|
670 | dprintf(("IsWindowVisible, window %x not found", hwnd));
|
---|
671 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
672 | return 0;
|
---|
673 | }
|
---|
674 | rc = window->IsWindowVisible();
|
---|
675 | dprintf(("IsWindowVisible %x returned %d", hwnd, rc));
|
---|
676 | return rc;
|
---|
677 | }
|
---|
678 | //******************************************************************************
|
---|
679 | //******************************************************************************
|
---|
680 | HWND WIN32API SetFocus (HWND hwnd)
|
---|
681 | {
|
---|
682 | HWND lastFocus, lastFocus_W, hwnd_O;
|
---|
683 | BOOL activate;
|
---|
684 |
|
---|
685 | hwnd_O = Win32BaseWindow::Win32ToOS2Handle (hwnd);
|
---|
686 | lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
|
---|
687 | activate = ((hwnd_O == lastFocus) || OSLibWinIsChild (lastFocus, hwnd_O));
|
---|
688 | lastFocus_W = Win32BaseWindow::OS2ToWin32Handle (lastFocus);
|
---|
689 |
|
---|
690 | dprintf(("SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
|
---|
691 |
|
---|
692 | return (OSLibWinSetFocus (OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
|
---|
693 | }
|
---|
694 | //******************************************************************************
|
---|
695 | //******************************************************************************
|
---|
696 | HWND WIN32API GetFocus(void)
|
---|
697 | {
|
---|
698 | HWND hwnd;
|
---|
699 |
|
---|
700 | hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
|
---|
701 | hwnd = Win32BaseWindow::OS2ToWin32Handle(hwnd);
|
---|
702 | dprintf(("USER32: GetFocus %x\n", hwnd));
|
---|
703 | return hwnd;
|
---|
704 | }
|
---|
705 | //******************************************************************************
|
---|
706 | //******************************************************************************
|
---|
707 | BOOL WIN32API IsZoomed(HWND hwnd)
|
---|
708 | {
|
---|
709 | DWORD style;
|
---|
710 |
|
---|
711 | style = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
712 | dprintf(("USER32: IsZoomed %x returned %d", hwnd, ((style & WS_MAXIMIZE) != 0)));
|
---|
713 |
|
---|
714 | return (style & WS_MAXIMIZE) != 0;
|
---|
715 | }
|
---|
716 | //******************************************************************************
|
---|
717 | //******************************************************************************
|
---|
718 | BOOL WIN32API LockWindowUpdate(HWND hwnd)
|
---|
719 | {
|
---|
720 | dprintf(("USER32: LockWindowUpdate\n"));
|
---|
721 | return O32_LockWindowUpdate(Win32BaseWindow::Win32ToOS2Handle(hwnd));
|
---|
722 | }
|
---|
723 | //******************************************************************************
|
---|
724 | //******************************************************************************
|
---|
725 | BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
|
---|
726 | {
|
---|
727 | Win32BaseWindow *window;
|
---|
728 |
|
---|
729 | if (hwnd)
|
---|
730 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
731 | else
|
---|
732 | window = windowDesktop;
|
---|
733 |
|
---|
734 | if(!window) {
|
---|
735 | dprintf(("GetWindowRect, window %x not found", hwnd));
|
---|
736 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
737 | return FALSE;
|
---|
738 | }
|
---|
739 | if(pRect == NULL) {
|
---|
740 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
741 | return FALSE;
|
---|
742 | }
|
---|
743 | *pRect = *window->getWindowRect();
|
---|
744 |
|
---|
745 | //convert from parent coordinates to screen (if necessary)
|
---|
746 | if(window->getParent()) {
|
---|
747 | MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
|
---|
748 | }
|
---|
749 |
|
---|
750 | dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
---|
751 | return TRUE;
|
---|
752 | }
|
---|
753 | //******************************************************************************
|
---|
754 | //******************************************************************************
|
---|
755 | int WIN32API GetWindowTextLengthA( HWND hwnd)
|
---|
756 | {
|
---|
757 | Win32BaseWindow *window;
|
---|
758 |
|
---|
759 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
760 | if(!window) {
|
---|
761 | dprintf(("GetWindowTextLength, window %x not found", hwnd));
|
---|
762 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
763 | return 0;
|
---|
764 | }
|
---|
765 | dprintf(("GetWindowTextLength %x", hwnd));
|
---|
766 | return window->GetWindowTextLength();
|
---|
767 | }
|
---|
768 | //******************************************************************************
|
---|
769 | //******************************************************************************
|
---|
770 | int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
|
---|
771 | {
|
---|
772 | Win32BaseWindow *window;
|
---|
773 | int rc;
|
---|
774 |
|
---|
775 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
776 | if(!window) {
|
---|
777 | dprintf(("GetWindowTextA, window %x not found", hwnd));
|
---|
778 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
779 | return 0;
|
---|
780 | }
|
---|
781 | rc = window->GetWindowTextA(lpsz, cch);
|
---|
782 | dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
|
---|
783 | return rc;
|
---|
784 | }
|
---|
785 | //******************************************************************************
|
---|
786 | //******************************************************************************
|
---|
787 | int WIN32API GetWindowTextLengthW( HWND hwnd)
|
---|
788 | {
|
---|
789 | dprintf(("USER32: GetWindowTextLengthW\n"));
|
---|
790 | return GetWindowTextLengthA(hwnd);
|
---|
791 | }
|
---|
792 | //******************************************************************************
|
---|
793 | //******************************************************************************
|
---|
794 | int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
|
---|
795 | {
|
---|
796 | Win32BaseWindow *window;
|
---|
797 |
|
---|
798 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
799 | if(!window) {
|
---|
800 | dprintf(("GetWindowTextW, window %x not found", hwnd));
|
---|
801 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
802 | return 0;
|
---|
803 | }
|
---|
804 | #ifdef DEBUG
|
---|
805 | int rc = window->GetWindowTextW(lpsz, cch);
|
---|
806 | if(rc) {
|
---|
807 | LPSTR astring = UnicodeToAsciiString(lpsz);
|
---|
808 | dprintf(("GetWindowTextW %x %s", hwnd, lpsz));
|
---|
809 | free(astring);
|
---|
810 | }
|
---|
811 | else dprintf(("GetWindowTextW %x returned %d", hwnd, rc));
|
---|
812 | return rc;
|
---|
813 | #else
|
---|
814 | return window->GetWindowTextW(lpsz, cch);
|
---|
815 | #endif
|
---|
816 | }
|
---|
817 | //******************************************************************************
|
---|
818 | //******************************************************************************
|
---|
819 | BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
|
---|
820 | {
|
---|
821 | Win32BaseWindow *window;
|
---|
822 |
|
---|
823 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
824 | if(!window) {
|
---|
825 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
---|
826 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
827 | return 0;
|
---|
828 | }
|
---|
829 | dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
|
---|
830 | return window->SetWindowTextA((LPSTR)lpsz);
|
---|
831 | }
|
---|
832 | //******************************************************************************
|
---|
833 | //******************************************************************************
|
---|
834 | BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
|
---|
835 | {
|
---|
836 | Win32BaseWindow *window;
|
---|
837 |
|
---|
838 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
839 | if(!window) {
|
---|
840 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
---|
841 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
842 | return 0;
|
---|
843 | }
|
---|
844 | #ifdef DEBUG
|
---|
845 | LPSTR astring = UnicodeToAsciiString(lpsz);
|
---|
846 | dprintf(("SetWindowTextW %x %s", hwnd, astring));
|
---|
847 | free(astring);
|
---|
848 | if(hwnd == 0x68000008) {
|
---|
849 | int i;
|
---|
850 | i = 5;
|
---|
851 | }
|
---|
852 | #endif
|
---|
853 | return window->SetWindowTextW((LPWSTR)lpsz);
|
---|
854 | }
|
---|
855 | /*******************************************************************
|
---|
856 | * InternalGetWindowText (USER32.326)
|
---|
857 | */
|
---|
858 | int WIN32API InternalGetWindowText(HWND hwnd,
|
---|
859 | LPWSTR lpString,
|
---|
860 | INT nMaxCount )
|
---|
861 | {
|
---|
862 | dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
|
---|
863 | hwnd,
|
---|
864 | lpString,
|
---|
865 | nMaxCount));
|
---|
866 |
|
---|
867 | return GetWindowTextW(hwnd,lpString,nMaxCount);
|
---|
868 | }
|
---|
869 | //******************************************************************************
|
---|
870 | //TODO: Correct?
|
---|
871 | //******************************************************************************
|
---|
872 | BOOL WIN32API SetForegroundWindow(HWND hwnd)
|
---|
873 | {
|
---|
874 | dprintf((" SetForegroundWindow %x", hwnd));
|
---|
875 |
|
---|
876 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
---|
877 | }
|
---|
878 | //******************************************************************************
|
---|
879 | //******************************************************************************
|
---|
880 | BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
|
---|
881 | {
|
---|
882 | HWND hwndWin32 = hwnd;
|
---|
883 | Win32BaseWindow *window;
|
---|
884 |
|
---|
885 | if (!pRect)
|
---|
886 | {
|
---|
887 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
888 | return FALSE;
|
---|
889 | }
|
---|
890 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
891 | if(!window) {
|
---|
892 | dprintf(("GetClientRect, window %x not found", hwnd));
|
---|
893 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
894 | return FALSE;
|
---|
895 | }
|
---|
896 | window->getClientRect(pRect);
|
---|
897 | dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
---|
898 | return TRUE;
|
---|
899 | }
|
---|
900 | //******************************************************************************
|
---|
901 | //******************************************************************************
|
---|
902 | BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
|
---|
903 | {
|
---|
904 | return AdjustWindowRectEx(rect, style, menu, 0);
|
---|
905 | }
|
---|
906 | //******************************************************************************
|
---|
907 | //******************************************************************************
|
---|
908 | BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
|
---|
909 | {
|
---|
910 | dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
|
---|
911 |
|
---|
912 | if(style == 0 && menu == FALSE && exStyle == 0) {
|
---|
913 | return TRUE; //nothing needs to be changed (VERIFIED in NT 4)
|
---|
914 | }
|
---|
915 | /* Correct the window style */
|
---|
916 | if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
|
---|
917 | style |= WS_CAPTION;
|
---|
918 |
|
---|
919 | //SvL: Include WS_POPUP -> otherwise HAS_THINFRAME is true for popup windows
|
---|
920 | // Also include WS_CHILD -> otherwise HAS_THICKFRAME doesn't work correctly
|
---|
921 | style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_POPUP);
|
---|
922 | exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
|
---|
923 | if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
|
---|
924 |
|
---|
925 | //Adjust rect outer (Win32BaseWindow::AdjustRectOuter)
|
---|
926 | if (HAS_THICKFRAME(style,exStyle))
|
---|
927 | InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
|
---|
928 | else
|
---|
929 | if (HAS_DLGFRAME(style,exStyle))
|
---|
930 | InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
|
---|
931 | else
|
---|
932 | if (HAS_THINFRAME(style))
|
---|
933 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
934 |
|
---|
935 | if ((style & WS_CAPTION) == WS_CAPTION)
|
---|
936 | {
|
---|
937 | if (exStyle & WS_EX_TOOLWINDOW)
|
---|
938 | rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
|
---|
939 | else
|
---|
940 | rect->top -= GetSystemMetrics(SM_CYCAPTION);
|
---|
941 | }
|
---|
942 |
|
---|
943 | if (menu)
|
---|
944 | rect->top -= GetSystemMetrics(SM_CYMENU);
|
---|
945 |
|
---|
946 | //Adjust rect inner (Win32BaseWindow::AdjustRectInner)
|
---|
947 | if (exStyle & WS_EX_CLIENTEDGE)
|
---|
948 | InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
|
---|
949 |
|
---|
950 | if (exStyle & WS_EX_STATICEDGE)
|
---|
951 | InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
952 |
|
---|
953 | if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
|
---|
954 | if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
|
---|
955 |
|
---|
956 | dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
|
---|
957 |
|
---|
958 | return TRUE;
|
---|
959 | }
|
---|
960 | //******************************************************************************
|
---|
961 | /* Coordinate Space and Transformation Functions */
|
---|
962 | //******************************************************************************
|
---|
963 | /*******************************************************************
|
---|
964 | * WINPOS_GetWinOffset
|
---|
965 | *
|
---|
966 | * Calculate the offset between the origin of the two windows. Used
|
---|
967 | * to implement MapWindowPoints.
|
---|
968 | */
|
---|
969 | static void WINPOS_GetWinOffset( Win32BaseWindow *wndFrom, Win32BaseWindow *wndTo,
|
---|
970 | POINT *offset )
|
---|
971 | {
|
---|
972 | Win32BaseWindow *window;
|
---|
973 |
|
---|
974 | offset->x = offset->y = 0;
|
---|
975 |
|
---|
976 | /* Translate source window origin to screen coords */
|
---|
977 | if(wndFrom != windowDesktop)
|
---|
978 | {
|
---|
979 | window = wndFrom;
|
---|
980 | while(window)
|
---|
981 | {
|
---|
982 | offset->x += window->getClientRectPtr()->left + window->getWindowRect()->left;
|
---|
983 | offset->y += window->getClientRectPtr()->top + window->getWindowRect()->top;
|
---|
984 | window = window->getParent();
|
---|
985 | }
|
---|
986 | }
|
---|
987 |
|
---|
988 | /* Translate origin to destination window coords */
|
---|
989 | if(wndTo != windowDesktop)
|
---|
990 | {
|
---|
991 | window = wndTo;
|
---|
992 | while(window)
|
---|
993 | {
|
---|
994 | offset->x -= window->getClientRectPtr()->left + window->getWindowRect()->left;
|
---|
995 | offset->y -= window->getClientRectPtr()->top + window->getWindowRect()->top;
|
---|
996 | window = window->getParent();
|
---|
997 | }
|
---|
998 | }
|
---|
999 | }
|
---|
1000 | //******************************************************************************
|
---|
1001 | //******************************************************************************
|
---|
1002 | int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
|
---|
1003 | UINT cPoints)
|
---|
1004 | {
|
---|
1005 | Win32BaseWindow *wndfrom, *wndto;
|
---|
1006 | int retval = 0;
|
---|
1007 | POINT offset;
|
---|
1008 |
|
---|
1009 | SetLastError(0);
|
---|
1010 | if(lpPoints == NULL || cPoints == 0) {
|
---|
1011 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1012 | return 0;
|
---|
1013 | }
|
---|
1014 | if(hwndFrom)
|
---|
1015 | {
|
---|
1016 | wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
|
---|
1017 | if(!wndfrom) {
|
---|
1018 | dprintf(("MapWindowPoints, window %x not found", hwndFrom));
|
---|
1019 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1020 | return 0;
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 | else wndfrom = windowDesktop;
|
---|
1024 |
|
---|
1025 | if(hwndTo)
|
---|
1026 | {
|
---|
1027 | wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
|
---|
1028 | if(!wndto) {
|
---|
1029 | dprintf(("MapWindowPoints, window %x not found", hwndTo));
|
---|
1030 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1031 | return 0;
|
---|
1032 | }
|
---|
1033 | }
|
---|
1034 | else wndto = windowDesktop;
|
---|
1035 |
|
---|
1036 | if(wndto == wndfrom)
|
---|
1037 | return 0; //nothing to do
|
---|
1038 |
|
---|
1039 | dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
|
---|
1040 | WINPOS_GetWinOffset(wndfrom, wndto, &offset);
|
---|
1041 |
|
---|
1042 | for(int i=0;i<cPoints;i++)
|
---|
1043 | {
|
---|
1044 | lpPoints[i].x += offset.x;
|
---|
1045 | lpPoints[i].y += offset.y;
|
---|
1046 | }
|
---|
1047 | retval = ((LONG)offset.y << 16) | offset.x;
|
---|
1048 | return retval;
|
---|
1049 | }
|
---|
1050 | //******************************************************************************
|
---|
1051 | //******************************************************************************
|
---|
1052 | BOOL WIN32API ScreenToClient(HWND hwnd, LPPOINT pt)
|
---|
1053 | {
|
---|
1054 | Win32BaseWindow *wnd;
|
---|
1055 | PRECT rcl;
|
---|
1056 | BOOL rc;
|
---|
1057 |
|
---|
1058 | if(!hwnd) {
|
---|
1059 | return (TRUE);
|
---|
1060 | }
|
---|
1061 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1062 | if (!wnd) {
|
---|
1063 | dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
|
---|
1064 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1065 | return FALSE;
|
---|
1066 | }
|
---|
1067 | SetLastError(0);
|
---|
1068 | #ifdef DEBUG
|
---|
1069 | POINT tmp = *pt;
|
---|
1070 | #endif
|
---|
1071 | MapWindowPoints(0, hwnd, pt, 1);
|
---|
1072 | dprintf2(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
|
---|
1073 | return TRUE;
|
---|
1074 | }
|
---|
1075 | //******************************************************************************
|
---|
1076 | //******************************************************************************
|
---|
1077 | HWND WIN32API GetDesktopWindow(void)
|
---|
1078 | {
|
---|
1079 | HWND DesktopWindow = windowDesktop->getWindowHandle();
|
---|
1080 | dprintf2(("USER32: GetDesktopWindow, returned %x\n", DesktopWindow));
|
---|
1081 | return DesktopWindow;
|
---|
1082 | }
|
---|
1083 | //******************************************************************************
|
---|
1084 | //******************************************************************************
|
---|
1085 | HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
|
---|
1086 | {
|
---|
1087 | return FindWindowExA( NULL, NULL, lpszClass, lpszWindow );
|
---|
1088 | }
|
---|
1089 | //******************************************************************************
|
---|
1090 | //******************************************************************************
|
---|
1091 | HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
|
---|
1092 | {
|
---|
1093 | return FindWindowExW( NULL, NULL, lpClassName, lpWindowName );
|
---|
1094 | }
|
---|
1095 | //******************************************************************************
|
---|
1096 | //******************************************************************************
|
---|
1097 | HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
|
---|
1098 | {
|
---|
1099 | ATOM atom = 0;
|
---|
1100 |
|
---|
1101 | if (lpszClass)
|
---|
1102 | {
|
---|
1103 | /* If the atom doesn't exist, then no class */
|
---|
1104 | /* with this name exists either. */
|
---|
1105 | if (!(atom = GlobalFindAtomA( lpszClass )))
|
---|
1106 | {
|
---|
1107 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
|
---|
1108 | return 0;
|
---|
1109 | }
|
---|
1110 | }
|
---|
1111 | return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, (LPSTR)lpszWindow);
|
---|
1112 | }
|
---|
1113 | /*****************************************************************************
|
---|
1114 | * Name : HWND WIN32API FindWindowExW
|
---|
1115 | * Purpose : The FindWindowEx function retrieves the handle of a window whose
|
---|
1116 | * class name and window name match the specified strings. The
|
---|
1117 | * function searches child windows, beginning with the one following
|
---|
1118 | * the given child window.
|
---|
1119 | * Parameters: HWND hwndParent handle of parent window
|
---|
1120 | * HWND hwndChildAfter handle of a child window
|
---|
1121 | * LPCTSTR lpszClass address of class name
|
---|
1122 | * LPCTSTR lpszWindow address of window name
|
---|
1123 | * Variables :
|
---|
1124 | * Result : If the function succeeds, the return value is the handle of the
|
---|
1125 | * window that has the specified class and window names.
|
---|
1126 | * If the function fails, the return value is NULL. To get extended
|
---|
1127 | * error information, call GetLastError.
|
---|
1128 | * Remark :
|
---|
1129 | *
|
---|
1130 | *****************************************************************************/
|
---|
1131 |
|
---|
1132 | HWND WIN32API FindWindowExW(HWND hwndParent,
|
---|
1133 | HWND hwndChildAfter,
|
---|
1134 | LPCWSTR lpszClass,
|
---|
1135 | LPCWSTR lpszWindow)
|
---|
1136 | {
|
---|
1137 | ATOM atom = 0;
|
---|
1138 | char *buffer;
|
---|
1139 | HWND hwnd;
|
---|
1140 |
|
---|
1141 | if (lpszClass)
|
---|
1142 | {
|
---|
1143 | /* If the atom doesn't exist, then no class */
|
---|
1144 | /* with this name exists either. */
|
---|
1145 | if (!(atom = GlobalFindAtomW( lpszClass )))
|
---|
1146 | {
|
---|
1147 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
|
---|
1148 | return 0;
|
---|
1149 | }
|
---|
1150 | }
|
---|
1151 | buffer = HEAP_strdupWtoA( GetProcessHeap(), 0, lpszWindow );
|
---|
1152 | hwnd = Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, buffer);
|
---|
1153 | HeapFree( GetProcessHeap(), 0, buffer );
|
---|
1154 | return hwnd;
|
---|
1155 | }
|
---|
1156 | //******************************************************************************
|
---|
1157 | //******************************************************************************
|
---|
1158 | BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
|
---|
1159 | {
|
---|
1160 | dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
|
---|
1161 | // return OSLibWinFlashWindow(Win32BaseWindow::Win32ToOS2Handle(hwnd), fFlash);
|
---|
1162 | return 1;
|
---|
1163 | }
|
---|
1164 | //******************************************************************************
|
---|
1165 | //******************************************************************************
|
---|
1166 | BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
|
---|
1167 | BOOL repaint )
|
---|
1168 | {
|
---|
1169 | int flags = SWP_NOZORDER | SWP_NOACTIVATE;
|
---|
1170 |
|
---|
1171 | if (!repaint) flags |= SWP_NOREDRAW;
|
---|
1172 | dprintf(("MoveWindow: %x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
|
---|
1173 |
|
---|
1174 | return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
|
---|
1175 | }
|
---|
1176 | //******************************************************************************
|
---|
1177 | //******************************************************************************
|
---|
1178 | BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
|
---|
1179 | {
|
---|
1180 | Win32BaseWindow *wnd;
|
---|
1181 | PRECT rcl;
|
---|
1182 |
|
---|
1183 | if (!hwnd) {
|
---|
1184 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1185 | return (FALSE);
|
---|
1186 | }
|
---|
1187 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1188 | if (!wnd) {
|
---|
1189 | dprintf(("warning: ClientToScreen window %x not found!", hwnd));
|
---|
1190 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1191 | return (FALSE);
|
---|
1192 | }
|
---|
1193 | #ifdef DEBUG
|
---|
1194 | POINT tmp = *pt;
|
---|
1195 | #endif
|
---|
1196 | MapWindowPoints(hwnd, 0, pt, 1);
|
---|
1197 | dprintf2(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
|
---|
1198 |
|
---|
1199 | return TRUE;
|
---|
1200 | }
|
---|
1201 | //******************************************************************************
|
---|
1202 | //Note: count 0 is a legal parameter (verified in NT4)
|
---|
1203 | //******************************************************************************
|
---|
1204 | HDWP WIN32API BeginDeferWindowPos(int count)
|
---|
1205 | {
|
---|
1206 | HDWP handle;
|
---|
1207 | DWP *pDWP;
|
---|
1208 |
|
---|
1209 | if (count < 0)
|
---|
1210 | {
|
---|
1211 | dprintf(("USER32: BeginDeferWindowPos invalid param %d", count));
|
---|
1212 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1213 | return 0;
|
---|
1214 | }
|
---|
1215 | dprintf(("USER32: BeginDeferWindowPos %d", count));
|
---|
1216 | if(count == 0)
|
---|
1217 | count = 8; // change to any non-zero value
|
---|
1218 |
|
---|
1219 | handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS));
|
---|
1220 | if (!handle)
|
---|
1221 | return 0;
|
---|
1222 |
|
---|
1223 | pDWP = (DWP *) handle;
|
---|
1224 | pDWP->actualCount = 0;
|
---|
1225 | pDWP->suggestedCount = count;
|
---|
1226 | pDWP->valid = TRUE;
|
---|
1227 | pDWP->wMagic = DWP_MAGIC;
|
---|
1228 | pDWP->hwndParent = 0;
|
---|
1229 | return handle;
|
---|
1230 | }
|
---|
1231 | /***********************************************************************
|
---|
1232 | * DeferWindowPos (USER32.128)
|
---|
1233 | *
|
---|
1234 | * TODO: SvL: Does this need to be thread safe?
|
---|
1235 | *
|
---|
1236 | */
|
---|
1237 | HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
|
---|
1238 | INT x, INT y, INT cx, INT cy,
|
---|
1239 | UINT flags )
|
---|
1240 | {
|
---|
1241 | DWP *pDWP;
|
---|
1242 | int i;
|
---|
1243 | HDWP newhdwp = hdwp,retvalue;
|
---|
1244 | Win32BaseWindow *window;
|
---|
1245 |
|
---|
1246 | pDWP = (DWP *)hdwp;
|
---|
1247 | if (!pDWP) {
|
---|
1248 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1249 | return 0;
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | if (hwnd == GetDesktopWindow())
|
---|
1253 | return 0;
|
---|
1254 |
|
---|
1255 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1256 | if(!window) {
|
---|
1257 | dprintf(("DeferWindowPos, window %x not found", hwnd));
|
---|
1258 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1259 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
---|
1260 | return 0;
|
---|
1261 | }
|
---|
1262 |
|
---|
1263 | dprintf(("USER32: DeferWindowPos hdwp %x hwnd %x hwndAfter %x (%d,%d)(%d,%d) %x", hdwp, hwnd, hwndAfter,
|
---|
1264 | x, y, cx, cy, flags));
|
---|
1265 |
|
---|
1266 | /* Numega Bounds Checker Demo dislikes the following code.
|
---|
1267 | In fact, I've not been able to find any "same parent" requirement in any docu
|
---|
1268 | [AM 980509]
|
---|
1269 | */
|
---|
1270 | #if 0
|
---|
1271 | /* All the windows of a DeferWindowPos() must have the same parent */
|
---|
1272 | parent = pWnd->parent->hwndSelf;
|
---|
1273 | if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
|
---|
1274 | else if (parent != pDWP->hwndParent)
|
---|
1275 | {
|
---|
1276 | USER_HEAP_FREE( hdwp );
|
---|
1277 | retvalue = 0;
|
---|
1278 | goto END;
|
---|
1279 | }
|
---|
1280 | #endif
|
---|
1281 |
|
---|
1282 | for (i = 0; i < pDWP->actualCount; i++)
|
---|
1283 | {
|
---|
1284 | if (pDWP->winPos[i].hwnd == hwnd)
|
---|
1285 | {
|
---|
1286 | /* Merge with the other changes */
|
---|
1287 | if (!(flags & SWP_NOZORDER))
|
---|
1288 | {
|
---|
1289 | pDWP->winPos[i].hwndInsertAfter = hwndAfter;
|
---|
1290 | }
|
---|
1291 | if (!(flags & SWP_NOMOVE))
|
---|
1292 | {
|
---|
1293 | pDWP->winPos[i].x = x;
|
---|
1294 | pDWP->winPos[i].y = y;
|
---|
1295 | }
|
---|
1296 | if (!(flags & SWP_NOSIZE))
|
---|
1297 | {
|
---|
1298 | pDWP->winPos[i].cx = cx;
|
---|
1299 | pDWP->winPos[i].cy = cy;
|
---|
1300 | }
|
---|
1301 | pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
|
---|
1302 | SWP_NOZORDER | SWP_NOREDRAW |
|
---|
1303 | SWP_NOACTIVATE | SWP_NOCOPYBITS|
|
---|
1304 | SWP_NOOWNERZORDER);
|
---|
1305 | pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
|
---|
1306 | SWP_FRAMECHANGED);
|
---|
1307 | retvalue = hdwp;
|
---|
1308 | goto END;
|
---|
1309 | }
|
---|
1310 | }
|
---|
1311 | if (pDWP->actualCount >= pDWP->suggestedCount)
|
---|
1312 | {
|
---|
1313 | //DWP structure already contains WINDOWPOS, allocated with (count-1)
|
---|
1314 | //in BeginDeferWindowPos; pDWP->suggestedCount alloc increases it by one
|
---|
1315 | newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
|
---|
1316 | sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
|
---|
1317 | if (!newhdwp)
|
---|
1318 | {
|
---|
1319 | retvalue = 0;
|
---|
1320 | goto END;
|
---|
1321 | }
|
---|
1322 | pDWP = (DWP *) newhdwp;
|
---|
1323 | pDWP->suggestedCount++;
|
---|
1324 | }
|
---|
1325 | pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
|
---|
1326 | pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
|
---|
1327 | pDWP->winPos[pDWP->actualCount].x = x;
|
---|
1328 | pDWP->winPos[pDWP->actualCount].y = y;
|
---|
1329 | pDWP->winPos[pDWP->actualCount].cx = cx;
|
---|
1330 | pDWP->winPos[pDWP->actualCount].cy = cy;
|
---|
1331 | pDWP->winPos[pDWP->actualCount].flags = flags;
|
---|
1332 | pDWP->actualCount++;
|
---|
1333 | retvalue = newhdwp;
|
---|
1334 | END:
|
---|
1335 | return retvalue;
|
---|
1336 | }
|
---|
1337 | //******************************************************************************
|
---|
1338 | //******************************************************************************
|
---|
1339 | BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
|
---|
1340 | {
|
---|
1341 | DWP *pDWP;
|
---|
1342 | WINDOWPOS *winpos;
|
---|
1343 | BOOL res = TRUE;
|
---|
1344 | int i;
|
---|
1345 |
|
---|
1346 | pDWP = (DWP *) hdwp;
|
---|
1347 | if (!pDWP) {
|
---|
1348 | dprintf(("**EndDeferWindowPos invalid parameter\n"));
|
---|
1349 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1350 | return FALSE;
|
---|
1351 | }
|
---|
1352 | dprintf(("**EndDeferWindowPos for %d windows", pDWP->actualCount));
|
---|
1353 | for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
|
---|
1354 | {
|
---|
1355 | dprintf(("**EndDeferWindowPos %x (%d,%d) (%d,%d) %x", winpos->hwnd, winpos->x, winpos->y, winpos->x, winpos->cy, winpos->flags));
|
---|
1356 | if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
|
---|
1357 | winpos->x, winpos->y, winpos->cx,
|
---|
1358 | winpos->cy, winpos->flags )))
|
---|
1359 | break;
|
---|
1360 | }
|
---|
1361 | dprintf(("**EndDeferWindowPos DONE"));
|
---|
1362 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
---|
1363 | return res;
|
---|
1364 | }
|
---|
1365 | //******************************************************************************
|
---|
1366 | //******************************************************************************
|
---|
1367 | HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
|
---|
1368 | {
|
---|
1369 | dprintf(("USER32: ChildWindowFromPoint\n"));
|
---|
1370 | return ChildWindowFromPointEx(hwnd, pt, 0);
|
---|
1371 | }
|
---|
1372 | /*****************************************************************************
|
---|
1373 | * Name : HWND WIN32API ChildWindowFromPointEx
|
---|
1374 | * Purpose : pt: client coordinates
|
---|
1375 | * Parameters:
|
---|
1376 | * Variables :
|
---|
1377 | * Result : If the function succeeds, the return value is the window handle.
|
---|
1378 | * If the function fails, the return value is zero
|
---|
1379 | * Remark :
|
---|
1380 | * Status : COMPLETELY IMPLEMENTED AND TESTED
|
---|
1381 | *
|
---|
1382 | * Author : Rene Pronk [Sun, 1999/08/08 23:30]
|
---|
1383 | *****************************************************************************/
|
---|
1384 | HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
|
---|
1385 | {
|
---|
1386 | RECT rect;
|
---|
1387 | HWND hWnd;
|
---|
1388 |
|
---|
1389 | dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
|
---|
1390 | hwndParent, pt, uFlags));
|
---|
1391 |
|
---|
1392 | if (GetWindowRect (hwndParent, &rect) == 0) {
|
---|
1393 | // oops, invalid handle
|
---|
1394 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1395 | return NULL;
|
---|
1396 | }
|
---|
1397 |
|
---|
1398 | ClientToScreen(hwndParent, &pt);
|
---|
1399 | if (PtInRect (&rect, pt) == 0) {
|
---|
1400 | // point is outside window
|
---|
1401 | return NULL;
|
---|
1402 | }
|
---|
1403 |
|
---|
1404 |
|
---|
1405 | // get first child
|
---|
1406 | hWnd = GetWindow (hwndParent, GW_CHILD);
|
---|
1407 |
|
---|
1408 | while (hWnd != NULL) {
|
---|
1409 |
|
---|
1410 | // do I need to skip this window?
|
---|
1411 | if (((uFlags & CWP_SKIPINVISIBLE) &&
|
---|
1412 | (IsWindowVisible (hWnd) == FALSE)) ||
|
---|
1413 | ((uFlags & CWP_SKIPDISABLED) &&
|
---|
1414 | (IsWindowEnabled (hWnd) == FALSE)) ||
|
---|
1415 | ((uFlags & CWP_SKIPTRANSPARENT) &&
|
---|
1416 | (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
|
---|
1417 |
|
---|
1418 | {
|
---|
1419 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
---|
1420 | continue;
|
---|
1421 | }
|
---|
1422 |
|
---|
1423 | // is the point in this window's rect?
|
---|
1424 | GetWindowRect (hWnd, &rect);
|
---|
1425 | if (PtInRect (&rect,pt) == FALSE) {
|
---|
1426 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
---|
1427 | continue;
|
---|
1428 | }
|
---|
1429 |
|
---|
1430 | dprintf(("ChildWindowFromPointEx returned %x", hWnd));
|
---|
1431 | // found it!
|
---|
1432 | return hWnd;
|
---|
1433 | }
|
---|
1434 |
|
---|
1435 | // the point is in the parentwindow but the parentwindow has no child
|
---|
1436 | // at this coordinate
|
---|
1437 | dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
|
---|
1438 | return hwndParent;
|
---|
1439 | }
|
---|
1440 | //******************************************************************************
|
---|
1441 | //******************************************************************************
|
---|
1442 | BOOL WIN32API CloseWindow(HWND hwnd)
|
---|
1443 | {
|
---|
1444 | Win32BaseWindow *window;
|
---|
1445 |
|
---|
1446 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1447 | if(!window) {
|
---|
1448 | dprintf(("CloseWindow, window %x not found", hwnd));
|
---|
1449 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1450 | return 0;
|
---|
1451 | }
|
---|
1452 | dprintf(("CloseWindow %x\n", hwnd));
|
---|
1453 | return window->CloseWindow();
|
---|
1454 | }
|
---|
1455 | //******************************************************************************
|
---|
1456 | //TODO: Does this return handles of hidden or disabled windows?
|
---|
1457 | //******************************************************************************
|
---|
1458 | HWND WIN32API WindowFromPoint( POINT point)
|
---|
1459 | {
|
---|
1460 | HWND hwndOS2, hwnd;
|
---|
1461 | POINT wPoint;
|
---|
1462 |
|
---|
1463 | wPoint.x = point.x;
|
---|
1464 | wPoint.y = mapScreenY(point.y);
|
---|
1465 |
|
---|
1466 | hwndOS2 = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&wPoint);
|
---|
1467 | if(hwndOS2)
|
---|
1468 | {
|
---|
1469 | hwnd = Win32BaseWindow::OS2ToWin32Handle(hwndOS2);
|
---|
1470 | if(hwnd) {
|
---|
1471 | dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwnd));
|
---|
1472 | return hwnd;
|
---|
1473 | }
|
---|
1474 | }
|
---|
1475 | dprintf(("WindowFromPoint (%d,%d) %x->1\n", point.x, point.y, hwndOS2));
|
---|
1476 | return windowDesktop->getWindowHandle();
|
---|
1477 | }
|
---|
1478 | //******************************************************************************
|
---|
1479 | //******************************************************************************
|
---|
1480 | BOOL WIN32API IsWindowUnicode(HWND hwnd)
|
---|
1481 | {
|
---|
1482 | Win32BaseWindow *window;
|
---|
1483 |
|
---|
1484 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1485 | if(!window) {
|
---|
1486 | dprintf(("IsWindowUnicode, window %x not found", hwnd));
|
---|
1487 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1488 | return 0;
|
---|
1489 | }
|
---|
1490 | return window->IsWindowUnicode();
|
---|
1491 | }
|
---|
1492 | /***********************************************************************
|
---|
1493 | * SwitchToThisWindow (USER32.539)
|
---|
1494 | */
|
---|
1495 | DWORD WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore )
|
---|
1496 | {
|
---|
1497 | return ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
|
---|
1498 | }
|
---|
1499 | //******************************************************************************
|
---|
1500 | //******************************************************************************
|
---|
1501 | BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1502 | {
|
---|
1503 | return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
|
---|
1504 | }
|
---|
1505 | //******************************************************************************
|
---|
1506 | //******************************************************************************
|
---|
1507 | BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1508 | {
|
---|
1509 | Win32BaseWindow *window;
|
---|
1510 | BOOL rc = TRUE;
|
---|
1511 | ULONG henum;
|
---|
1512 | HWND hwndNext;
|
---|
1513 |
|
---|
1514 | if(lpfn == NULL) {
|
---|
1515 | dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
|
---|
1516 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1517 | return FALSE;
|
---|
1518 | }
|
---|
1519 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1520 | if(!window) {
|
---|
1521 | dprintf(("EnumChildWindows, window %x not found", hwnd));
|
---|
1522 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1523 | return FALSE;
|
---|
1524 | }
|
---|
1525 | return window->EnumChildWindows(lpfn, lParam);
|
---|
1526 | }
|
---|
1527 | //******************************************************************************
|
---|
1528 | //******************************************************************************
|
---|
1529 | BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1530 | {
|
---|
1531 | return windowDesktop->EnumWindows(lpfn, lParam);
|
---|
1532 | }
|
---|
1533 | //******************************************************************************
|
---|
1534 | //******************************************************************************
|
---|
1535 | UINT WIN32API ArrangeIconicWindows( HWND hwnd)
|
---|
1536 | {
|
---|
1537 | dprintf(("USER32: ArrangeIconicWindows %x", hwnd));
|
---|
1538 | return O32_ArrangeIconicWindows(Win32BaseWindow::Win32ToOS2Handle(hwnd));
|
---|
1539 | }
|
---|
1540 | //******************************************************************************
|
---|
1541 | //restores iconized window to previous size/position
|
---|
1542 | //******************************************************************************
|
---|
1543 | BOOL WIN32API OpenIcon(HWND hwnd)
|
---|
1544 | {
|
---|
1545 | dprintf(("USER32: OpenIcon"));
|
---|
1546 |
|
---|
1547 | if(!IsIconic(hwnd))
|
---|
1548 | return FALSE;
|
---|
1549 | ShowWindow(hwnd, SW_SHOWNORMAL);
|
---|
1550 | return TRUE;
|
---|
1551 | }
|
---|
1552 | //******************************************************************************
|
---|
1553 | //******************************************************************************
|
---|
1554 | BOOL WIN32API ShowOwnedPopups( HWND hwnd, BOOL arg2)
|
---|
1555 | {
|
---|
1556 | dprintf(("USER32: ShowOwnedPopups (OPEN32: todo) %x", hwnd));
|
---|
1557 | return O32_ShowOwnedPopups(Win32BaseWindow::Win32ToOS2Handle(hwnd), arg2);
|
---|
1558 | }
|
---|
1559 | //******************************************************************************
|
---|
1560 | //******************************************************************************
|
---|
1561 | HWND WIN32API GetForegroundWindow(void)
|
---|
1562 | {
|
---|
1563 | HWND hwnd;
|
---|
1564 |
|
---|
1565 | hwnd = Win32BaseWindow::OS2ToWin32Handle(OSLibWinQueryActiveWindow());
|
---|
1566 | dprintf(("USER32: GetForegroundWindow returned %x", hwnd));
|
---|
1567 | return hwnd;
|
---|
1568 | }
|
---|
1569 | //******************************************************************************
|
---|
1570 | //******************************************************************************
|
---|
1571 | HWND WIN32API GetLastActivePopup( HWND hWnd)
|
---|
1572 | {
|
---|
1573 | HWND hwnd;
|
---|
1574 |
|
---|
1575 | hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
|
---|
1576 |
|
---|
1577 | hwnd = Win32BaseWindow::OS2ToWin32Handle(O32_GetLastActivePopup(hWnd));
|
---|
1578 |
|
---|
1579 | dprintf(("GetLastActivePopup %x returned %x", hWnd, hwnd));
|
---|
1580 | return hwnd;
|
---|
1581 | }
|
---|
1582 | //******************************************************************************
|
---|
1583 | //******************************************************************************
|
---|
1584 | DWORD WIN32API GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
|
---|
1585 | {
|
---|
1586 | dprintf2(("USER32: GetWindowThreadProcessId"));
|
---|
1587 | hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
|
---|
1588 |
|
---|
1589 | return O32_GetWindowThreadProcessId(hWnd,lpdwProcessId);
|
---|
1590 | }
|
---|
1591 | //******************************************************************************
|
---|
1592 | //******************************************************************************
|
---|
1593 | DWORD WIN32API GetWindowContextHelpId(HWND hwnd)
|
---|
1594 | {
|
---|
1595 | Win32BaseWindow *window;
|
---|
1596 |
|
---|
1597 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1598 | if(!window) {
|
---|
1599 | dprintf(("GetWindowContextHelpId, window %x not found", hwnd));
|
---|
1600 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1601 | return 0;
|
---|
1602 | }
|
---|
1603 | dprintf(("GetWindowContextHelpId %x", hwnd));
|
---|
1604 | return window->getWindowContextHelpId();
|
---|
1605 | }
|
---|
1606 | //******************************************************************************
|
---|
1607 | //******************************************************************************
|
---|
1608 | BOOL WIN32API SetWindowContextHelpId(HWND hwnd, DWORD dwContextHelpId)
|
---|
1609 | {
|
---|
1610 | Win32BaseWindow *window;
|
---|
1611 |
|
---|
1612 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1613 | if(!window) {
|
---|
1614 | dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
|
---|
1615 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1616 | return 0;
|
---|
1617 | }
|
---|
1618 | dprintf(("SetWindowContextHelpId %x %d", hwnd, dwContextHelpId));
|
---|
1619 | window->setWindowContextHelpId(dwContextHelpId);
|
---|
1620 | return(TRUE);
|
---|
1621 | }
|
---|
1622 | //******************************************************************************
|
---|
1623 | //******************************************************************************
|
---|
1624 | HANDLE WINAPI GetPropA( HWND hwnd, LPCSTR str )
|
---|
1625 | {
|
---|
1626 | Win32BaseWindow *window;
|
---|
1627 |
|
---|
1628 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1629 | if(!window) {
|
---|
1630 | dprintf(("GetPropA, window %x not found", hwnd));
|
---|
1631 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1632 | return 0;
|
---|
1633 | }
|
---|
1634 | return window->getProp(str);
|
---|
1635 | }
|
---|
1636 | //******************************************************************************
|
---|
1637 | //******************************************************************************
|
---|
1638 | HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str )
|
---|
1639 | {
|
---|
1640 | LPSTR strA;
|
---|
1641 | HANDLE ret;
|
---|
1642 |
|
---|
1643 | if (!HIWORD(str)) return GetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
|
---|
1644 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
1645 | ret = GetPropA( hwnd, strA );
|
---|
1646 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
1647 | return ret;
|
---|
1648 | }
|
---|
1649 | //******************************************************************************
|
---|
1650 | //******************************************************************************
|
---|
1651 | BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle )
|
---|
1652 | {
|
---|
1653 | Win32BaseWindow *window;
|
---|
1654 |
|
---|
1655 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1656 | if(!window) {
|
---|
1657 | dprintf(("SetPropA, window %x not found", hwnd));
|
---|
1658 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1659 | return FALSE;
|
---|
1660 | }
|
---|
1661 | return window->setProp(str, handle);
|
---|
1662 | }
|
---|
1663 | //******************************************************************************
|
---|
1664 | //******************************************************************************
|
---|
1665 | BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle )
|
---|
1666 | {
|
---|
1667 | BOOL ret;
|
---|
1668 | LPSTR strA;
|
---|
1669 |
|
---|
1670 | if (!HIWORD(str))
|
---|
1671 | return SetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str), handle );
|
---|
1672 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
1673 | ret = SetPropA( hwnd, strA, handle );
|
---|
1674 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
1675 | return ret;
|
---|
1676 | }
|
---|
1677 | //******************************************************************************
|
---|
1678 | //******************************************************************************
|
---|
1679 | HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str )
|
---|
1680 | {
|
---|
1681 | Win32BaseWindow *window;
|
---|
1682 |
|
---|
1683 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1684 | if(!window) {
|
---|
1685 | dprintf(("RemovePropA, window %x not found", hwnd));
|
---|
1686 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1687 | return 0;
|
---|
1688 | }
|
---|
1689 | return window->removeProp(str);
|
---|
1690 | }
|
---|
1691 | //******************************************************************************
|
---|
1692 | //******************************************************************************
|
---|
1693 | HANDLE WINAPI RemovePropW( HWND hwnd, LPCWSTR str )
|
---|
1694 | {
|
---|
1695 | LPSTR strA;
|
---|
1696 | HANDLE ret;
|
---|
1697 |
|
---|
1698 | if (!HIWORD(str))
|
---|
1699 | return RemovePropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
|
---|
1700 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
1701 | ret = RemovePropA( hwnd, strA );
|
---|
1702 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
1703 | return ret;
|
---|
1704 | }
|
---|
1705 | //******************************************************************************
|
---|
1706 | //******************************************************************************
|
---|
1707 | INT WINAPI EnumPropsA( HWND hwnd, PROPENUMPROCA func )
|
---|
1708 | {
|
---|
1709 | return EnumPropsExA( hwnd, (PROPENUMPROCEXA)func, 0 );
|
---|
1710 | }
|
---|
1711 | //******************************************************************************
|
---|
1712 | //******************************************************************************
|
---|
1713 | INT WINAPI EnumPropsW( HWND hwnd, PROPENUMPROCW func )
|
---|
1714 | {
|
---|
1715 | return EnumPropsExW( hwnd, (PROPENUMPROCEXW)func, 0 );
|
---|
1716 | }
|
---|
1717 | //******************************************************************************
|
---|
1718 | //******************************************************************************
|
---|
1719 | INT WINAPI EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam)
|
---|
1720 | {
|
---|
1721 | Win32BaseWindow *window;
|
---|
1722 |
|
---|
1723 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1724 | if(!window) {
|
---|
1725 | dprintf(("EnumPropsExA, window %x not found", hwnd));
|
---|
1726 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1727 | return -1;
|
---|
1728 | }
|
---|
1729 | return window->enumPropsExA(func, lParam);
|
---|
1730 | }
|
---|
1731 | //******************************************************************************
|
---|
1732 | //******************************************************************************
|
---|
1733 | INT WINAPI EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
|
---|
1734 | {
|
---|
1735 | Win32BaseWindow *window;
|
---|
1736 |
|
---|
1737 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1738 | if(!window) {
|
---|
1739 | dprintf(("EnumPropsExA, window %x not found", hwnd));
|
---|
1740 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1741 | return -1;
|
---|
1742 | }
|
---|
1743 | return window->enumPropsExW(func, lParam);
|
---|
1744 | }
|
---|
1745 | //******************************************************************************
|
---|
1746 | //******************************************************************************
|
---|