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