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