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