1 | /* $Id: window.cpp,v 1.70 2000-06-08 18:10:12 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 | dprintf(("USER32: IsZoomed\n"));
|
---|
710 | return O32_IsZoomed(Win32BaseWindow::Win32ToOS2Handle(hwnd));
|
---|
711 | }
|
---|
712 | //******************************************************************************
|
---|
713 | //******************************************************************************
|
---|
714 | BOOL WIN32API LockWindowUpdate(HWND hwnd)
|
---|
715 | {
|
---|
716 | dprintf(("USER32: LockWindowUpdate\n"));
|
---|
717 | return O32_LockWindowUpdate(Win32BaseWindow::Win32ToOS2Handle(hwnd));
|
---|
718 | }
|
---|
719 | //******************************************************************************
|
---|
720 | //******************************************************************************
|
---|
721 | BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
|
---|
722 | {
|
---|
723 | Win32BaseWindow *window;
|
---|
724 |
|
---|
725 | if (hwnd)
|
---|
726 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
727 | else
|
---|
728 | window = windowDesktop;
|
---|
729 |
|
---|
730 | if(!window) {
|
---|
731 | dprintf(("GetWindowRect, window %x not found", hwnd));
|
---|
732 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
733 | return FALSE;
|
---|
734 | }
|
---|
735 | if(pRect == NULL) {
|
---|
736 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
737 | return FALSE;
|
---|
738 | }
|
---|
739 | *pRect = *window->getWindowRect();
|
---|
740 |
|
---|
741 | //convert from parent coordinates to screen (if necessary)
|
---|
742 | if(window->getParent()) {
|
---|
743 | MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
|
---|
744 | }
|
---|
745 |
|
---|
746 | dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
---|
747 | return TRUE;
|
---|
748 | }
|
---|
749 | //******************************************************************************
|
---|
750 | //******************************************************************************
|
---|
751 | int WIN32API GetWindowTextLengthA( HWND hwnd)
|
---|
752 | {
|
---|
753 | Win32BaseWindow *window;
|
---|
754 |
|
---|
755 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
756 | if(!window) {
|
---|
757 | dprintf(("GetWindowTextLength, window %x not found", hwnd));
|
---|
758 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
759 | return 0;
|
---|
760 | }
|
---|
761 | dprintf(("GetWindowTextLength %x", hwnd));
|
---|
762 | return window->GetWindowTextLength();
|
---|
763 | }
|
---|
764 | //******************************************************************************
|
---|
765 | //******************************************************************************
|
---|
766 | int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
|
---|
767 | {
|
---|
768 | Win32BaseWindow *window;
|
---|
769 | int rc;
|
---|
770 |
|
---|
771 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
772 | if(!window) {
|
---|
773 | dprintf(("GetWindowTextA, window %x not found", hwnd));
|
---|
774 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
775 | return 0;
|
---|
776 | }
|
---|
777 | rc = window->GetWindowTextA(lpsz, cch);
|
---|
778 | dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
|
---|
779 | return rc;
|
---|
780 | }
|
---|
781 | //******************************************************************************
|
---|
782 | //******************************************************************************
|
---|
783 | int WIN32API GetWindowTextLengthW( HWND hwnd)
|
---|
784 | {
|
---|
785 | dprintf(("USER32: GetWindowTextLengthW\n"));
|
---|
786 | return GetWindowTextLengthA(hwnd);
|
---|
787 | }
|
---|
788 | //******************************************************************************
|
---|
789 | //******************************************************************************
|
---|
790 | int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
|
---|
791 | {
|
---|
792 | Win32BaseWindow *window;
|
---|
793 |
|
---|
794 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
795 | if(!window) {
|
---|
796 | dprintf(("GetWindowTextW, window %x not found", hwnd));
|
---|
797 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
798 | return 0;
|
---|
799 | }
|
---|
800 | dprintf(("GetWindowTextW %x", hwnd));
|
---|
801 | return window->GetWindowTextW(lpsz, cch);
|
---|
802 | }
|
---|
803 | //******************************************************************************
|
---|
804 | //******************************************************************************
|
---|
805 | BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
|
---|
806 | {
|
---|
807 | Win32BaseWindow *window;
|
---|
808 |
|
---|
809 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
810 | if(!window) {
|
---|
811 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
---|
812 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
813 | return 0;
|
---|
814 | }
|
---|
815 | dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
|
---|
816 | return window->SetWindowTextA((LPSTR)lpsz);
|
---|
817 | }
|
---|
818 | //******************************************************************************
|
---|
819 | //******************************************************************************
|
---|
820 | BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
|
---|
821 | {
|
---|
822 | Win32BaseWindow *window;
|
---|
823 |
|
---|
824 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
825 | if(!window) {
|
---|
826 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
---|
827 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
828 | return 0;
|
---|
829 | }
|
---|
830 | dprintf(("SetWindowTextW %x", hwnd));
|
---|
831 | return window->SetWindowTextW((LPWSTR)lpsz);
|
---|
832 | }
|
---|
833 | /*******************************************************************
|
---|
834 | * InternalGetWindowText (USER32.326)
|
---|
835 | */
|
---|
836 | int WIN32API InternalGetWindowText(HWND hwnd,
|
---|
837 | LPWSTR lpString,
|
---|
838 | INT nMaxCount )
|
---|
839 | {
|
---|
840 | dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
|
---|
841 | hwnd,
|
---|
842 | lpString,
|
---|
843 | nMaxCount));
|
---|
844 |
|
---|
845 | return GetWindowTextW(hwnd,lpString,nMaxCount);
|
---|
846 | }
|
---|
847 | //******************************************************************************
|
---|
848 | //TODO: Correct?
|
---|
849 | //******************************************************************************
|
---|
850 | BOOL WIN32API SetForegroundWindow(HWND hwnd)
|
---|
851 | {
|
---|
852 | dprintf((" SetForegroundWindow %x", hwnd));
|
---|
853 |
|
---|
854 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
---|
855 | }
|
---|
856 | //******************************************************************************
|
---|
857 | //******************************************************************************
|
---|
858 | BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
|
---|
859 | {
|
---|
860 | HWND hwndWin32 = hwnd;
|
---|
861 | Win32BaseWindow *window;
|
---|
862 |
|
---|
863 | if (!pRect)
|
---|
864 | {
|
---|
865 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
866 | return FALSE;
|
---|
867 | }
|
---|
868 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
869 | if(!window) {
|
---|
870 | dprintf(("GetClientRect, window %x not found", hwnd));
|
---|
871 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
872 | return FALSE;
|
---|
873 | }
|
---|
874 | window->getClientRect(pRect);
|
---|
875 | dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
---|
876 | return TRUE;
|
---|
877 | }
|
---|
878 | //******************************************************************************
|
---|
879 | //******************************************************************************
|
---|
880 | BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
|
---|
881 | {
|
---|
882 | return AdjustWindowRectEx(rect, style, menu, 0);
|
---|
883 | }
|
---|
884 | //******************************************************************************
|
---|
885 | //******************************************************************************
|
---|
886 | BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
|
---|
887 | {
|
---|
888 | dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
|
---|
889 |
|
---|
890 | if(style == 0 && menu == FALSE && exStyle == 0) {
|
---|
891 | return TRUE; //nothing needs to be changed (VERIFIED in NT 4)
|
---|
892 | }
|
---|
893 | /* Correct the window style */
|
---|
894 | if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
|
---|
895 | style |= WS_CAPTION;
|
---|
896 |
|
---|
897 | //SvL: Include WS_POPUP -> otherwise HAS_THINFRAME is true for popup windows
|
---|
898 | // Also include WS_CHILD -> otherwise HAS_THICKFRAME doesn't work correctly
|
---|
899 | style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_POPUP);
|
---|
900 | exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
|
---|
901 | if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
|
---|
902 |
|
---|
903 | //Adjust rect outer (Win32BaseWindow::AdjustRectOuter)
|
---|
904 | if (HAS_THICKFRAME(style,exStyle))
|
---|
905 | InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
|
---|
906 | else
|
---|
907 | if (HAS_DLGFRAME(style,exStyle))
|
---|
908 | InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
|
---|
909 | else
|
---|
910 | if (HAS_THINFRAME(style))
|
---|
911 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
912 |
|
---|
913 | if ((style & WS_CAPTION) == WS_CAPTION)
|
---|
914 | {
|
---|
915 | if (exStyle & WS_EX_TOOLWINDOW)
|
---|
916 | rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
|
---|
917 | else
|
---|
918 | rect->top -= GetSystemMetrics(SM_CYCAPTION);
|
---|
919 | }
|
---|
920 |
|
---|
921 | if (menu)
|
---|
922 | rect->top -= GetSystemMetrics(SM_CYMENU);
|
---|
923 |
|
---|
924 | //Adjust rect inner (Win32BaseWindow::AdjustRectInner)
|
---|
925 | if (exStyle & WS_EX_CLIENTEDGE)
|
---|
926 | InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
|
---|
927 |
|
---|
928 | if (exStyle & WS_EX_STATICEDGE)
|
---|
929 | InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
930 |
|
---|
931 | if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
|
---|
932 | if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
|
---|
933 |
|
---|
934 | dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
|
---|
935 |
|
---|
936 | return TRUE;
|
---|
937 | }
|
---|
938 | //******************************************************************************
|
---|
939 | /* Coordinate Space and Transformation Functions */
|
---|
940 | //******************************************************************************
|
---|
941 | /*******************************************************************
|
---|
942 | * WINPOS_GetWinOffset
|
---|
943 | *
|
---|
944 | * Calculate the offset between the origin of the two windows. Used
|
---|
945 | * to implement MapWindowPoints.
|
---|
946 | */
|
---|
947 | static void WINPOS_GetWinOffset( Win32BaseWindow *wndFrom, Win32BaseWindow *wndTo,
|
---|
948 | POINT *offset )
|
---|
949 | {
|
---|
950 | Win32BaseWindow *window;
|
---|
951 |
|
---|
952 | offset->x = offset->y = 0;
|
---|
953 |
|
---|
954 | /* Translate source window origin to screen coords */
|
---|
955 | if(wndFrom != windowDesktop)
|
---|
956 | {
|
---|
957 | window = wndFrom;
|
---|
958 | while(window)
|
---|
959 | {
|
---|
960 | offset->x += window->getClientRectPtr()->left + window->getWindowRect()->left;
|
---|
961 | offset->y += window->getClientRectPtr()->top + window->getWindowRect()->top;
|
---|
962 | window = window->getParent();
|
---|
963 | }
|
---|
964 | }
|
---|
965 |
|
---|
966 | /* Translate origin to destination window coords */
|
---|
967 | if(wndTo != windowDesktop)
|
---|
968 | {
|
---|
969 | window = wndTo;
|
---|
970 | while(window)
|
---|
971 | {
|
---|
972 | offset->x -= window->getClientRectPtr()->left + window->getWindowRect()->left;
|
---|
973 | offset->y -= window->getClientRectPtr()->top + window->getWindowRect()->top;
|
---|
974 | window = window->getParent();
|
---|
975 | }
|
---|
976 | }
|
---|
977 | }
|
---|
978 | //******************************************************************************
|
---|
979 | //******************************************************************************
|
---|
980 | int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
|
---|
981 | UINT cPoints)
|
---|
982 | {
|
---|
983 | Win32BaseWindow *wndfrom, *wndto;
|
---|
984 | int retval = 0;
|
---|
985 | POINT offset;
|
---|
986 |
|
---|
987 | SetLastError(0);
|
---|
988 | if(lpPoints == NULL || cPoints == 0) {
|
---|
989 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
990 | return 0;
|
---|
991 | }
|
---|
992 | if(hwndFrom)
|
---|
993 | {
|
---|
994 | wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
|
---|
995 | if(!wndfrom) {
|
---|
996 | dprintf(("MapWindowPoints, window %x not found", hwndFrom));
|
---|
997 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
998 | return 0;
|
---|
999 | }
|
---|
1000 | }
|
---|
1001 | else wndfrom = windowDesktop;
|
---|
1002 |
|
---|
1003 | if(hwndTo)
|
---|
1004 | {
|
---|
1005 | wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
|
---|
1006 | if(!wndto) {
|
---|
1007 | dprintf(("MapWindowPoints, window %x not found", hwndTo));
|
---|
1008 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1009 | return 0;
|
---|
1010 | }
|
---|
1011 | }
|
---|
1012 | else wndto = windowDesktop;
|
---|
1013 |
|
---|
1014 | if(wndto == wndfrom)
|
---|
1015 | return 0; //nothing to do
|
---|
1016 |
|
---|
1017 | dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
|
---|
1018 | WINPOS_GetWinOffset(wndfrom, wndto, &offset);
|
---|
1019 |
|
---|
1020 | for(int i=0;i<cPoints;i++)
|
---|
1021 | {
|
---|
1022 | lpPoints[i].x += offset.x;
|
---|
1023 | lpPoints[i].y += offset.y;
|
---|
1024 | }
|
---|
1025 | retval = ((LONG)offset.y << 16) | offset.x;
|
---|
1026 | return retval;
|
---|
1027 | }
|
---|
1028 | //******************************************************************************
|
---|
1029 | //******************************************************************************
|
---|
1030 | BOOL WIN32API ScreenToClient(HWND hwnd, LPPOINT pt)
|
---|
1031 | {
|
---|
1032 | Win32BaseWindow *wnd;
|
---|
1033 | PRECT rcl;
|
---|
1034 | BOOL rc;
|
---|
1035 |
|
---|
1036 | if(!hwnd) {
|
---|
1037 | return (TRUE);
|
---|
1038 | }
|
---|
1039 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1040 | if (!wnd) {
|
---|
1041 | dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
|
---|
1042 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1043 | return FALSE;
|
---|
1044 | }
|
---|
1045 | SetLastError(0);
|
---|
1046 | #ifdef DEBUG
|
---|
1047 | POINT tmp = *pt;
|
---|
1048 | #endif
|
---|
1049 | MapWindowPoints(0, hwnd, pt, 1);
|
---|
1050 | dprintf2(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
|
---|
1051 | return TRUE;
|
---|
1052 | }
|
---|
1053 | //******************************************************************************
|
---|
1054 | //******************************************************************************
|
---|
1055 | HWND WIN32API GetDesktopWindow(void)
|
---|
1056 | {
|
---|
1057 | HWND DesktopWindow = windowDesktop->getWindowHandle();
|
---|
1058 | dprintf2(("USER32: GetDesktopWindow, returned %x\n", DesktopWindow));
|
---|
1059 | return DesktopWindow;
|
---|
1060 | }
|
---|
1061 | //******************************************************************************
|
---|
1062 | //******************************************************************************
|
---|
1063 | HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
|
---|
1064 | {
|
---|
1065 | return FindWindowExA( NULL, NULL, lpszClass, lpszWindow );
|
---|
1066 | }
|
---|
1067 | //******************************************************************************
|
---|
1068 | //******************************************************************************
|
---|
1069 | HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
|
---|
1070 | {
|
---|
1071 | return FindWindowExW( NULL, NULL, lpClassName, lpWindowName );
|
---|
1072 | }
|
---|
1073 | //******************************************************************************
|
---|
1074 | //******************************************************************************
|
---|
1075 | HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
|
---|
1076 | {
|
---|
1077 | ATOM atom = 0;
|
---|
1078 |
|
---|
1079 | if (lpszClass)
|
---|
1080 | {
|
---|
1081 | /* If the atom doesn't exist, then no class */
|
---|
1082 | /* with this name exists either. */
|
---|
1083 | if (!(atom = GlobalFindAtomA( lpszClass )))
|
---|
1084 | {
|
---|
1085 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
|
---|
1086 | return 0;
|
---|
1087 | }
|
---|
1088 | }
|
---|
1089 | return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, (LPSTR)lpszWindow);
|
---|
1090 | }
|
---|
1091 | /*****************************************************************************
|
---|
1092 | * Name : HWND WIN32API FindWindowExW
|
---|
1093 | * Purpose : The FindWindowEx function retrieves the handle of a window whose
|
---|
1094 | * class name and window name match the specified strings. The
|
---|
1095 | * function searches child windows, beginning with the one following
|
---|
1096 | * the given child window.
|
---|
1097 | * Parameters: HWND hwndParent handle of parent window
|
---|
1098 | * HWND hwndChildAfter handle of a child window
|
---|
1099 | * LPCTSTR lpszClass address of class name
|
---|
1100 | * LPCTSTR lpszWindow address of window name
|
---|
1101 | * Variables :
|
---|
1102 | * Result : If the function succeeds, the return value is the handle of the
|
---|
1103 | * window that has the specified class and window names.
|
---|
1104 | * If the function fails, the return value is NULL. To get extended
|
---|
1105 | * error information, call GetLastError.
|
---|
1106 | * Remark :
|
---|
1107 | *
|
---|
1108 | *****************************************************************************/
|
---|
1109 |
|
---|
1110 | HWND WIN32API FindWindowExW(HWND hwndParent,
|
---|
1111 | HWND hwndChildAfter,
|
---|
1112 | LPCWSTR lpszClass,
|
---|
1113 | LPCWSTR lpszWindow)
|
---|
1114 | {
|
---|
1115 | ATOM atom = 0;
|
---|
1116 | char *buffer;
|
---|
1117 | HWND hwnd;
|
---|
1118 |
|
---|
1119 | if (lpszClass)
|
---|
1120 | {
|
---|
1121 | /* If the atom doesn't exist, then no class */
|
---|
1122 | /* with this name exists either. */
|
---|
1123 | if (!(atom = GlobalFindAtomW( lpszClass )))
|
---|
1124 | {
|
---|
1125 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
|
---|
1126 | return 0;
|
---|
1127 | }
|
---|
1128 | }
|
---|
1129 | buffer = HEAP_strdupWtoA( GetProcessHeap(), 0, lpszWindow );
|
---|
1130 | hwnd = Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, buffer);
|
---|
1131 | HeapFree( GetProcessHeap(), 0, buffer );
|
---|
1132 | return hwnd;
|
---|
1133 | }
|
---|
1134 | //******************************************************************************
|
---|
1135 | //******************************************************************************
|
---|
1136 | BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
|
---|
1137 | {
|
---|
1138 | dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
|
---|
1139 | // return OSLibWinFlashWindow(Win32BaseWindow::Win32ToOS2Handle(hwnd), fFlash);
|
---|
1140 | return 1;
|
---|
1141 | }
|
---|
1142 | //******************************************************************************
|
---|
1143 | //******************************************************************************
|
---|
1144 | BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
|
---|
1145 | BOOL repaint )
|
---|
1146 | {
|
---|
1147 | int flags = SWP_NOZORDER | SWP_NOACTIVATE;
|
---|
1148 |
|
---|
1149 | if (!repaint) flags |= SWP_NOREDRAW;
|
---|
1150 | dprintf(("MoveWindow: %x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
|
---|
1151 |
|
---|
1152 | return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
|
---|
1153 | }
|
---|
1154 | //******************************************************************************
|
---|
1155 | //******************************************************************************
|
---|
1156 | BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
|
---|
1157 | {
|
---|
1158 | Win32BaseWindow *wnd;
|
---|
1159 | PRECT rcl;
|
---|
1160 |
|
---|
1161 | if (!hwnd) {
|
---|
1162 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1163 | return (FALSE);
|
---|
1164 | }
|
---|
1165 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
---|
1166 | if (!wnd) {
|
---|
1167 | dprintf(("warning: ClientToScreen window %x not found!", hwnd));
|
---|
1168 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1169 | return (FALSE);
|
---|
1170 | }
|
---|
1171 | #ifdef DEBUG
|
---|
1172 | POINT tmp = *pt;
|
---|
1173 | #endif
|
---|
1174 | MapWindowPoints(hwnd, 0, pt, 1);
|
---|
1175 | dprintf2(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
|
---|
1176 |
|
---|
1177 | return TRUE;
|
---|
1178 | }
|
---|
1179 | //******************************************************************************
|
---|
1180 | //******************************************************************************
|
---|
1181 | HDWP WIN32API BeginDeferWindowPos(int count)
|
---|
1182 | {
|
---|
1183 | HDWP handle;
|
---|
1184 | DWP *pDWP;
|
---|
1185 |
|
---|
1186 | if (count <= 0)
|
---|
1187 | {
|
---|
1188 | dprintf(("USER32: BeginDeferWindowPos invalid param %d", count));
|
---|
1189 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1190 | return 0;
|
---|
1191 | }
|
---|
1192 | dprintf(("USER32: BeginDeferWindowPos %d", count));
|
---|
1193 | handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS) );
|
---|
1194 | if (!handle)
|
---|
1195 | return 0;
|
---|
1196 |
|
---|
1197 | pDWP = (DWP *) handle;
|
---|
1198 | pDWP->actualCount = 0;
|
---|
1199 | pDWP->suggestedCount = count;
|
---|
1200 | pDWP->valid = TRUE;
|
---|
1201 | pDWP->wMagic = DWP_MAGIC;
|
---|
1202 | pDWP->hwndParent = 0;
|
---|
1203 | return handle;
|
---|
1204 | }
|
---|
1205 | /***********************************************************************
|
---|
1206 | * DeferWindowPos (USER32.128)
|
---|
1207 | */
|
---|
1208 | HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
|
---|
1209 | INT x, INT y, INT cx, INT cy,
|
---|
1210 | UINT flags )
|
---|
1211 | {
|
---|
1212 | DWP *pDWP;
|
---|
1213 | int i;
|
---|
1214 | HDWP newhdwp = hdwp,retvalue;
|
---|
1215 | Win32BaseWindow *window;
|
---|
1216 |
|
---|
1217 | pDWP = (DWP *)hdwp;
|
---|
1218 | if (!pDWP) {
|
---|
1219 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1220 | return 0;
|
---|
1221 | }
|
---|
1222 |
|
---|
1223 | if (hwnd == GetDesktopWindow())
|
---|
1224 | return 0;
|
---|
1225 |
|
---|
1226 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1227 | if(!window) {
|
---|
1228 | dprintf(("DeferWindowPos, window %x not found", hwnd));
|
---|
1229 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1230 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
---|
1231 | return 0;
|
---|
1232 | }
|
---|
1233 |
|
---|
1234 | dprintf(("USER32: DeferWindowPos hdwp %x hwnd %x hwndAfter %x (%d,%d)(%d,%d) %x", hdwp, hwnd, hwndAfter,
|
---|
1235 | x, y, cx, cy, flags));
|
---|
1236 |
|
---|
1237 | /* Numega Bounds Checker Demo dislikes the following code.
|
---|
1238 | In fact, I've not been able to find any "same parent" requirement in any docu
|
---|
1239 | [AM 980509]
|
---|
1240 | */
|
---|
1241 | #if 0
|
---|
1242 | /* All the windows of a DeferWindowPos() must have the same parent */
|
---|
1243 | parent = pWnd->parent->hwndSelf;
|
---|
1244 | if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
|
---|
1245 | else if (parent != pDWP->hwndParent)
|
---|
1246 | {
|
---|
1247 | USER_HEAP_FREE( hdwp );
|
---|
1248 | retvalue = 0;
|
---|
1249 | goto END;
|
---|
1250 | }
|
---|
1251 | #endif
|
---|
1252 |
|
---|
1253 | for (i = 0; i < pDWP->actualCount; i++)
|
---|
1254 | {
|
---|
1255 | if (pDWP->winPos[i].hwnd == hwnd)
|
---|
1256 | {
|
---|
1257 | /* Merge with the other changes */
|
---|
1258 | if (!(flags & SWP_NOZORDER))
|
---|
1259 | {
|
---|
1260 | pDWP->winPos[i].hwndInsertAfter = hwndAfter;
|
---|
1261 | }
|
---|
1262 | if (!(flags & SWP_NOMOVE))
|
---|
1263 | {
|
---|
1264 | pDWP->winPos[i].x = x;
|
---|
1265 | pDWP->winPos[i].y = y;
|
---|
1266 | }
|
---|
1267 | if (!(flags & SWP_NOSIZE))
|
---|
1268 | {
|
---|
1269 | pDWP->winPos[i].cx = cx;
|
---|
1270 | pDWP->winPos[i].cy = cy;
|
---|
1271 | }
|
---|
1272 | pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
|
---|
1273 | SWP_NOZORDER | SWP_NOREDRAW |
|
---|
1274 | SWP_NOACTIVATE | SWP_NOCOPYBITS|
|
---|
1275 | SWP_NOOWNERZORDER);
|
---|
1276 | pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
|
---|
1277 | SWP_FRAMECHANGED);
|
---|
1278 | retvalue = hdwp;
|
---|
1279 | goto END;
|
---|
1280 | }
|
---|
1281 | }
|
---|
1282 | if (pDWP->actualCount >= pDWP->suggestedCount)
|
---|
1283 | {
|
---|
1284 | newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
|
---|
1285 | sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
|
---|
1286 | if (!newhdwp)
|
---|
1287 | {
|
---|
1288 | retvalue = 0;
|
---|
1289 | goto END;
|
---|
1290 | }
|
---|
1291 | pDWP = (DWP *) newhdwp;
|
---|
1292 | pDWP->suggestedCount++;
|
---|
1293 | }
|
---|
1294 | pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
|
---|
1295 | pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
|
---|
1296 | pDWP->winPos[pDWP->actualCount].x = x;
|
---|
1297 | pDWP->winPos[pDWP->actualCount].y = y;
|
---|
1298 | pDWP->winPos[pDWP->actualCount].cx = cx;
|
---|
1299 | pDWP->winPos[pDWP->actualCount].cy = cy;
|
---|
1300 | pDWP->winPos[pDWP->actualCount].flags = flags;
|
---|
1301 | pDWP->actualCount++;
|
---|
1302 | retvalue = newhdwp;
|
---|
1303 | END:
|
---|
1304 | return retvalue;
|
---|
1305 | }
|
---|
1306 | //******************************************************************************
|
---|
1307 | //******************************************************************************
|
---|
1308 | BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
|
---|
1309 | {
|
---|
1310 | DWP *pDWP;
|
---|
1311 | WINDOWPOS *winpos;
|
---|
1312 | BOOL res = TRUE;
|
---|
1313 | int i;
|
---|
1314 |
|
---|
1315 | pDWP = (DWP *) hdwp;
|
---|
1316 | if (!pDWP) {
|
---|
1317 | dprintf(("**EndDeferWindowPos invalid parameter\n"));
|
---|
1318 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1319 | return FALSE;
|
---|
1320 | }
|
---|
1321 | dprintf(("**EndDeferWindowPos for %d windows", pDWP->actualCount));
|
---|
1322 | for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
|
---|
1323 | {
|
---|
1324 | dprintf(("**EndDeferWindowPos %x (%d,%d) (%d,%d) %x", winpos->hwnd, winpos->x, winpos->y, winpos->x, winpos->cy, winpos->flags));
|
---|
1325 | if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
|
---|
1326 | winpos->x, winpos->y, winpos->cx,
|
---|
1327 | winpos->cy, winpos->flags )))
|
---|
1328 | break;
|
---|
1329 | }
|
---|
1330 | dprintf(("**EndDeferWindowPos DONE"));
|
---|
1331 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
---|
1332 | return res;
|
---|
1333 | }
|
---|
1334 | //******************************************************************************
|
---|
1335 | //******************************************************************************
|
---|
1336 | HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
|
---|
1337 | {
|
---|
1338 | dprintf(("USER32: ChildWindowFromPoint\n"));
|
---|
1339 | return ChildWindowFromPointEx(hwnd, pt, 0);
|
---|
1340 | }
|
---|
1341 | /*****************************************************************************
|
---|
1342 | * Name : HWND WIN32API ChildWindowFromPointEx
|
---|
1343 | * Purpose : pt: client coordinates
|
---|
1344 | * Parameters:
|
---|
1345 | * Variables :
|
---|
1346 | * Result : If the function succeeds, the return value is the window handle.
|
---|
1347 | * If the function fails, the return value is zero
|
---|
1348 | * Remark :
|
---|
1349 | * Status : FULLY IMPLEMENTED AND TESTED
|
---|
1350 | *
|
---|
1351 | * Author : Rene Pronk [Sun, 1999/08/08 23:30]
|
---|
1352 | *****************************************************************************/
|
---|
1353 | HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
|
---|
1354 | {
|
---|
1355 | RECT rect;
|
---|
1356 | HWND hWnd;
|
---|
1357 |
|
---|
1358 | dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
|
---|
1359 | hwndParent, pt, uFlags));
|
---|
1360 |
|
---|
1361 | if (GetWindowRect (hwndParent, &rect) == 0) {
|
---|
1362 | // oops, invalid handle
|
---|
1363 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1364 | return NULL;
|
---|
1365 | }
|
---|
1366 |
|
---|
1367 | ClientToScreen(hwndParent, &pt);
|
---|
1368 | if (PtInRect (&rect, pt) == 0) {
|
---|
1369 | // point is outside window
|
---|
1370 | return NULL;
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 |
|
---|
1374 | // get first child
|
---|
1375 | hWnd = GetWindow (hwndParent, GW_CHILD);
|
---|
1376 |
|
---|
1377 | while (hWnd != NULL) {
|
---|
1378 |
|
---|
1379 | // do I need to skip this window?
|
---|
1380 | if (((uFlags & CWP_SKIPINVISIBLE) &&
|
---|
1381 | (IsWindowVisible (hWnd) == FALSE)) ||
|
---|
1382 | ((uFlags & CWP_SKIPDISABLED) &&
|
---|
1383 | (IsWindowEnabled (hWnd) == FALSE)) ||
|
---|
1384 | ((uFlags & CWP_SKIPTRANSPARENT) &&
|
---|
1385 | (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
|
---|
1386 |
|
---|
1387 | {
|
---|
1388 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
---|
1389 | continue;
|
---|
1390 | }
|
---|
1391 |
|
---|
1392 | // is the point in this window's rect?
|
---|
1393 | GetWindowRect (hWnd, &rect);
|
---|
1394 | if (PtInRect (&rect,pt) == FALSE) {
|
---|
1395 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
---|
1396 | continue;
|
---|
1397 | }
|
---|
1398 |
|
---|
1399 | dprintf(("ChildWindowFromPointEx returned %x", hWnd));
|
---|
1400 | // found it!
|
---|
1401 | return hWnd;
|
---|
1402 | }
|
---|
1403 |
|
---|
1404 | // the point is in the parentwindow but the parentwindow has no child
|
---|
1405 | // at this coordinate
|
---|
1406 | dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
|
---|
1407 | return hwndParent;
|
---|
1408 | }
|
---|
1409 | //******************************************************************************
|
---|
1410 | //******************************************************************************
|
---|
1411 | BOOL WIN32API CloseWindow(HWND hwnd)
|
---|
1412 | {
|
---|
1413 | Win32BaseWindow *window;
|
---|
1414 |
|
---|
1415 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1416 | if(!window) {
|
---|
1417 | dprintf(("CloseWindow, window %x not found", hwnd));
|
---|
1418 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1419 | return 0;
|
---|
1420 | }
|
---|
1421 | dprintf(("CloseWindow %x\n", hwnd));
|
---|
1422 | return window->CloseWindow();
|
---|
1423 | }
|
---|
1424 | //******************************************************************************
|
---|
1425 | //TODO: Does this return handles of hidden or disabled windows?
|
---|
1426 | //******************************************************************************
|
---|
1427 | HWND WIN32API WindowFromPoint( POINT point)
|
---|
1428 | {
|
---|
1429 | HWND hwndOS2, hwnd;
|
---|
1430 | POINT wPoint;
|
---|
1431 |
|
---|
1432 | wPoint.x = point.x;
|
---|
1433 | wPoint.y = mapScreenY(point.y);
|
---|
1434 |
|
---|
1435 | hwndOS2 = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&wPoint);
|
---|
1436 | if(hwndOS2)
|
---|
1437 | {
|
---|
1438 | hwnd = Win32BaseWindow::OS2ToWin32Handle(hwndOS2);
|
---|
1439 | if(hwnd) {
|
---|
1440 | dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwnd));
|
---|
1441 | return hwnd;
|
---|
1442 | }
|
---|
1443 | }
|
---|
1444 | dprintf(("WindowFromPoint (%d,%d) %x->1\n", point.x, point.y, hwndOS2));
|
---|
1445 | return windowDesktop->getWindowHandle();
|
---|
1446 | }
|
---|
1447 | //******************************************************************************
|
---|
1448 | //******************************************************************************
|
---|
1449 | BOOL WIN32API IsWindowUnicode(HWND hwnd)
|
---|
1450 | {
|
---|
1451 | Win32BaseWindow *window;
|
---|
1452 |
|
---|
1453 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1454 | if(!window) {
|
---|
1455 | dprintf(("IsWindowUnicode, window %x not found", hwnd));
|
---|
1456 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1457 | return 0;
|
---|
1458 | }
|
---|
1459 | return window->IsWindowUnicode();
|
---|
1460 | }
|
---|
1461 | /***********************************************************************
|
---|
1462 | * SwitchToThisWindow (USER32.539)
|
---|
1463 | */
|
---|
1464 | DWORD WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore )
|
---|
1465 | {
|
---|
1466 | return ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
|
---|
1467 | }
|
---|
1468 | //******************************************************************************
|
---|
1469 | //******************************************************************************
|
---|
1470 | BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1471 | {
|
---|
1472 | return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
|
---|
1473 | }
|
---|
1474 | //******************************************************************************
|
---|
1475 | //******************************************************************************
|
---|
1476 | BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1477 | {
|
---|
1478 | Win32BaseWindow *window;
|
---|
1479 | BOOL rc = TRUE;
|
---|
1480 | ULONG henum;
|
---|
1481 | HWND hwndNext;
|
---|
1482 |
|
---|
1483 | if(lpfn == NULL) {
|
---|
1484 | dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
|
---|
1485 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1486 | return FALSE;
|
---|
1487 | }
|
---|
1488 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1489 | if(!window) {
|
---|
1490 | dprintf(("EnumChildWindows, window %x not found", hwnd));
|
---|
1491 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1492 | return FALSE;
|
---|
1493 | }
|
---|
1494 | return window->EnumChildWindows(lpfn, lParam);
|
---|
1495 | }
|
---|
1496 | //******************************************************************************
|
---|
1497 | //******************************************************************************
|
---|
1498 | BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
---|
1499 | {
|
---|
1500 | return windowDesktop->EnumWindows(lpfn, lParam);
|
---|
1501 | }
|
---|
1502 | //******************************************************************************
|
---|
1503 | //******************************************************************************
|
---|
1504 | UINT WIN32API ArrangeIconicWindows( HWND hwnd)
|
---|
1505 | {
|
---|
1506 | dprintf(("USER32: ArrangeIconicWindows %x", hwnd));
|
---|
1507 | return O32_ArrangeIconicWindows(Win32BaseWindow::Win32ToOS2Handle(hwnd));
|
---|
1508 | }
|
---|
1509 | //******************************************************************************
|
---|
1510 | //restores iconized window to previous size/position
|
---|
1511 | //******************************************************************************
|
---|
1512 | BOOL WIN32API OpenIcon(HWND hwnd)
|
---|
1513 | {
|
---|
1514 | dprintf(("USER32: OpenIcon"));
|
---|
1515 |
|
---|
1516 | if(!IsIconic(hwnd))
|
---|
1517 | return FALSE;
|
---|
1518 | ShowWindow(hwnd, SW_SHOWNORMAL);
|
---|
1519 | return TRUE;
|
---|
1520 | }
|
---|
1521 | //******************************************************************************
|
---|
1522 | //******************************************************************************
|
---|
1523 | BOOL WIN32API ShowOwnedPopups( HWND hwnd, BOOL arg2)
|
---|
1524 | {
|
---|
1525 | dprintf(("USER32: ShowOwnedPopups (OPEN32: todo) %x", hwnd));
|
---|
1526 | return O32_ShowOwnedPopups(Win32BaseWindow::Win32ToOS2Handle(hwnd), arg2);
|
---|
1527 | }
|
---|
1528 | //******************************************************************************
|
---|
1529 | //******************************************************************************
|
---|
1530 | HWND WIN32API GetForegroundWindow(void)
|
---|
1531 | {
|
---|
1532 | HWND hwnd;
|
---|
1533 |
|
---|
1534 | hwnd = Win32BaseWindow::OS2ToWin32Handle(OSLibWinQueryActiveWindow());
|
---|
1535 | dprintf(("USER32: GetForegroundWindow returned %x", hwnd));
|
---|
1536 | return hwnd;
|
---|
1537 | }
|
---|
1538 | //******************************************************************************
|
---|
1539 | //******************************************************************************
|
---|
1540 | HWND WIN32API GetLastActivePopup( HWND hWnd)
|
---|
1541 | {
|
---|
1542 | HWND hwnd;
|
---|
1543 |
|
---|
1544 | hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
|
---|
1545 |
|
---|
1546 | hwnd = Win32BaseWindow::OS2ToWin32Handle(O32_GetLastActivePopup(hWnd));
|
---|
1547 |
|
---|
1548 | dprintf(("GetLastActivePopup %x returned %x", hWnd, hwnd));
|
---|
1549 | return hwnd;
|
---|
1550 | }
|
---|
1551 | //******************************************************************************
|
---|
1552 | //******************************************************************************
|
---|
1553 | DWORD WIN32API GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
|
---|
1554 | {
|
---|
1555 | dprintf2(("USER32: GetWindowThreadProcessId"));
|
---|
1556 | hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
|
---|
1557 |
|
---|
1558 | return O32_GetWindowThreadProcessId(hWnd,lpdwProcessId);
|
---|
1559 | }
|
---|
1560 | //******************************************************************************
|
---|
1561 | //******************************************************************************
|
---|
1562 | DWORD WIN32API GetWindowContextHelpId(HWND hwnd)
|
---|
1563 | {
|
---|
1564 | Win32BaseWindow *window;
|
---|
1565 |
|
---|
1566 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1567 | if(!window) {
|
---|
1568 | dprintf(("GetWindowContextHelpId, window %x not found", hwnd));
|
---|
1569 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1570 | return 0;
|
---|
1571 | }
|
---|
1572 | dprintf(("GetWindowContextHelpId %x", hwnd));
|
---|
1573 | return window->getWindowContextHelpId();
|
---|
1574 | }
|
---|
1575 | //******************************************************************************
|
---|
1576 | //******************************************************************************
|
---|
1577 | BOOL WIN32API SetWindowContextHelpId(HWND hwnd, DWORD dwContextHelpId)
|
---|
1578 | {
|
---|
1579 | Win32BaseWindow *window;
|
---|
1580 |
|
---|
1581 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1582 | if(!window) {
|
---|
1583 | dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
|
---|
1584 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1585 | return 0;
|
---|
1586 | }
|
---|
1587 | dprintf(("SetWindowContextHelpId %x %d", hwnd, dwContextHelpId));
|
---|
1588 | window->setWindowContextHelpId(dwContextHelpId);
|
---|
1589 | return(TRUE);
|
---|
1590 | }
|
---|
1591 | //******************************************************************************
|
---|
1592 | //******************************************************************************
|
---|
1593 | HANDLE WINAPI GetPropA( HWND hwnd, LPCSTR str )
|
---|
1594 | {
|
---|
1595 | Win32BaseWindow *window;
|
---|
1596 |
|
---|
1597 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1598 | if(!window) {
|
---|
1599 | dprintf(("GetPropA, window %x not found", hwnd));
|
---|
1600 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1601 | return 0;
|
---|
1602 | }
|
---|
1603 | return window->getProp(str);
|
---|
1604 | }
|
---|
1605 | //******************************************************************************
|
---|
1606 | //******************************************************************************
|
---|
1607 | HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str )
|
---|
1608 | {
|
---|
1609 | LPSTR strA;
|
---|
1610 | HANDLE ret;
|
---|
1611 |
|
---|
1612 | if (!HIWORD(str)) return GetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
|
---|
1613 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
1614 | ret = GetPropA( hwnd, strA );
|
---|
1615 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
1616 | return ret;
|
---|
1617 | }
|
---|
1618 | //******************************************************************************
|
---|
1619 | //******************************************************************************
|
---|
1620 | BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle )
|
---|
1621 | {
|
---|
1622 | Win32BaseWindow *window;
|
---|
1623 |
|
---|
1624 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1625 | if(!window) {
|
---|
1626 | dprintf(("SetPropA, window %x not found", hwnd));
|
---|
1627 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1628 | return FALSE;
|
---|
1629 | }
|
---|
1630 | return window->setProp(str, handle);
|
---|
1631 | }
|
---|
1632 | //******************************************************************************
|
---|
1633 | //******************************************************************************
|
---|
1634 | BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle )
|
---|
1635 | {
|
---|
1636 | BOOL ret;
|
---|
1637 | LPSTR strA;
|
---|
1638 |
|
---|
1639 | if (!HIWORD(str))
|
---|
1640 | return SetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str), handle );
|
---|
1641 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
1642 | ret = SetPropA( hwnd, strA, handle );
|
---|
1643 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
1644 | return ret;
|
---|
1645 | }
|
---|
1646 | //******************************************************************************
|
---|
1647 | //******************************************************************************
|
---|
1648 | HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str )
|
---|
1649 | {
|
---|
1650 | Win32BaseWindow *window;
|
---|
1651 |
|
---|
1652 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1653 | if(!window) {
|
---|
1654 | dprintf(("RemovePropA, window %x not found", hwnd));
|
---|
1655 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1656 | return 0;
|
---|
1657 | }
|
---|
1658 | return window->removeProp(str);
|
---|
1659 | }
|
---|
1660 | //******************************************************************************
|
---|
1661 | //******************************************************************************
|
---|
1662 | HANDLE WINAPI RemovePropW( HWND hwnd, LPCWSTR str )
|
---|
1663 | {
|
---|
1664 | LPSTR strA;
|
---|
1665 | HANDLE ret;
|
---|
1666 |
|
---|
1667 | if (!HIWORD(str))
|
---|
1668 | return RemovePropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
|
---|
1669 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
1670 | ret = RemovePropA( hwnd, strA );
|
---|
1671 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
1672 | return ret;
|
---|
1673 | }
|
---|
1674 | //******************************************************************************
|
---|
1675 | //******************************************************************************
|
---|
1676 | INT WINAPI EnumPropsA( HWND hwnd, PROPENUMPROCA func )
|
---|
1677 | {
|
---|
1678 | return EnumPropsExA( hwnd, (PROPENUMPROCEXA)func, 0 );
|
---|
1679 | }
|
---|
1680 | //******************************************************************************
|
---|
1681 | //******************************************************************************
|
---|
1682 | INT WINAPI EnumPropsW( HWND hwnd, PROPENUMPROCW func )
|
---|
1683 | {
|
---|
1684 | return EnumPropsExW( hwnd, (PROPENUMPROCEXW)func, 0 );
|
---|
1685 | }
|
---|
1686 | //******************************************************************************
|
---|
1687 | //******************************************************************************
|
---|
1688 | INT WINAPI EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam)
|
---|
1689 | {
|
---|
1690 | Win32BaseWindow *window;
|
---|
1691 |
|
---|
1692 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1693 | if(!window) {
|
---|
1694 | dprintf(("EnumPropsExA, window %x not found", hwnd));
|
---|
1695 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1696 | return -1;
|
---|
1697 | }
|
---|
1698 | return window->enumPropsExA(func, lParam);
|
---|
1699 | }
|
---|
1700 | //******************************************************************************
|
---|
1701 | //******************************************************************************
|
---|
1702 | INT WINAPI EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
|
---|
1703 | {
|
---|
1704 | Win32BaseWindow *window;
|
---|
1705 |
|
---|
1706 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
1707 | if(!window) {
|
---|
1708 | dprintf(("EnumPropsExA, window %x not found", hwnd));
|
---|
1709 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
1710 | return -1;
|
---|
1711 | }
|
---|
1712 | return window->enumPropsExW(func, lParam);
|
---|
1713 | }
|
---|
1714 | //******************************************************************************
|
---|
1715 | //******************************************************************************
|
---|