[10496] | 1 | /* $Id: window.cpp,v 1.140 2004-03-09 10:06:15 sandervl Exp $ */
|
---|
[2469] | 2 | /*
|
---|
| 3 | * Win32 window apis for OS/2
|
---|
| 4 | *
|
---|
[5404] | 5 | * Copyright 1999-2001 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
[2469] | 6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
---|
| 7 | * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
|
---|
| 8 | *
|
---|
[3662] | 9 | * Parts based on Wine Windows code (windows\win.c, windows\property.c, windows\winpos.c)
|
---|
[2469] | 10 | *
|
---|
[3662] | 11 | * Copyright 1993, 1994, 1995 Alexandre Julliard
|
---|
| 12 | * 1995, 1996, 1999 Alex Korobka
|
---|
[2469] | 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)
|
---|
[4463] | 18 | * TODO: ShowOwnedPopups needs to be tested
|
---|
| 19 | * GetLastActivePopup needs to be rewritten
|
---|
[2469] | 20 | *
|
---|
| 21 | */
|
---|
| 22 |
|
---|
[6972] | 23 | #include <odin.h>
|
---|
| 24 | #include <odinwrap.h>
|
---|
| 25 | #include <os2sel.h>
|
---|
| 26 |
|
---|
[2469] | 27 | #include <os2win.h>
|
---|
| 28 | #include <misc.h>
|
---|
| 29 | #include <string.h>
|
---|
| 30 | #include <stdio.h>
|
---|
[21916] | 31 | #include "win32wbase.h"
|
---|
| 32 | #include "win32wmdiclient.h"
|
---|
| 33 | #include "win32wdesktop.h"
|
---|
[2469] | 34 | #include "win32dlg.h"
|
---|
[21916] | 35 | #include "oslibwin.h"
|
---|
| 36 | #include "oslibgdi.h"
|
---|
[2469] | 37 | #include "user32.h"
|
---|
| 38 | #include "winicon.h"
|
---|
[10145] | 39 | #include "pmwindow.h"
|
---|
[5137] | 40 | #include "oslibmsg.h"
|
---|
[21916] | 41 | #include <win/winpos.h>
|
---|
| 42 | #include <win/win.h>
|
---|
[2956] | 43 | #include <heapstring.h>
|
---|
[4848] | 44 | #include <winuser32.h>
|
---|
[5713] | 45 | #include "hook.h"
|
---|
[10316] | 46 | #include <wprocess.h>
|
---|
[10450] | 47 | #include <custombuild.h>
|
---|
[2469] | 48 |
|
---|
[2852] | 49 | #define DBG_LOCALLOG DBG_window
|
---|
[2803] | 50 | #include "dbglocal.h"
|
---|
| 51 |
|
---|
[6972] | 52 | ODINDEBUGCHANNEL(USER32-WINDOW)
|
---|
| 53 |
|
---|
[21916] | 54 | #ifdef __cplusplus
|
---|
| 55 | extern "C" {
|
---|
| 56 | #endif
|
---|
[6972] | 57 |
|
---|
[2469] | 58 | //******************************************************************************
|
---|
| 59 | //******************************************************************************
|
---|
[7875] | 60 | HWND WIN32API CreateWindowExA(DWORD exStyle,
|
---|
| 61 | LPCSTR className,
|
---|
| 62 | LPCSTR windowName,
|
---|
| 63 | DWORD style,
|
---|
| 64 | INT x,
|
---|
| 65 | INT y,
|
---|
| 66 | INT width,
|
---|
| 67 | INT height,
|
---|
| 68 | HWND parent,
|
---|
| 69 | HMENU menu,
|
---|
| 70 | HINSTANCE instance,
|
---|
| 71 | LPVOID data )
|
---|
[2469] | 72 | {
|
---|
| 73 | Win32BaseWindow *window;
|
---|
| 74 | ATOM classAtom;
|
---|
| 75 | CREATESTRUCTA cs;
|
---|
| 76 | char tmpClass[20];
|
---|
| 77 |
|
---|
| 78 | if(exStyle & WS_EX_MDICHILD)
|
---|
| 79 | return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
---|
| 80 |
|
---|
| 81 | /* Find the class atom */
|
---|
| 82 | if (!(classAtom = GlobalFindAtomA(className)))
|
---|
| 83 | {
|
---|
| 84 | if (!HIWORD(className))
|
---|
| 85 | dprintf(("CreateWindowEx32A: bad class name %04x\n",LOWORD(className)));
|
---|
| 86 | else
|
---|
| 87 | dprintf(("CreateWindowEx32A: bad class name '%s'\n", className));
|
---|
| 88 |
|
---|
| 89 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 90 | return 0;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[8940] | 93 | // if the pointer to the classname string has the high word cleared,
|
---|
| 94 | // then it's not a pointer but a number for one of the builtin classes
|
---|
[2469] | 95 | if (!HIWORD(className))
|
---|
| 96 | {
|
---|
| 97 | sprintf(tmpClass,"#%d", (int) className);
|
---|
| 98 | className = tmpClass;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /* Create the window */
|
---|
| 102 | cs.lpCreateParams = data;
|
---|
| 103 | cs.hInstance = instance;
|
---|
| 104 | cs.hMenu = menu;
|
---|
| 105 | cs.hwndParent = parent;
|
---|
| 106 | cs.x = x;
|
---|
| 107 | cs.y = y;
|
---|
| 108 | cs.cx = width;
|
---|
| 109 | cs.cy = height;
|
---|
| 110 | cs.style = style;
|
---|
| 111 | cs.lpszName = windowName;
|
---|
| 112 | cs.lpszClass = className;
|
---|
| 113 | cs.dwExStyle = exStyle;
|
---|
[10450] | 114 |
|
---|
| 115 | HOOK_CallOdinHookA(HODIN_PREWINDOWCREATEDA, 0, (DWORD)&cs);
|
---|
| 116 |
|
---|
[2469] | 117 | if(HIWORD(className)) {
|
---|
[10496] | 118 | dprintf(("CreateWindowExA: window %s class %s parent %x (%d,%d) (%d,%d), %x %x menu=%x", windowName, className, parent, x, y, width, height, style, exStyle, menu));
|
---|
[2469] | 119 | }
|
---|
[10496] | 120 | else dprintf(("CreateWindowExA: window %s class %d parent %x (%d,%d) (%d,%d), %x %x menu=%x", windowName, className, parent, x, y, width, height, style, exStyle, menu));
|
---|
[2469] | 121 |
|
---|
[21916] | 122 | if(!stricmp(className, MDICLIENTCLASSNAMEA)) {
|
---|
[2469] | 123 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, FALSE);
|
---|
| 124 | }
|
---|
| 125 | else
|
---|
[21916] | 126 | if(!stricmp((char *) className, DIALOG_CLASS_NAMEA))
|
---|
[2469] | 127 | {
|
---|
| 128 | DLG_TEMPLATE dlgTemplate = {0};
|
---|
| 129 | dlgTemplate.style = cs.style;
|
---|
| 130 | dlgTemplate.exStyle = cs.dwExStyle;
|
---|
| 131 | dlgTemplate.x = cs.x;
|
---|
| 132 | dlgTemplate.y = cs.y;
|
---|
| 133 | dlgTemplate.cx = cs.cx;
|
---|
| 134 | dlgTemplate.cy = cs.cy;
|
---|
| 135 | dlgTemplate.className = cs.lpszClass;
|
---|
| 136 | dlgTemplate.caption = cs.lpszName;
|
---|
| 137 | window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
|
---|
| 138 | (LPCSTR) &dlgTemplate,
|
---|
| 139 | cs.hwndParent,
|
---|
| 140 | NULL,
|
---|
| 141 | (LPARAM) data,
|
---|
| 142 | FALSE);
|
---|
| 143 | }
|
---|
| 144 | else {
|
---|
| 145 | window = new Win32BaseWindow( &cs, classAtom, FALSE );
|
---|
| 146 | }
|
---|
| 147 | if(window == NULL)
|
---|
| 148 | {
|
---|
| 149 | dprintf(("Win32BaseWindow creation failed!!"));
|
---|
| 150 | return 0;
|
---|
| 151 | }
|
---|
| 152 | if(GetLastError() != 0)
|
---|
| 153 | {
|
---|
| 154 | dprintf(("Win32BaseWindow error found!!"));
|
---|
[5935] | 155 | RELEASE_WNDOBJ(window);
|
---|
[2469] | 156 | delete window;
|
---|
| 157 | return 0;
|
---|
| 158 | }
|
---|
[5935] | 159 | HWND hwnd = window->getWindowHandle();
|
---|
[21916] | 160 |
|
---|
[6972] | 161 | // set myself as last active popup / window
|
---|
| 162 | window->setLastActive( hwnd );
|
---|
[21916] | 163 |
|
---|
[5935] | 164 | RELEASE_WNDOBJ(window);
|
---|
| 165 | return hwnd;
|
---|
[2469] | 166 | }
|
---|
| 167 | //******************************************************************************
|
---|
| 168 | //******************************************************************************
|
---|
[7875] | 169 | HWND WIN32API CreateWindowExW(DWORD exStyle,
|
---|
| 170 | LPCWSTR className,
|
---|
| 171 | LPCWSTR windowName,
|
---|
| 172 | DWORD style,
|
---|
| 173 | INT x,
|
---|
| 174 | INT y,
|
---|
| 175 | INT width,
|
---|
| 176 | INT height,
|
---|
| 177 | HWND parent,
|
---|
| 178 | HMENU menu,
|
---|
| 179 | HINSTANCE instance,
|
---|
| 180 | LPVOID data )
|
---|
[2469] | 181 | {
|
---|
| 182 | Win32BaseWindow *window;
|
---|
| 183 | ATOM classAtom;
|
---|
| 184 | CREATESTRUCTA cs;
|
---|
| 185 | WCHAR tmpClassW[20];
|
---|
| 186 |
|
---|
| 187 | if(exStyle & WS_EX_MDICHILD)
|
---|
| 188 | return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
---|
| 189 |
|
---|
| 190 | /* Find the class atom */
|
---|
[4585] | 191 | if (!(classAtom = GlobalFindAtomW(className)))
|
---|
[2469] | 192 | {
|
---|
[4585] | 193 | if (!HIWORD(className))
|
---|
| 194 | dprintf(("CreateWindowEx32W: bad class name %04x",LOWORD(className)));
|
---|
| 195 | else
|
---|
[5406] | 196 | dprintf(("CreateWindowEx32W: bad class name '%ls'", className));
|
---|
[2469] | 197 |
|
---|
[4585] | 198 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 199 | return 0;
|
---|
[2469] | 200 | }
|
---|
[5977] | 201 | #ifdef DEBUG
|
---|
[2469] | 202 | if(HIWORD(className)) {
|
---|
[7248] | 203 | dprintf(("CreateWindowExW: class %ls name %ls parent %x (%d,%d) (%d,%d), %x %x menu=%x", className, HIWORD(windowName) ? windowName : NULL, parent, x, y, width, height, style, exStyle, menu));
|
---|
[2469] | 204 | }
|
---|
[7248] | 205 | else dprintf(("CreateWindowExW: class %d name %ls parent %x (%d,%d) (%d,%d), %x %x menu=%x", className, HIWORD(windowName) ? windowName : NULL, parent, x, y, width, height, style, exStyle, menu));
|
---|
[5977] | 206 | #endif
|
---|
[8941] | 207 | // if the pointer to the classname string has the high word cleared,
|
---|
| 208 | // then it's not a pointer but a number for one of the builtin classes
|
---|
[4585] | 209 | if (!HIWORD(className))
|
---|
| 210 | {
|
---|
| 211 | wsprintfW(tmpClassW, (LPCWSTR)L"#%d", (int) className);
|
---|
| 212 | className = tmpClassW;
|
---|
| 213 | }
|
---|
| 214 |
|
---|
[2469] | 215 | /* Create the window */
|
---|
| 216 | cs.lpCreateParams = data;
|
---|
| 217 | cs.hInstance = instance;
|
---|
| 218 | cs.hMenu = menu;
|
---|
| 219 | cs.hwndParent = parent;
|
---|
| 220 | cs.x = x;
|
---|
| 221 | cs.y = y;
|
---|
| 222 | cs.cx = width;
|
---|
| 223 | cs.cy = height;
|
---|
| 224 | cs.style = style;
|
---|
| 225 | cs.lpszName = (LPSTR)windowName;
|
---|
| 226 | cs.lpszClass = (LPSTR)className;
|
---|
| 227 | cs.dwExStyle = exStyle;
|
---|
| 228 |
|
---|
| 229 | if(!lstrcmpiW(className, (LPWSTR)MDICLIENTCLASSNAMEW)) {
|
---|
| 230 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, TRUE);
|
---|
| 231 | }
|
---|
| 232 | else
|
---|
| 233 | if(!lstrcmpiW(className, (LPWSTR)DIALOG_CLASS_NAMEW))
|
---|
| 234 | {
|
---|
| 235 | DLG_TEMPLATE dlgTemplate = {0};
|
---|
| 236 | dlgTemplate.style = cs.style;
|
---|
| 237 | dlgTemplate.exStyle = cs.dwExStyle;
|
---|
| 238 | dlgTemplate.x = cs.x;
|
---|
| 239 | dlgTemplate.y = cs.y;
|
---|
| 240 | dlgTemplate.cx = cs.cx;
|
---|
| 241 | dlgTemplate.cy = cs.cy;
|
---|
| 242 | dlgTemplate.className = cs.lpszClass;
|
---|
| 243 | dlgTemplate.caption = cs.lpszName;
|
---|
| 244 | window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
|
---|
| 245 | (LPCSTR) &dlgTemplate,
|
---|
| 246 | cs.hwndParent,
|
---|
| 247 | NULL,
|
---|
| 248 | (LPARAM) data,
|
---|
| 249 | TRUE);
|
---|
| 250 | }
|
---|
| 251 | else {
|
---|
| 252 | window = new Win32BaseWindow( &cs, classAtom, TRUE );
|
---|
| 253 | }
|
---|
| 254 | if(window == NULL)
|
---|
| 255 | {
|
---|
| 256 | dprintf(("Win32BaseWindow creation failed!!"));
|
---|
| 257 | return 0;
|
---|
| 258 | }
|
---|
| 259 | if(GetLastError() != 0)
|
---|
| 260 | {
|
---|
| 261 | dprintf(("Win32BaseWindow error found!!"));
|
---|
[5935] | 262 | RELEASE_WNDOBJ(window);
|
---|
[2469] | 263 | delete window;
|
---|
| 264 | return 0;
|
---|
| 265 | }
|
---|
[5935] | 266 | HWND hwnd = window->getWindowHandle();
|
---|
[21916] | 267 |
|
---|
[6972] | 268 | // set myself as last active popup / window
|
---|
| 269 | window->setLastActive( hwnd );
|
---|
[21916] | 270 |
|
---|
[5935] | 271 | RELEASE_WNDOBJ(window);
|
---|
| 272 | return hwnd;
|
---|
[2469] | 273 | }
|
---|
| 274 | //******************************************************************************
|
---|
| 275 | //******************************************************************************
|
---|
[7875] | 276 | BOOL WIN32API DestroyWindow(HWND hwnd)
|
---|
[2469] | 277 | {
|
---|
| 278 | Win32BaseWindow *window;
|
---|
[5935] | 279 | BOOL ret;
|
---|
[2469] | 280 |
|
---|
| 281 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 282 | if(!window) {
|
---|
| 283 | dprintf(("DestroyWindow, window %x not found", hwnd));
|
---|
| 284 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 285 | return 0;
|
---|
| 286 | }
|
---|
[5935] | 287 | ret = window->DestroyWindow();
|
---|
| 288 | RELEASE_WNDOBJ(window);
|
---|
| 289 | return ret;
|
---|
[2469] | 290 | }
|
---|
| 291 | //******************************************************************************
|
---|
| 292 | //******************************************************************************
|
---|
[7875] | 293 | HWND WIN32API SetActiveWindow(HWND hwnd)
|
---|
[2469] | 294 | {
|
---|
| 295 | Win32BaseWindow *window;
|
---|
[5935] | 296 | HWND hwndActive;
|
---|
[2469] | 297 |
|
---|
| 298 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 299 | if(!window) {
|
---|
| 300 | dprintf(("SetActiveWindow, window %x not found", hwnd));
|
---|
| 301 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 302 | return 0;
|
---|
| 303 | }
|
---|
[5935] | 304 | hwndActive = window->SetActiveWindow();
|
---|
[21916] | 305 |
|
---|
[6972] | 306 | // check last active popup window
|
---|
| 307 | if (hwndActive)
|
---|
| 308 | {
|
---|
| 309 | // TODO:
|
---|
| 310 | // set last active popup window to the ancestor window
|
---|
| 311 | dprintf(("support for last active popup incorrectly implemented"));
|
---|
| 312 | }
|
---|
[21916] | 313 |
|
---|
[5935] | 314 | RELEASE_WNDOBJ(window);
|
---|
| 315 | return hwndActive;
|
---|
[2469] | 316 | }
|
---|
| 317 | //******************************************************************************
|
---|
[5060] | 318 | //Note: does not set last error if no parent (verified in NT4, SP6)
|
---|
[2469] | 319 | //******************************************************************************
|
---|
[6981] | 320 | HWND WIN32API GetParent(HWND hwnd)
|
---|
[2469] | 321 | {
|
---|
| 322 | Win32BaseWindow *window;
|
---|
[5935] | 323 | HWND hwndParent;
|
---|
[2469] | 324 |
|
---|
| 325 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 326 | if(!window) {
|
---|
| 327 | dprintf(("GetParent, window %x not found", hwnd));
|
---|
| 328 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 329 | return 0;
|
---|
| 330 | }
|
---|
[5060] | 331 | dprintf2(("GetParent %x", hwnd));
|
---|
[5935] | 332 | hwndParent = window->GetParent();
|
---|
| 333 | RELEASE_WNDOBJ(window);
|
---|
| 334 | return hwndParent;
|
---|
[2469] | 335 | }
|
---|
| 336 | //******************************************************************************
|
---|
| 337 | //******************************************************************************
|
---|
[7875] | 338 | HWND WIN32API SetParent(HWND hwndChild, HWND hwndNewParent)
|
---|
[2469] | 339 | {
|
---|
[5935] | 340 | Win32BaseWindow *window;
|
---|
| 341 | HWND hwndOldParent;
|
---|
[2469] | 342 |
|
---|
| 343 | window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
|
---|
| 344 | if(!window) {
|
---|
| 345 | dprintf(("SetParent, window %x not found", hwndChild));
|
---|
| 346 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 347 | return 0;
|
---|
| 348 | }
|
---|
[3663] | 349 | if(hwndNewParent == HWND_DESKTOP) {
|
---|
[5060] | 350 | hwndNewParent = GetDesktopWindow();
|
---|
[3942] | 351 | }
|
---|
[3663] | 352 | else {
|
---|
[5935] | 353 | if(!IsWindow(hwndNewParent)) {
|
---|
| 354 | RELEASE_WNDOBJ(window);
|
---|
[4463] | 355 | dprintf(("SetParent, parent %x not found", hwndNewParent));
|
---|
| 356 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 357 | return 0;
|
---|
[3663] | 358 | }
|
---|
[4463] | 359 | }
|
---|
[2469] | 360 | dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
|
---|
[5935] | 361 | hwndOldParent = window->SetParent(hwndNewParent);
|
---|
| 362 | RELEASE_WNDOBJ(window);
|
---|
| 363 | return hwndOldParent;
|
---|
[2469] | 364 | }
|
---|
| 365 | //******************************************************************************
|
---|
| 366 | //******************************************************************************
|
---|
[7875] | 367 | BOOL WIN32API IsChild(HWND hwndParent, HWND hwnd)
|
---|
[2469] | 368 | {
|
---|
| 369 | Win32BaseWindow *window;
|
---|
[5935] | 370 | BOOL fIsChild;
|
---|
[2469] | 371 |
|
---|
| 372 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 373 | if(!window) {
|
---|
[3373] | 374 | dprintf(("IsChild %x, window %x not found", hwndParent, hwnd));
|
---|
[2469] | 375 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 376 | return 0;
|
---|
| 377 | }
|
---|
| 378 | dprintf(("IsChild %x %x", hwndParent, hwnd));
|
---|
[5935] | 379 | fIsChild = window->IsChild(hwndParent);
|
---|
| 380 | RELEASE_WNDOBJ(window);
|
---|
| 381 | return fIsChild;
|
---|
[2469] | 382 | }
|
---|
| 383 | //******************************************************************************
|
---|
| 384 | //******************************************************************************
|
---|
[7875] | 385 | HWND WIN32API GetTopWindow(HWND hwnd)
|
---|
[2469] | 386 | {
|
---|
| 387 | Win32BaseWindow *window;
|
---|
[4203] | 388 | HWND hwndTop;
|
---|
[2469] | 389 |
|
---|
[3679] | 390 | if(hwnd == HWND_DESKTOP) {
|
---|
[5935] | 391 | windowDesktop->addRef();
|
---|
[5685] | 392 | window = windowDesktop;
|
---|
[2469] | 393 | }
|
---|
[3679] | 394 | else {
|
---|
[4463] | 395 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 396 | if(!window) {
|
---|
| 397 | dprintf(("GetTopWindow, window %x not found", hwnd));
|
---|
| 398 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 399 | return 0;
|
---|
[5685] | 400 | }
|
---|
[3679] | 401 | }
|
---|
[4203] | 402 | hwndTop = window->GetTopWindow();
|
---|
| 403 | dprintf2(("GetTopWindow %x returned %x", hwnd, hwndTop));
|
---|
[5935] | 404 | RELEASE_WNDOBJ(window);
|
---|
[4203] | 405 | return hwndTop;
|
---|
[2469] | 406 | }
|
---|
| 407 | //******************************************************************************
|
---|
| 408 | //******************************************************************************
|
---|
[7875] | 409 | BOOL WIN32API IsIconic(HWND hwnd)
|
---|
[2469] | 410 | {
|
---|
| 411 | Win32BaseWindow *window;
|
---|
[5935] | 412 | BOOL fIsIconic;
|
---|
[2469] | 413 |
|
---|
| 414 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 415 | if(!window) {
|
---|
| 416 | dprintf(("IsIconic, window %x not found", hwnd));
|
---|
| 417 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
[2521] | 418 | return FALSE;
|
---|
[2469] | 419 | }
|
---|
[5935] | 420 | fIsIconic = window->IsWindowIconic();
|
---|
| 421 | dprintf(("IsIconic %x returned %d", hwnd, fIsIconic));
|
---|
| 422 | RELEASE_WNDOBJ(window);
|
---|
| 423 | return fIsIconic;
|
---|
[2469] | 424 | }
|
---|
| 425 | //******************************************************************************
|
---|
| 426 | //******************************************************************************
|
---|
[7875] | 427 | HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
|
---|
[2469] | 428 | {
|
---|
| 429 | Win32BaseWindow *window;
|
---|
[5935] | 430 | HWND hwndRelated;
|
---|
[2469] | 431 |
|
---|
| 432 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 433 | if(!window) {
|
---|
| 434 | dprintf(("GetWindow, window %x not found", hwnd));
|
---|
| 435 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 436 | return 0;
|
---|
| 437 | }
|
---|
[5935] | 438 | hwndRelated = window->GetWindow(uCmd);
|
---|
| 439 | RELEASE_WNDOBJ(window);
|
---|
| 440 | return hwndRelated;
|
---|
[2469] | 441 | }
|
---|
[21334] | 442 |
|
---|
| 443 | /******************************************************************************
|
---|
| 444 | * GetWindowInfo (USER32.@)
|
---|
| 445 | *
|
---|
| 446 | * Note: tests show that Windows doesn't check cbSize of the structure.
|
---|
| 447 | */
|
---|
| 448 | BOOL WINAPI GetWindowInfo( HWND hwnd, PWINDOWINFO pwi)
|
---|
| 449 | {
|
---|
| 450 | if (!pwi) return FALSE;
|
---|
| 451 | if (!IsWindow(hwnd)) return FALSE;
|
---|
| 452 |
|
---|
| 453 | GetWindowRect(hwnd, &pwi->rcWindow);
|
---|
| 454 | GetClientRect(hwnd, &pwi->rcClient);
|
---|
| 455 | /* translate to screen coordinates */
|
---|
| 456 | MapWindowPoints(hwnd, 0, (LPPOINT)&pwi->rcClient, 2);
|
---|
| 457 |
|
---|
| 458 | pwi->dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
|
---|
| 459 | pwi->dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
|
---|
| 460 | pwi->dwWindowStatus = ((GetActiveWindow() == hwnd) ? WS_ACTIVECAPTION : 0);
|
---|
| 461 |
|
---|
| 462 | pwi->cxWindowBorders = pwi->rcClient.left - pwi->rcWindow.left;
|
---|
| 463 | pwi->cyWindowBorders = pwi->rcWindow.bottom - pwi->rcClient.bottom;
|
---|
| 464 |
|
---|
| 465 | pwi->atomWindowType = GetClassLongW( hwnd, GCW_ATOM );
|
---|
| 466 | pwi->wCreatorVersion = 0x0400;
|
---|
| 467 |
|
---|
| 468 | return TRUE;
|
---|
| 469 | }
|
---|
[21953] | 470 | /*****************************************************************************
|
---|
| 471 | * UpdateLayeredWindow (USER32.@)
|
---|
| 472 | */
|
---|
| 473 | BOOL WIN32API UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT *pptDst,SIZE *psize,
|
---|
| 474 | HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend,
|
---|
| 475 | DWORD dwFlags)
|
---|
| 476 | {
|
---|
| 477 | dprintf(("USER32: UpdateLayeredWindow(%08xh, %08xh, %08xh, %08xh, %08xh, "
|
---|
| 478 | "%08xh, %08xh, %08xh, %08xh) not implemented\n",
|
---|
| 479 | hwnd, hdcDst, pptDst, psize, hdcSrc, pptSrc, crKey, pblend, dwFlags));
|
---|
| 480 | return FALSE;
|
---|
| 481 | }
|
---|
[21334] | 482 |
|
---|
[2469] | 483 | //******************************************************************************
|
---|
| 484 | //******************************************************************************
|
---|
[7875] | 485 | BOOL WIN32API EnableWindow(HWND hwnd, BOOL fEnable)
|
---|
[2469] | 486 | {
|
---|
| 487 | Win32BaseWindow *window;
|
---|
[5935] | 488 | BOOL fEnabled;
|
---|
[2469] | 489 |
|
---|
| 490 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 491 | if(!window) {
|
---|
| 492 | dprintf(("EnableWindow, window %x not found", hwnd));
|
---|
| 493 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 494 | return 0;
|
---|
| 495 | }
|
---|
| 496 | dprintf(("EnableWindow %x %d", hwnd, fEnable));
|
---|
[5935] | 497 | fEnabled = window->EnableWindow(fEnable);
|
---|
| 498 | RELEASE_WNDOBJ(window);
|
---|
| 499 | return fEnabled;
|
---|
[2469] | 500 | }
|
---|
| 501 | //******************************************************************************
|
---|
| 502 | //******************************************************************************
|
---|
[7875] | 503 | BOOL WIN32API BringWindowToTop(HWND hwnd)
|
---|
[2469] | 504 | {
|
---|
[6783] | 505 | dprintf(("BringWindowToTop %x", hwnd));
|
---|
[7875] | 506 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
|
---|
[2469] | 507 | }
|
---|
[3662] | 508 | /***********************************************************************
|
---|
| 509 | * SetInternalWindowPos (USER32.483)
|
---|
| 510 | */
|
---|
[7875] | 511 | VOID WIN32API SetInternalWindowPos(HWND hwnd, UINT showCmd, LPRECT lpRect,
|
---|
| 512 | LPPOINT lpPoint )
|
---|
[3662] | 513 | {
|
---|
| 514 | if( IsWindow(hwnd) )
|
---|
| 515 | {
|
---|
[4497] | 516 | WINDOWPLACEMENT wndpl;
|
---|
| 517 | UINT flags;
|
---|
[3662] | 518 |
|
---|
| 519 | GetWindowPlacement(hwnd, &wndpl);
|
---|
[4497] | 520 | wndpl.length = sizeof(wndpl);
|
---|
| 521 | wndpl.showCmd = showCmd;
|
---|
| 522 | wndpl.flags = 0;
|
---|
[3662] | 523 |
|
---|
[4497] | 524 | if(lpPoint)
|
---|
| 525 | {
|
---|
[3662] | 526 | wndpl.flags |= WPF_SETMINPOSITION;
|
---|
[4497] | 527 | wndpl.ptMinPosition = *lpPoint;
|
---|
| 528 | }
|
---|
| 529 | if(lpRect)
|
---|
| 530 | {
|
---|
[3662] | 531 | wndpl.rcNormalPosition = *lpRect;
|
---|
[4497] | 532 | }
|
---|
[7875] | 533 | SetWindowPlacement(hwnd, &wndpl);
|
---|
[3662] | 534 | }
|
---|
| 535 |
|
---|
| 536 | }
|
---|
| 537 | /***********************************************************************
|
---|
| 538 | * GetInternalWindowPos (USER32.245)
|
---|
| 539 | */
|
---|
[7875] | 540 | UINT WIN32API GetInternalWindowPos(HWND hwnd, LPRECT rectWnd, LPPOINT ptIcon )
|
---|
[3662] | 541 | {
|
---|
| 542 | WINDOWPLACEMENT wndpl;
|
---|
| 543 |
|
---|
| 544 | if(GetWindowPlacement( hwnd, &wndpl ))
|
---|
| 545 | {
|
---|
| 546 | if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
|
---|
| 547 | if (ptIcon) *ptIcon = wndpl.ptMinPosition;
|
---|
| 548 | return wndpl.showCmd;
|
---|
| 549 | }
|
---|
| 550 | return 0;
|
---|
| 551 | }
|
---|
[2469] | 552 | //******************************************************************************
|
---|
| 553 | //******************************************************************************
|
---|
[7875] | 554 | HWND GetActiveWindow()
|
---|
[2469] | 555 | {
|
---|
| 556 | return Win32BaseWindow::GetActiveWindow();
|
---|
| 557 | }
|
---|
| 558 | //******************************************************************************
|
---|
| 559 | //******************************************************************************
|
---|
[7875] | 560 | BOOL WIN32API ShowWindow(HWND hwnd, INT nCmdShow)
|
---|
[2469] | 561 | {
|
---|
| 562 | Win32BaseWindow *window;
|
---|
[5935] | 563 | BOOL ret;
|
---|
[2469] | 564 |
|
---|
| 565 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 566 | if(!window) {
|
---|
| 567 | dprintf(("ShowWindow, window %x not found", hwnd));
|
---|
| 568 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 569 | return 0;
|
---|
| 570 | }
|
---|
[10145] | 571 |
|
---|
| 572 | //PF Start PM restoration routine first if we restore from icon
|
---|
| 573 | //so all internal PM logic will work - this routine will always
|
---|
| 574 | //lead to ShowWindow(SW_RESTORE)
|
---|
| 575 |
|
---|
| 576 | if ((nCmdShow == SW_RESTORE) && (window->getStyle() & WS_MINIMIZE) && fOS2Look )
|
---|
| 577 | {
|
---|
[21916] | 578 | dprintf(("ShowWindow: Initiating OS/2 PM restore"));
|
---|
[10145] | 579 | ret = OSLibWinRestoreWindow(window->getOS2FrameWindowHandle());
|
---|
| 580 | }
|
---|
[21916] | 581 | else
|
---|
[10145] | 582 | ret = window->ShowWindow(nCmdShow);
|
---|
[5935] | 583 | RELEASE_WNDOBJ(window);
|
---|
| 584 | return ret;
|
---|
[2469] | 585 | }
|
---|
| 586 | /*****************************************************************************
|
---|
| 587 | * Name : BOOL WIN32API ShowWindowAsync
|
---|
| 588 | * Purpose : The ShowWindowAsync function sets the show state of a window
|
---|
| 589 | * created by a different thread.
|
---|
| 590 | * Parameters: HWND hwnd handle of window
|
---|
| 591 | * int nCmdShow show state of window
|
---|
| 592 | * Variables :
|
---|
| 593 | * Result : If the window was previously visible, the return value is TRUE.
|
---|
| 594 | * If the window was previously hidden, the return value is FALSE.
|
---|
| 595 | * Remark :
|
---|
| 596 | * Status : UNTESTED STUB
|
---|
| 597 | *
|
---|
| 598 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
| 599 | *****************************************************************************/
|
---|
[7866] | 600 | BOOL WIN32API ShowWindowAsync(HWND hwnd, int nCmdShow)
|
---|
[2469] | 601 | {
|
---|
| 602 | dprintf(("USER32:ShowWindowAsync (%08xh,%08x) not correctly implemented.\n",
|
---|
[7875] | 603 | hwnd, nCmdShow));
|
---|
[2469] | 604 |
|
---|
| 605 | return ShowWindow(hwnd, nCmdShow);
|
---|
| 606 | }
|
---|
| 607 | //******************************************************************************
|
---|
| 608 | //******************************************************************************
|
---|
[7875] | 609 | BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, INT x,
|
---|
| 610 | INT y, INT cx, INT cy, UINT fuFlags)
|
---|
[2469] | 611 | {
|
---|
| 612 | Win32BaseWindow *window;
|
---|
| 613 |
|
---|
[2521] | 614 | if (!hwnd)
|
---|
| 615 | {
|
---|
| 616 | dprintf(("SetWindowPos: Can't move desktop!"));
|
---|
| 617 | return TRUE;
|
---|
| 618 | }
|
---|
[2469] | 619 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 620 | if(!window) {
|
---|
| 621 | dprintf(("SetWindowPos, window %x not found", hwnd));
|
---|
| 622 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
[2521] | 623 | return FALSE;
|
---|
[2469] | 624 | }
|
---|
| 625 | dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
|
---|
[5935] | 626 | BOOL ret = window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
|
---|
| 627 | RELEASE_WNDOBJ(window);
|
---|
| 628 | return ret;
|
---|
[2469] | 629 | }
|
---|
| 630 | //******************************************************************************
|
---|
[4497] | 631 | //NOTE: length must equal structure size or else api fails (verified in NT4, SP6)
|
---|
[2469] | 632 | //******************************************************************************
|
---|
[7875] | 633 | BOOL WIN32API SetWindowPlacement(HWND hwnd, const WINDOWPLACEMENT *winpos)
|
---|
[2469] | 634 | {
|
---|
| 635 | Win32BaseWindow *window;
|
---|
| 636 |
|
---|
[5935] | 637 | if(!winpos || winpos->length != sizeof(WINDOWPLACEMENT)) {
|
---|
| 638 | dprintf(("SetWindowPlacement %x invalid parameter", hwnd));
|
---|
| 639 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 640 | return FALSE;
|
---|
| 641 | }
|
---|
[2469] | 642 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 643 | if(!window) {
|
---|
| 644 | dprintf(("SetWindowPlacement, window %x not found", hwnd));
|
---|
| 645 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
[3662] | 646 | return FALSE;
|
---|
[2469] | 647 | }
|
---|
[3662] | 648 | dprintf(("USER32: SetWindowPlacement %x %x", hwnd, winpos));
|
---|
[5935] | 649 | BOOL ret = window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
|
---|
| 650 | RELEASE_WNDOBJ(window);
|
---|
| 651 | return ret;
|
---|
[2469] | 652 | }
|
---|
| 653 | //******************************************************************************
|
---|
[4497] | 654 | //NOTE: Length does not need to be correct (even though the SDK docs claim otherwise)
|
---|
| 655 | // (Verified in NT4, SP6)
|
---|
[2469] | 656 | //******************************************************************************
|
---|
[7875] | 657 | BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT winpos)
|
---|
[2469] | 658 | {
|
---|
[3662] | 659 | Win32BaseWindow *window;
|
---|
| 660 |
|
---|
[5935] | 661 | if(!winpos) {
|
---|
| 662 | dprintf(("GetWindowPlacement %x invalid parameter", hwnd));
|
---|
| 663 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 664 | return FALSE;
|
---|
| 665 | }
|
---|
[3662] | 666 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 667 | if(!window) {
|
---|
| 668 | dprintf(("GetWindowPlacement, window %x not found", hwnd));
|
---|
| 669 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 670 | return FALSE;
|
---|
| 671 | }
|
---|
| 672 | dprintf(("USER32: GetWindowPlacement %x %x", hwnd, winpos));
|
---|
[5935] | 673 | BOOL ret = window->GetWindowPlacement(winpos);
|
---|
| 674 | RELEASE_WNDOBJ(window);
|
---|
| 675 | return ret;
|
---|
[2469] | 676 | }
|
---|
| 677 | //******************************************************************************
|
---|
| 678 | //******************************************************************************
|
---|
[6981] | 679 | BOOL WIN32API IsWindow(HWND hwnd)
|
---|
[2469] | 680 | {
|
---|
| 681 | Win32BaseWindow *window;
|
---|
| 682 |
|
---|
| 683 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 684 | if(!window) {
|
---|
| 685 | dprintf(("IsWindow, window %x not found", hwnd));
|
---|
| 686 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 687 | return FALSE;
|
---|
| 688 | }
|
---|
[4203] | 689 | dprintf2(("IsWindow %x", hwnd));
|
---|
[5935] | 690 | BOOL fIsWindow = window->IsWindow();
|
---|
| 691 | RELEASE_WNDOBJ(window);
|
---|
| 692 | return fIsWindow;
|
---|
[2469] | 693 | }
|
---|
| 694 | //******************************************************************************
|
---|
| 695 | //******************************************************************************
|
---|
[7875] | 696 | BOOL WIN32API IsWindowEnabled(HWND hwnd)
|
---|
[2469] | 697 | {
|
---|
[7875] | 698 | DWORD dwStyle;
|
---|
[2469] | 699 |
|
---|
[5935] | 700 | if(!IsWindow(hwnd)) {
|
---|
[2469] | 701 | dprintf(("IsWindowEnabled, window %x not found", hwnd));
|
---|
| 702 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 703 | return 0;
|
---|
| 704 | }
|
---|
| 705 | dprintf(("IsWindowEnabled %x", hwnd));
|
---|
[5586] | 706 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
| 707 | if(dwStyle & WS_DISABLED) {
|
---|
| 708 | return FALSE;
|
---|
| 709 | }
|
---|
| 710 | return TRUE;
|
---|
[2469] | 711 | }
|
---|
| 712 | //******************************************************************************
|
---|
| 713 | //******************************************************************************
|
---|
[6981] | 714 | BOOL WIN32API IsWindowVisible(HWND hwnd)
|
---|
[2469] | 715 | {
|
---|
[5586] | 716 | BOOL ret;
|
---|
| 717 | HWND hwndParent;
|
---|
| 718 | DWORD dwStyle;
|
---|
[2469] | 719 |
|
---|
[5935] | 720 | if(hwnd == HWND_DESKTOP) {//TODO: verify in NT!
|
---|
[5586] | 721 | dprintf(("IsWindowVisible DESKTOP returned TRUE"));
|
---|
| 722 | return TRUE; //desktop is always visible
|
---|
| 723 | }
|
---|
[5935] | 724 | if(!IsWindow(hwnd)) {
|
---|
[2469] | 725 | dprintf(("IsWindowVisible, window %x not found", hwnd));
|
---|
| 726 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 727 | return 0;
|
---|
| 728 | }
|
---|
[5586] | 729 | //check visibility of this window
|
---|
| 730 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
| 731 | if(!(dwStyle & WS_VISIBLE)) {
|
---|
| 732 | ret = FALSE;
|
---|
| 733 | goto end;
|
---|
| 734 | }
|
---|
| 735 | ret = TRUE;
|
---|
| 736 |
|
---|
[21916] | 737 | if(dwStyle & WS_CHILD)
|
---|
[7183] | 738 | {
|
---|
| 739 | //check visibility of parents
|
---|
| 740 | hwndParent = GetParent(hwnd);
|
---|
| 741 | while(hwndParent) {
|
---|
| 742 | dwStyle = GetWindowLongA(hwndParent, GWL_STYLE);
|
---|
| 743 | if(!(dwStyle & WS_VISIBLE)) {
|
---|
| 744 | dprintf(("IsWindowVisible %x returned FALSE (parent %x invisible)", hwnd, hwndParent));
|
---|
| 745 | return FALSE;
|
---|
| 746 | }
|
---|
| 747 | if(!(dwStyle & WS_CHILD)) {
|
---|
| 748 | break; //GetParent can also return the owner
|
---|
| 749 | }
|
---|
| 750 | hwndParent = GetParent(hwndParent);
|
---|
[5586] | 751 | }
|
---|
| 752 | }
|
---|
| 753 | end:
|
---|
| 754 | dprintf(("IsWindowVisible %x returned %d", hwnd, ret));
|
---|
| 755 | return ret;
|
---|
[2469] | 756 | }
|
---|
| 757 | //******************************************************************************
|
---|
| 758 | //******************************************************************************
|
---|
[8848] | 759 | HWND WINAPI GetAncestor( HWND hwnd, UINT type )
|
---|
| 760 | {
|
---|
| 761 | HWND hwndAncestor = 0;
|
---|
[10316] | 762 | Win32BaseWindow *window;
|
---|
[8848] | 763 |
|
---|
[10316] | 764 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 765 | if(!window) {
|
---|
| 766 | dprintf(("GetAncestor, window %x not found", hwnd));
|
---|
| 767 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 768 | return FALSE;
|
---|
| 769 | }
|
---|
| 770 |
|
---|
[8848] | 771 | if (type == GA_PARENT)
|
---|
| 772 | {
|
---|
| 773 | LONG dwStyle = GetWindowLongW( hwnd, GWL_STYLE );
|
---|
| 774 | if(dwStyle & WS_CHILD) {
|
---|
| 775 | hwndAncestor = GetParent(hwnd);
|
---|
| 776 | }
|
---|
| 777 | //else no child -> no parent (GetParent returns owner otherwise!)
|
---|
| 778 | }
|
---|
[21916] | 779 | else
|
---|
| 780 | if (type == GA_ROOT)
|
---|
[10316] | 781 | {
|
---|
| 782 | hwndAncestor = window->GetTopParent();
|
---|
| 783 | }
|
---|
| 784 | else
|
---|
[21916] | 785 | if (type == GA_ROOTOWNER)
|
---|
[10316] | 786 | {
|
---|
[21916] | 787 | if(hwnd != GetDesktopWindow())
|
---|
[10316] | 788 | {
|
---|
| 789 | hwndAncestor = hwnd;
|
---|
| 790 | for(;;)
|
---|
| 791 | {
|
---|
| 792 | HWND parent = GetParent( hwndAncestor );
|
---|
| 793 | if (!parent) break;
|
---|
| 794 | hwndAncestor = parent;
|
---|
| 795 | }
|
---|
| 796 | }
|
---|
| 797 | }
|
---|
| 798 | else dprintf(("Unsupported type %d", type));
|
---|
| 799 |
|
---|
| 800 | RELEASE_WNDOBJ(window);
|
---|
| 801 | return hwndAncestor;
|
---|
[8848] | 802 | }
|
---|
| 803 | //******************************************************************************
|
---|
[9791] | 804 | BOOL fIgnoreKeystrokes = FALSE;
|
---|
[8848] | 805 | //******************************************************************************
|
---|
[9791] | 806 | void SetFocusChanged()
|
---|
| 807 | {
|
---|
| 808 | //Focus has changed; invalidate SetFocus(0) state
|
---|
| 809 | fIgnoreKeystrokes = FALSE;
|
---|
| 810 | }
|
---|
| 811 | //******************************************************************************
|
---|
| 812 | //******************************************************************************
|
---|
[7875] | 813 | HWND WIN32API SetFocus(HWND hwnd)
|
---|
[2469] | 814 | {
|
---|
[5935] | 815 | Win32BaseWindow *window;
|
---|
[5713] | 816 | Win32BaseWindow *oldfocuswnd;
|
---|
[8846] | 817 | HWND lastFocus, lastFocus_W, hwnd_O, hwndTopParent, hwndTop;
|
---|
[7887] | 818 | BOOL activate, ret;
|
---|
[5137] | 819 | TEB *teb;
|
---|
[9590] | 820 |
|
---|
[21916] | 821 | dprintf(("SetFocus %x", hwnd));
|
---|
[5137] | 822 | teb = GetThreadTEB();
|
---|
| 823 | if(teb == NULL) {
|
---|
| 824 | DebugInt3();
|
---|
| 825 | return 0;
|
---|
| 826 | }
|
---|
[9791] | 827 | //Special case; SetFocus(0) tells Windows to ignore keystrokes. Pressing
|
---|
| 828 | //a key now generates WM_SYSKEYDOWN/(WM_SYSCHAR)/WM_SYSKEYUP instead
|
---|
| 829 | //of WM_KEYDOWN/(WM_CHAR)/WM_KEYUP
|
---|
| 830 | //WM_KILLFOCUS is sent to the window that currently has focus
|
---|
| 831 | if(hwnd == 0) {
|
---|
| 832 | lastFocus_W = GetFocus();
|
---|
| 833 | if(lastFocus_W == 0) return 0; //nothing to do
|
---|
[5137] | 834 |
|
---|
[9791] | 835 | if(HOOK_CallHooksA(WH_CBT, HCBT_SETFOCUS, 0, (LPARAM)lastFocus_W)) {
|
---|
| 836 | dprintf(("hook cancelled SetFocus call!"));
|
---|
| 837 | return 0;
|
---|
| 838 | }
|
---|
[10316] | 839 | fIgnoreKeystrokes = TRUE;
|
---|
[9791] | 840 | SendMessageA(lastFocus_W, WM_KILLFOCUS, 0, 0);
|
---|
| 841 |
|
---|
| 842 | return lastFocus_W;
|
---|
| 843 | }
|
---|
| 844 |
|
---|
[8846] | 845 | //SetFocus is not allowed for minimized or disabled windows (this window
|
---|
| 846 | //or any parent)
|
---|
| 847 | hwndTop = hwnd;
|
---|
| 848 | for (;;)
|
---|
| 849 | {
|
---|
| 850 | HWND parent;
|
---|
| 851 |
|
---|
| 852 | LONG style = GetWindowLongW( hwndTop, GWL_STYLE );
|
---|
| 853 | if (style & (WS_MINIMIZE | WS_DISABLED)) {
|
---|
| 854 | dprintf(("SetFocus, %x not allowed on minimized or disabled window (%x)", hwnd, style));
|
---|
| 855 | return 0;
|
---|
| 856 | }
|
---|
[8848] | 857 | parent = GetAncestor(hwndTop, GA_PARENT);
|
---|
[8846] | 858 | if (!parent || parent == GetDesktopWindow()) break;
|
---|
| 859 | hwndTop = parent;
|
---|
| 860 | }
|
---|
| 861 |
|
---|
[8848] | 862 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 863 | if(!window) {
|
---|
| 864 | dprintf(("SetFocus, window %x not found", hwnd));
|
---|
[9588] | 865 | //Note: last error not set (NT4, SP6), returns current focus window
|
---|
| 866 | //SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 867 | return GetFocus();
|
---|
[8848] | 868 | }
|
---|
| 869 |
|
---|
[5698] | 870 | hwnd_O = window->getOS2WindowHandle();
|
---|
[10136] | 871 | lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
|
---|
[5696] | 872 |
|
---|
[5935] | 873 | hwndTopParent = window->GetTopParent();
|
---|
[5713] | 874 | activate = FALSE;
|
---|
[5935] | 875 | lastFocus_W = OS2ToWin32Handle(lastFocus);
|
---|
[5713] | 876 | if(lastFocus_W) {
|
---|
| 877 | oldfocuswnd = Win32BaseWindow::GetWindowFromHandle(lastFocus_W);
|
---|
[5935] | 878 | if(lastFocus_W != hwnd && hwndTopParent != oldfocuswnd->GetTopParent()) {
|
---|
[5713] | 879 | activate = TRUE;
|
---|
| 880 | }
|
---|
[5935] | 881 | RELEASE_WNDOBJ(oldfocuswnd);
|
---|
[5713] | 882 | }
|
---|
| 883 | else activate = TRUE;
|
---|
[2469] | 884 |
|
---|
[5713] | 885 | dprintf(("SetFocus %x (%x) -> %x (%x) act %d", lastFocus_W, lastFocus, hwnd, hwnd_O, activate));
|
---|
[2469] | 886 |
|
---|
[5713] | 887 | if(HOOK_CallHooksA(WH_CBT, HCBT_SETFOCUS, hwnd, (LPARAM)lastFocus_W)) {
|
---|
| 888 | dprintf(("hook cancelled SetFocus call!"));
|
---|
[7887] | 889 | RELEASE_WNDOBJ(window);
|
---|
[5713] | 890 | return 0;
|
---|
| 891 | }
|
---|
| 892 |
|
---|
| 893 | if(!IsWindow(hwnd)) return FALSE; //abort if window destroyed
|
---|
| 894 |
|
---|
[7095] | 895 | //NOTE: Don't always activate the window or else the z-order will be changed!!
|
---|
[7887] | 896 | ret = (OSLibWinSetFocus(OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
|
---|
| 897 | RELEASE_WNDOBJ(window);
|
---|
[9791] | 898 |
|
---|
| 899 | //If keystrokes were ignored and focus is set to the old focus window, then
|
---|
| 900 | //PM won't send us a WM_SETFOCUS message. (as we don't inform PM for SetFocus(0))
|
---|
| 901 | if(fIgnoreKeystrokes && lastFocus_W == hwnd) {
|
---|
| 902 | dprintf(("Manually send WM_SETFOCUS; real focus window hasn't changed"));
|
---|
| 903 | SendMessageA(lastFocus_W, WM_SETFOCUS, 0, 0);
|
---|
| 904 | }
|
---|
| 905 | fIgnoreKeystrokes = FALSE;
|
---|
[7887] | 906 | return ret;
|
---|
[2469] | 907 | }
|
---|
| 908 | //******************************************************************************
|
---|
| 909 | //******************************************************************************
|
---|
[7875] | 910 | HWND WIN32API GetFocus()
|
---|
[2469] | 911 | {
|
---|
[5137] | 912 | TEB *teb;
|
---|
| 913 | HWND hwnd;
|
---|
[2469] | 914 |
|
---|
[5137] | 915 | teb = GetThreadTEB();
|
---|
| 916 | if(teb == NULL) {
|
---|
| 917 | DebugInt3();
|
---|
| 918 | return 0;
|
---|
| 919 | }
|
---|
[9791] | 920 | //If keystrokes are ignored (SetFocus(0)), then return 0
|
---|
| 921 | if(fIgnoreKeystrokes) {
|
---|
| 922 | dprintf(("GetFocus; returning 0 after SetFocus(0) call"));
|
---|
| 923 | return 0;
|
---|
| 924 | }
|
---|
[2469] | 925 | hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
|
---|
[4848] | 926 | hwnd = OS2ToWin32Handle(hwnd);
|
---|
[2469] | 927 | dprintf(("USER32: GetFocus %x\n", hwnd));
|
---|
| 928 | return hwnd;
|
---|
| 929 | }
|
---|
| 930 | //******************************************************************************
|
---|
| 931 | //******************************************************************************
|
---|
[8978] | 932 | BOOL WIN32API GetGUIThreadInfo(DWORD dwThreadId, GUITHREADINFO *lpThreadInfo)
|
---|
| 933 | {
|
---|
| 934 | dprintf(("!WARNING!: GetGUIThreadInfo not completely implemented!!"));
|
---|
| 935 |
|
---|
| 936 | if(!lpThreadInfo || lpThreadInfo->cbSize != sizeof(GUITHREADINFO)) {
|
---|
| 937 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 938 | return FALSE;
|
---|
| 939 | }
|
---|
| 940 | //dwThreadId == 0 -> current thread
|
---|
| 941 | if(!dwThreadId) dwThreadId = GetCurrentThreadId();
|
---|
| 942 |
|
---|
| 943 | lpThreadInfo->flags;
|
---|
| 944 | lpThreadInfo->hwndActive = GetActiveWindow();
|
---|
| 945 | if(lpThreadInfo->hwndActive) {
|
---|
[21916] | 946 | if(dwThreadId != GetWindowThreadProcessId(lpThreadInfo->hwndActive, NULL))
|
---|
[8978] | 947 | {//this thread doesn't own the active window (TODO: correct??)
|
---|
| 948 | lpThreadInfo->hwndActive = 0;
|
---|
| 949 | }
|
---|
| 950 | }
|
---|
| 951 | lpThreadInfo->hwndFocus = GetFocus();
|
---|
| 952 | lpThreadInfo->hwndCapture = GetCapture();
|
---|
| 953 | lpThreadInfo->flags = 0; //TODO:
|
---|
| 954 | lpThreadInfo->hwndMenuOwner = 0; //TODO: Handle to the window that owns any active menus
|
---|
| 955 | lpThreadInfo->hwndMoveSize = 0; //TODO: Handle to the window in a move or size loop.
|
---|
| 956 | lpThreadInfo->hwndCaret = 0; //TODO: Handle to the window that is displaying the caret
|
---|
| 957 | lpThreadInfo->rcCaret.left = 0;
|
---|
| 958 | lpThreadInfo->rcCaret.top = 0;
|
---|
| 959 | lpThreadInfo->rcCaret.right = 0;
|
---|
| 960 | lpThreadInfo->rcCaret.bottom = 0;
|
---|
| 961 |
|
---|
| 962 | SetLastError(ERROR_SUCCESS);
|
---|
| 963 | return TRUE;
|
---|
| 964 | }
|
---|
| 965 | //******************************************************************************
|
---|
| 966 | //******************************************************************************
|
---|
[7875] | 967 | BOOL WIN32API IsZoomed(HWND hwnd)
|
---|
[2469] | 968 | {
|
---|
[4147] | 969 | DWORD style;
|
---|
| 970 |
|
---|
| 971 | style = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
| 972 | dprintf(("USER32: IsZoomed %x returned %d", hwnd, ((style & WS_MAXIMIZE) != 0)));
|
---|
| 973 |
|
---|
| 974 | return (style & WS_MAXIMIZE) != 0;
|
---|
[2469] | 975 | }
|
---|
| 976 | //******************************************************************************
|
---|
| 977 | //******************************************************************************
|
---|
[7875] | 978 | BOOL WIN32API LockWindowUpdate(HWND hwnd)
|
---|
[2469] | 979 | {
|
---|
[6972] | 980 | return OSLibWinLockWindowUpdate(Win32ToOS2Handle(hwnd));
|
---|
[2469] | 981 | }
|
---|
| 982 | //******************************************************************************
|
---|
| 983 | //******************************************************************************
|
---|
[7875] | 984 | BOOL WIN32API GetWindowRect(HWND hwnd, PRECT pRect)
|
---|
[2469] | 985 | {
|
---|
| 986 | Win32BaseWindow *window;
|
---|
| 987 |
|
---|
[5935] | 988 | if(pRect == NULL) {
|
---|
| 989 | dprintf(("GetWindowRect %x invalid parameter!", hwnd));
|
---|
| 990 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 991 | return FALSE;
|
---|
| 992 | }
|
---|
[2552] | 993 |
|
---|
[5935] | 994 | if(hwnd == HWND_DESKTOP) {
|
---|
| 995 | windowDesktop->addRef();
|
---|
| 996 | window = windowDesktop;
|
---|
[21916] | 997 | }
|
---|
[5935] | 998 | else window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
[21916] | 999 |
|
---|
[2469] | 1000 | if(!window) {
|
---|
| 1001 | dprintf(("GetWindowRect, window %x not found", hwnd));
|
---|
| 1002 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
[2483] | 1003 | return FALSE;
|
---|
[2469] | 1004 | }
|
---|
[3662] | 1005 | *pRect = *window->getWindowRect();
|
---|
[2552] | 1006 |
|
---|
[3662] | 1007 | //convert from parent coordinates to screen (if necessary)
|
---|
| 1008 | if(window->getParent()) {
|
---|
[4463] | 1009 | MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
|
---|
[3662] | 1010 | }
|
---|
[5935] | 1011 | RELEASE_WNDOBJ(window);
|
---|
[2469] | 1012 | dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
---|
[2483] | 1013 | return TRUE;
|
---|
[2469] | 1014 | }
|
---|
| 1015 | //******************************************************************************
|
---|
| 1016 | //******************************************************************************
|
---|
[7875] | 1017 | INT WIN32API GetWindowTextLengthA(HWND hwnd)
|
---|
[2469] | 1018 | {
|
---|
| 1019 | Win32BaseWindow *window;
|
---|
| 1020 |
|
---|
| 1021 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1022 | if(!window) {
|
---|
[5496] | 1023 | dprintf(("GetWindowTextLengthA, window %x not found", hwnd));
|
---|
[2469] | 1024 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1025 | return 0;
|
---|
| 1026 | }
|
---|
[5496] | 1027 | dprintf(("GetWindowTextLengthA %x", hwnd));
|
---|
[5935] | 1028 | int ret = window->GetWindowTextLengthA();
|
---|
| 1029 | RELEASE_WNDOBJ(window);
|
---|
| 1030 | return ret;
|
---|
[2469] | 1031 | }
|
---|
| 1032 | //******************************************************************************
|
---|
| 1033 | //******************************************************************************
|
---|
[7875] | 1034 | int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
|
---|
[2469] | 1035 | {
|
---|
| 1036 | Win32BaseWindow *window;
|
---|
| 1037 | int rc;
|
---|
| 1038 |
|
---|
| 1039 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1040 | if(!window) {
|
---|
| 1041 | dprintf(("GetWindowTextA, window %x not found", hwnd));
|
---|
| 1042 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1043 | return 0;
|
---|
| 1044 | }
|
---|
| 1045 | rc = window->GetWindowTextA(lpsz, cch);
|
---|
| 1046 | dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
|
---|
[5935] | 1047 | RELEASE_WNDOBJ(window);
|
---|
[2469] | 1048 | return rc;
|
---|
| 1049 | }
|
---|
| 1050 | //******************************************************************************
|
---|
| 1051 | //******************************************************************************
|
---|
| 1052 | int WIN32API GetWindowTextLengthW( HWND hwnd)
|
---|
| 1053 | {
|
---|
[5496] | 1054 | Win32BaseWindow *window;
|
---|
| 1055 |
|
---|
| 1056 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1057 | if(!window) {
|
---|
| 1058 | dprintf(("GetWindowTextLengthW, window %x not found", hwnd));
|
---|
| 1059 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1060 | return 0;
|
---|
| 1061 | }
|
---|
| 1062 | dprintf(("GetWindowTextLengthW %x", hwnd));
|
---|
[5935] | 1063 | int ret = window->GetWindowTextLengthW();
|
---|
| 1064 | RELEASE_WNDOBJ(window);
|
---|
| 1065 | return ret;
|
---|
[2469] | 1066 | }
|
---|
| 1067 | //******************************************************************************
|
---|
| 1068 | //******************************************************************************
|
---|
[7875] | 1069 | int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
|
---|
[2469] | 1070 | {
|
---|
| 1071 | Win32BaseWindow *window;
|
---|
| 1072 |
|
---|
| 1073 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1074 | if(!window) {
|
---|
| 1075 | dprintf(("GetWindowTextW, window %x not found", hwnd));
|
---|
| 1076 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1077 | return 0;
|
---|
| 1078 | }
|
---|
[4188] | 1079 | int rc = window->GetWindowTextW(lpsz, cch);
|
---|
[5935] | 1080 | RELEASE_WNDOBJ(window);
|
---|
[5406] | 1081 | dprintf(("GetWindowTextW %x %ls", hwnd, lpsz));
|
---|
[4188] | 1082 | return rc;
|
---|
[2469] | 1083 | }
|
---|
| 1084 | //******************************************************************************
|
---|
| 1085 | //******************************************************************************
|
---|
[7875] | 1086 | BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
|
---|
[2469] | 1087 | {
|
---|
| 1088 | Win32BaseWindow *window;
|
---|
| 1089 |
|
---|
| 1090 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1091 | if(!window) {
|
---|
| 1092 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
---|
| 1093 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1094 | return 0;
|
---|
| 1095 | }
|
---|
| 1096 | dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
|
---|
[5935] | 1097 | BOOL ret = window->SetWindowTextA((LPSTR)lpsz);
|
---|
| 1098 | RELEASE_WNDOBJ(window);
|
---|
| 1099 | return ret;
|
---|
[2469] | 1100 | }
|
---|
| 1101 | //******************************************************************************
|
---|
| 1102 | //******************************************************************************
|
---|
[7875] | 1103 | BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
|
---|
[2469] | 1104 | {
|
---|
| 1105 | Win32BaseWindow *window;
|
---|
| 1106 |
|
---|
| 1107 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1108 | if(!window) {
|
---|
| 1109 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
---|
| 1110 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1111 | return 0;
|
---|
| 1112 | }
|
---|
[5406] | 1113 | dprintf(("SetWindowTextW %x %ls", hwnd, lpsz));
|
---|
[5935] | 1114 | BOOL ret = window->SetWindowTextW((LPWSTR)lpsz);
|
---|
| 1115 | RELEASE_WNDOBJ(window);
|
---|
| 1116 | return ret;
|
---|
[2469] | 1117 | }
|
---|
| 1118 | /*******************************************************************
|
---|
| 1119 | * InternalGetWindowText (USER32.326)
|
---|
| 1120 | */
|
---|
[21916] | 1121 | int WIN32API InternalGetWindowText(HWND hwnd,
|
---|
[2469] | 1122 | LPWSTR lpString,
|
---|
| 1123 | INT nMaxCount )
|
---|
| 1124 | {
|
---|
| 1125 | dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
|
---|
[7875] | 1126 | hwnd, lpString, nMaxCount));
|
---|
[2469] | 1127 |
|
---|
[7875] | 1128 | return GetWindowTextW(hwnd, lpString,nMaxCount);
|
---|
[2469] | 1129 | }
|
---|
| 1130 | //******************************************************************************
|
---|
| 1131 | //TODO: Correct?
|
---|
| 1132 | //******************************************************************************
|
---|
| 1133 | BOOL WIN32API SetForegroundWindow(HWND hwnd)
|
---|
| 1134 | {
|
---|
| 1135 | dprintf((" SetForegroundWindow %x", hwnd));
|
---|
| 1136 |
|
---|
[3513] | 1137 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
---|
[2469] | 1138 | }
|
---|
| 1139 | //******************************************************************************
|
---|
| 1140 | //******************************************************************************
|
---|
[7875] | 1141 | BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
|
---|
[2469] | 1142 | {
|
---|
| 1143 | HWND hwndWin32 = hwnd;
|
---|
| 1144 | Win32BaseWindow *window;
|
---|
| 1145 |
|
---|
| 1146 | if (!pRect)
|
---|
| 1147 | {
|
---|
[5685] | 1148 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 1149 | return FALSE;
|
---|
[2469] | 1150 | }
|
---|
| 1151 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1152 | if(!window) {
|
---|
| 1153 | dprintf(("GetClientRect, window %x not found", hwnd));
|
---|
| 1154 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1155 | return FALSE;
|
---|
| 1156 | }
|
---|
| 1157 | window->getClientRect(pRect);
|
---|
| 1158 | dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
---|
[5935] | 1159 | RELEASE_WNDOBJ(window);
|
---|
[2469] | 1160 | return TRUE;
|
---|
| 1161 | }
|
---|
| 1162 | //******************************************************************************
|
---|
| 1163 | //******************************************************************************
|
---|
| 1164 | BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
|
---|
| 1165 | {
|
---|
| 1166 | return AdjustWindowRectEx(rect, style, menu, 0);
|
---|
| 1167 | }
|
---|
| 1168 | //******************************************************************************
|
---|
[4457] | 1169 | //Calculate window rectangle based on given client rectangle, style, menu and extended style
|
---|
[2469] | 1170 | //******************************************************************************
|
---|
| 1171 | BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
|
---|
| 1172 | {
|
---|
[3501] | 1173 | if(style == 0 && menu == FALSE && exStyle == 0) {
|
---|
[4457] | 1174 | dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d) -> no change required", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
|
---|
[5685] | 1175 | return TRUE; //nothing needs to be changed (VERIFIED in NT 4)
|
---|
[3501] | 1176 | }
|
---|
[4457] | 1177 | dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
|
---|
[2469] | 1178 | /* Correct the window style */
|
---|
| 1179 | if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
|
---|
[4463] | 1180 | style |= WS_CAPTION;
|
---|
[2469] | 1181 |
|
---|
[3119] | 1182 | //SvL: Include WS_POPUP -> otherwise HAS_THINFRAME is true for popup windows
|
---|
| 1183 | // Also include WS_CHILD -> otherwise HAS_THICKFRAME doesn't work correctly
|
---|
| 1184 | style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_POPUP);
|
---|
| 1185 | exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
|
---|
[2469] | 1186 | if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
|
---|
| 1187 |
|
---|
| 1188 | //Adjust rect outer (Win32BaseWindow::AdjustRectOuter)
|
---|
[2529] | 1189 | if (HAS_THICKFRAME(style,exStyle))
|
---|
[5685] | 1190 | InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
|
---|
[2529] | 1191 | else
|
---|
[5685] | 1192 | if (HAS_DLGFRAME(style,exStyle))
|
---|
[2529] | 1193 | InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
|
---|
[5685] | 1194 | else
|
---|
| 1195 | if (HAS_THINFRAME(style))
|
---|
| 1196 | InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
[2529] | 1197 |
|
---|
| 1198 | if ((style & WS_CAPTION) == WS_CAPTION)
|
---|
[2469] | 1199 | {
|
---|
[5685] | 1200 | if (exStyle & WS_EX_TOOLWINDOW)
|
---|
| 1201 | rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
|
---|
| 1202 | else
|
---|
| 1203 | rect->top -= GetSystemMetrics(SM_CYCAPTION);
|
---|
[2469] | 1204 | }
|
---|
| 1205 |
|
---|
| 1206 | if (menu)
|
---|
[5685] | 1207 | rect->top -= GetSystemMetrics(SM_CYMENU);
|
---|
[2469] | 1208 |
|
---|
| 1209 | //Adjust rect inner (Win32BaseWindow::AdjustRectInner)
|
---|
[4460] | 1210 | if(!(style & WS_ICONIC)) {
|
---|
[5685] | 1211 | if (exStyle & WS_EX_CLIENTEDGE)
|
---|
[4463] | 1212 | InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
|
---|
[2469] | 1213 |
|
---|
[5685] | 1214 | if (exStyle & WS_EX_STATICEDGE)
|
---|
[4463] | 1215 | InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
|
---|
[2469] | 1216 |
|
---|
[5685] | 1217 | //SvL: scrollbars aren't checked *UNLESS* the style includes a border (any border)
|
---|
[4460] | 1218 | // --> VERIFIED IN NT4, SP6 (fixes MFC apps with scrollbars + bar controls)
|
---|
[5685] | 1219 | if(style & (WS_THICKFRAME|WS_BORDER|WS_DLGFRAME)) {
|
---|
[4463] | 1220 | if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
|
---|
| 1221 | if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
|
---|
[5685] | 1222 | }
|
---|
[4460] | 1223 | }
|
---|
[2469] | 1224 |
|
---|
| 1225 | dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
|
---|
[2852] | 1226 |
|
---|
[2469] | 1227 | return TRUE;
|
---|
| 1228 | }
|
---|
| 1229 | //******************************************************************************
|
---|
| 1230 | /* Coordinate Space and Transformation Functions */
|
---|
| 1231 | //******************************************************************************
|
---|
[3662] | 1232 | /*******************************************************************
|
---|
| 1233 | * WINPOS_GetWinOffset
|
---|
| 1234 | *
|
---|
| 1235 | * Calculate the offset between the origin of the two windows. Used
|
---|
| 1236 | * to implement MapWindowPoints.
|
---|
| 1237 | */
|
---|
| 1238 | static void WINPOS_GetWinOffset( Win32BaseWindow *wndFrom, Win32BaseWindow *wndTo,
|
---|
| 1239 | POINT *offset )
|
---|
| 1240 | {
|
---|
| 1241 | Win32BaseWindow *window;
|
---|
| 1242 |
|
---|
| 1243 | offset->x = offset->y = 0;
|
---|
| 1244 |
|
---|
| 1245 | /* Translate source window origin to screen coords */
|
---|
| 1246 | if(wndFrom != windowDesktop)
|
---|
| 1247 | {
|
---|
[7890] | 1248 | window = wndFrom;
|
---|
[3662] | 1249 | while(window)
|
---|
| 1250 | {
|
---|
| 1251 | offset->x += window->getClientRectPtr()->left + window->getWindowRect()->left;
|
---|
| 1252 | offset->y += window->getClientRectPtr()->top + window->getWindowRect()->top;
|
---|
| 1253 | window = window->getParent();
|
---|
| 1254 | }
|
---|
| 1255 | }
|
---|
| 1256 |
|
---|
| 1257 | /* Translate origin to destination window coords */
|
---|
| 1258 | if(wndTo != windowDesktop)
|
---|
| 1259 | {
|
---|
[7890] | 1260 | window = wndTo;
|
---|
[3662] | 1261 | while(window)
|
---|
| 1262 | {
|
---|
| 1263 | offset->x -= window->getClientRectPtr()->left + window->getWindowRect()->left;
|
---|
| 1264 | offset->y -= window->getClientRectPtr()->top + window->getWindowRect()->top;
|
---|
| 1265 | window = window->getParent();
|
---|
| 1266 | }
|
---|
| 1267 | }
|
---|
| 1268 | }
|
---|
| 1269 | //******************************************************************************
|
---|
| 1270 | //******************************************************************************
|
---|
[2469] | 1271 | int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
|
---|
| 1272 | UINT cPoints)
|
---|
| 1273 | {
|
---|
| 1274 | Win32BaseWindow *wndfrom, *wndto;
|
---|
| 1275 | int retval = 0;
|
---|
[3662] | 1276 | POINT offset;
|
---|
[2469] | 1277 |
|
---|
[3482] | 1278 | SetLastError(0);
|
---|
[2469] | 1279 | if(lpPoints == NULL || cPoints == 0) {
|
---|
[21347] | 1280 | dprintf(("MapWindowPoints error: lpPoints %p, cPoints %d", lpPoints, cPoints));
|
---|
[2469] | 1281 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 1282 | return 0;
|
---|
| 1283 | }
|
---|
[5935] | 1284 | if(hwndTo == hwndFrom)
|
---|
| 1285 | return 0; //nothing to do
|
---|
| 1286 |
|
---|
| 1287 | if(hwndFrom == HWND_DESKTOP)
|
---|
[2469] | 1288 | {
|
---|
[5935] | 1289 | windowDesktop->addRef();
|
---|
| 1290 | wndfrom = windowDesktop;
|
---|
[21916] | 1291 | }
|
---|
[5935] | 1292 | else {
|
---|
[2469] | 1293 | wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
|
---|
| 1294 | if(!wndfrom) {
|
---|
| 1295 | dprintf(("MapWindowPoints, window %x not found", hwndFrom));
|
---|
| 1296 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1297 | return 0;
|
---|
| 1298 | }
|
---|
| 1299 | }
|
---|
| 1300 |
|
---|
[5935] | 1301 | if(hwndTo == HWND_DESKTOP)
|
---|
[2469] | 1302 | {
|
---|
[5935] | 1303 | windowDesktop->addRef();
|
---|
| 1304 | wndto = windowDesktop;
|
---|
[21916] | 1305 | }
|
---|
[5935] | 1306 | else {
|
---|
[2469] | 1307 | wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
|
---|
| 1308 | if(!wndto) {
|
---|
| 1309 | dprintf(("MapWindowPoints, window %x not found", hwndTo));
|
---|
| 1310 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1311 | return 0;
|
---|
| 1312 | }
|
---|
| 1313 | }
|
---|
| 1314 |
|
---|
[3662] | 1315 | dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
|
---|
| 1316 | WINPOS_GetWinOffset(wndfrom, wndto, &offset);
|
---|
[2469] | 1317 |
|
---|
[5935] | 1318 | RELEASE_WNDOBJ(wndto);
|
---|
| 1319 | RELEASE_WNDOBJ(wndfrom);
|
---|
[2469] | 1320 | for(int i=0;i<cPoints;i++)
|
---|
| 1321 | {
|
---|
[3662] | 1322 | lpPoints[i].x += offset.x;
|
---|
| 1323 | lpPoints[i].y += offset.y;
|
---|
[2469] | 1324 | }
|
---|
[3662] | 1325 | retval = ((LONG)offset.y << 16) | offset.x;
|
---|
[2469] | 1326 | return retval;
|
---|
| 1327 | }
|
---|
| 1328 | //******************************************************************************
|
---|
| 1329 | //******************************************************************************
|
---|
[7875] | 1330 | BOOL WIN32API ScreenToClient(HWND hwnd, LPPOINT pt)
|
---|
[2469] | 1331 | {
|
---|
| 1332 | PRECT rcl;
|
---|
[2560] | 1333 | BOOL rc;
|
---|
[2469] | 1334 |
|
---|
[5935] | 1335 | if(hwnd == HWND_DESKTOP) {
|
---|
| 1336 | return (TRUE); //nothing to do
|
---|
[3662] | 1337 | }
|
---|
[5935] | 1338 | if (!IsWindow(hwnd)) {
|
---|
[2852] | 1339 | dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
|
---|
[3482] | 1340 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1341 | return FALSE;
|
---|
[2560] | 1342 | }
|
---|
[3482] | 1343 | SetLastError(0);
|
---|
[2560] | 1344 | #ifdef DEBUG
|
---|
| 1345 | POINT tmp = *pt;
|
---|
| 1346 | #endif
|
---|
[3662] | 1347 | MapWindowPoints(0, hwnd, pt, 1);
|
---|
| 1348 | dprintf2(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
|
---|
| 1349 | return TRUE;
|
---|
[2469] | 1350 | }
|
---|
| 1351 | //******************************************************************************
|
---|
| 1352 | //******************************************************************************
|
---|
| 1353 | HWND WIN32API GetDesktopWindow(void)
|
---|
| 1354 | {
|
---|
[7890] | 1355 | HWND hDesktopWindow = windowDesktop->getWindowHandle();
|
---|
| 1356 | dprintf2(("USER32: GetDesktopWindow, returned %x\n", hDesktopWindow));
|
---|
| 1357 | return hDesktopWindow;
|
---|
[2469] | 1358 | }
|
---|
| 1359 | //******************************************************************************
|
---|
| 1360 | //******************************************************************************
|
---|
| 1361 | HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
|
---|
| 1362 | {
|
---|
[2956] | 1363 | return FindWindowExA( NULL, NULL, lpszClass, lpszWindow );
|
---|
[2469] | 1364 | }
|
---|
| 1365 | //******************************************************************************
|
---|
| 1366 | //******************************************************************************
|
---|
| 1367 | HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
|
---|
| 1368 | {
|
---|
[2956] | 1369 | return FindWindowExW( NULL, NULL, lpClassName, lpWindowName );
|
---|
[2469] | 1370 | }
|
---|
| 1371 | //******************************************************************************
|
---|
| 1372 | //******************************************************************************
|
---|
| 1373 | HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
|
---|
| 1374 | {
|
---|
[2956] | 1375 | ATOM atom = 0;
|
---|
| 1376 |
|
---|
| 1377 | if (lpszClass)
|
---|
| 1378 | {
|
---|
| 1379 | /* If the atom doesn't exist, then no class */
|
---|
| 1380 | /* with this name exists either. */
|
---|
[3942] | 1381 | if (!(atom = GlobalFindAtomA( lpszClass )))
|
---|
[2956] | 1382 | {
|
---|
| 1383 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
|
---|
| 1384 | return 0;
|
---|
| 1385 | }
|
---|
[2469] | 1386 | }
|
---|
[2956] | 1387 | return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, (LPSTR)lpszWindow);
|
---|
[2469] | 1388 | }
|
---|
| 1389 | /*****************************************************************************
|
---|
| 1390 | * Name : HWND WIN32API FindWindowExW
|
---|
| 1391 | * Purpose : The FindWindowEx function retrieves the handle of a window whose
|
---|
| 1392 | * class name and window name match the specified strings. The
|
---|
| 1393 | * function searches child windows, beginning with the one following
|
---|
| 1394 | * the given child window.
|
---|
| 1395 | * Parameters: HWND hwndParent handle of parent window
|
---|
| 1396 | * HWND hwndChildAfter handle of a child window
|
---|
| 1397 | * LPCTSTR lpszClass address of class name
|
---|
| 1398 | * LPCTSTR lpszWindow address of window name
|
---|
| 1399 | * Variables :
|
---|
| 1400 | * Result : If the function succeeds, the return value is the handle of the
|
---|
| 1401 | * window that has the specified class and window names.
|
---|
| 1402 | * If the function fails, the return value is NULL. To get extended
|
---|
| 1403 | * error information, call GetLastError.
|
---|
| 1404 | * Remark :
|
---|
| 1405 | *
|
---|
| 1406 | *****************************************************************************/
|
---|
| 1407 |
|
---|
| 1408 | HWND WIN32API FindWindowExW(HWND hwndParent,
|
---|
[2956] | 1409 | HWND hwndChildAfter,
|
---|
| 1410 | LPCWSTR lpszClass,
|
---|
| 1411 | LPCWSTR lpszWindow)
|
---|
[2469] | 1412 | {
|
---|
[2956] | 1413 | ATOM atom = 0;
|
---|
| 1414 | char *buffer;
|
---|
| 1415 | HWND hwnd;
|
---|
| 1416 |
|
---|
| 1417 | if (lpszClass)
|
---|
| 1418 | {
|
---|
| 1419 | /* If the atom doesn't exist, then no class */
|
---|
| 1420 | /* with this name exists either. */
|
---|
| 1421 | if (!(atom = GlobalFindAtomW( lpszClass )))
|
---|
| 1422 | {
|
---|
| 1423 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
|
---|
| 1424 | return 0;
|
---|
| 1425 | }
|
---|
[2469] | 1426 | }
|
---|
[2956] | 1427 | buffer = HEAP_strdupWtoA( GetProcessHeap(), 0, lpszWindow );
|
---|
| 1428 | hwnd = Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, buffer);
|
---|
| 1429 | HeapFree( GetProcessHeap(), 0, buffer );
|
---|
| 1430 | return hwnd;
|
---|
[2469] | 1431 | }
|
---|
| 1432 | //******************************************************************************
|
---|
| 1433 | //******************************************************************************
|
---|
[7875] | 1434 | BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
|
---|
[2469] | 1435 | {
|
---|
| 1436 | dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
|
---|
[4848] | 1437 | // return OSLibWinFlashWindow(Win32ToOS2Handle(hwnd), fFlash);
|
---|
[3501] | 1438 | return 1;
|
---|
[2469] | 1439 | }
|
---|
| 1440 | //******************************************************************************
|
---|
| 1441 | //******************************************************************************
|
---|
[21303] | 1442 | BOOL WIN32API FlashWindowEx( PFLASHWINFO pfwi)
|
---|
| 1443 | {
|
---|
| 1444 | dprintf(("FlashWindow %p %d\n", pfwi));
|
---|
| 1445 | return 1;
|
---|
| 1446 | }
|
---|
| 1447 | //******************************************************************************
|
---|
| 1448 | //******************************************************************************
|
---|
[7875] | 1449 | BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
|
---|
[2469] | 1450 | BOOL repaint )
|
---|
| 1451 | {
|
---|
| 1452 | int flags = SWP_NOZORDER | SWP_NOACTIVATE;
|
---|
| 1453 |
|
---|
| 1454 | if (!repaint) flags |= SWP_NOREDRAW;
|
---|
| 1455 | dprintf(("MoveWindow: %x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
|
---|
| 1456 |
|
---|
| 1457 | return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
|
---|
| 1458 | }
|
---|
| 1459 | //******************************************************************************
|
---|
| 1460 | //******************************************************************************
|
---|
[7875] | 1461 | BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
|
---|
[2469] | 1462 | {
|
---|
| 1463 | PRECT rcl;
|
---|
| 1464 |
|
---|
[5935] | 1465 | if(hwnd == HWND_DESKTOP) {
|
---|
| 1466 | return(TRUE); //nothing to do
|
---|
[2469] | 1467 | }
|
---|
[5935] | 1468 | if(!IsWindow(hwnd)) {
|
---|
[2852] | 1469 | dprintf(("warning: ClientToScreen window %x not found!", hwnd));
|
---|
[2469] | 1470 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1471 | return (FALSE);
|
---|
| 1472 | }
|
---|
[2560] | 1473 | #ifdef DEBUG
|
---|
| 1474 | POINT tmp = *pt;
|
---|
| 1475 | #endif
|
---|
[3662] | 1476 | MapWindowPoints(hwnd, 0, pt, 1);
|
---|
| 1477 | dprintf2(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
|
---|
[2852] | 1478 |
|
---|
[3662] | 1479 | return TRUE;
|
---|
[2469] | 1480 | }
|
---|
| 1481 | //******************************************************************************
|
---|
[3766] | 1482 | //Note: count 0 is a legal parameter (verified in NT4)
|
---|
[2469] | 1483 | //******************************************************************************
|
---|
| 1484 | HDWP WIN32API BeginDeferWindowPos(int count)
|
---|
| 1485 | {
|
---|
| 1486 | HDWP handle;
|
---|
| 1487 | DWP *pDWP;
|
---|
| 1488 |
|
---|
[3766] | 1489 | if (count < 0)
|
---|
[2469] | 1490 | {
|
---|
[2852] | 1491 | dprintf(("USER32: BeginDeferWindowPos invalid param %d", count));
|
---|
[2469] | 1492 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 1493 | return 0;
|
---|
| 1494 | }
|
---|
[2552] | 1495 | dprintf(("USER32: BeginDeferWindowPos %d", count));
|
---|
[3766] | 1496 | if(count == 0)
|
---|
| 1497 | count = 8; // change to any non-zero value
|
---|
| 1498 |
|
---|
| 1499 | handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS));
|
---|
[2469] | 1500 | if (!handle)
|
---|
| 1501 | return 0;
|
---|
| 1502 |
|
---|
| 1503 | pDWP = (DWP *) handle;
|
---|
| 1504 | pDWP->actualCount = 0;
|
---|
| 1505 | pDWP->suggestedCount = count;
|
---|
| 1506 | pDWP->valid = TRUE;
|
---|
| 1507 | pDWP->wMagic = DWP_MAGIC;
|
---|
| 1508 | pDWP->hwndParent = 0;
|
---|
| 1509 | return handle;
|
---|
| 1510 | }
|
---|
| 1511 | /***********************************************************************
|
---|
| 1512 | * DeferWindowPos (USER32.128)
|
---|
[3942] | 1513 | *
|
---|
[3766] | 1514 | * TODO: SvL: Does this need to be thread safe?
|
---|
| 1515 | *
|
---|
[2469] | 1516 | */
|
---|
[7875] | 1517 | HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
|
---|
[2469] | 1518 | INT x, INT y, INT cx, INT cy,
|
---|
| 1519 | UINT flags )
|
---|
| 1520 | {
|
---|
| 1521 | DWP *pDWP;
|
---|
| 1522 | int i;
|
---|
| 1523 | HDWP newhdwp = hdwp,retvalue;
|
---|
| 1524 |
|
---|
| 1525 | pDWP = (DWP *)hdwp;
|
---|
| 1526 | if (!pDWP) {
|
---|
| 1527 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 1528 | return 0;
|
---|
| 1529 | }
|
---|
| 1530 |
|
---|
| 1531 | if (hwnd == GetDesktopWindow())
|
---|
| 1532 | return 0;
|
---|
| 1533 |
|
---|
[5935] | 1534 | if(!IsWindow(hwnd)) {
|
---|
[2469] | 1535 | dprintf(("DeferWindowPos, window %x not found", hwnd));
|
---|
| 1536 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1537 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
---|
| 1538 | return 0;
|
---|
| 1539 | }
|
---|
| 1540 |
|
---|
[2552] | 1541 | dprintf(("USER32: DeferWindowPos hdwp %x hwnd %x hwndAfter %x (%d,%d)(%d,%d) %x", hdwp, hwnd, hwndAfter,
|
---|
| 1542 | x, y, cx, cy, flags));
|
---|
[2469] | 1543 |
|
---|
| 1544 | /* Numega Bounds Checker Demo dislikes the following code.
|
---|
| 1545 | In fact, I've not been able to find any "same parent" requirement in any docu
|
---|
| 1546 | [AM 980509]
|
---|
| 1547 | */
|
---|
| 1548 | #if 0
|
---|
| 1549 | /* All the windows of a DeferWindowPos() must have the same parent */
|
---|
| 1550 | parent = pWnd->parent->hwndSelf;
|
---|
| 1551 | if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
|
---|
| 1552 | else if (parent != pDWP->hwndParent)
|
---|
| 1553 | {
|
---|
| 1554 | USER_HEAP_FREE( hdwp );
|
---|
| 1555 | retvalue = 0;
|
---|
| 1556 | goto END;
|
---|
| 1557 | }
|
---|
| 1558 | #endif
|
---|
| 1559 |
|
---|
| 1560 | for (i = 0; i < pDWP->actualCount; i++)
|
---|
| 1561 | {
|
---|
| 1562 | if (pDWP->winPos[i].hwnd == hwnd)
|
---|
| 1563 | {
|
---|
| 1564 | /* Merge with the other changes */
|
---|
| 1565 | if (!(flags & SWP_NOZORDER))
|
---|
| 1566 | {
|
---|
| 1567 | pDWP->winPos[i].hwndInsertAfter = hwndAfter;
|
---|
| 1568 | }
|
---|
| 1569 | if (!(flags & SWP_NOMOVE))
|
---|
| 1570 | {
|
---|
| 1571 | pDWP->winPos[i].x = x;
|
---|
| 1572 | pDWP->winPos[i].y = y;
|
---|
| 1573 | }
|
---|
| 1574 | if (!(flags & SWP_NOSIZE))
|
---|
| 1575 | {
|
---|
| 1576 | pDWP->winPos[i].cx = cx;
|
---|
| 1577 | pDWP->winPos[i].cy = cy;
|
---|
| 1578 | }
|
---|
| 1579 | pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
|
---|
| 1580 | SWP_NOZORDER | SWP_NOREDRAW |
|
---|
| 1581 | SWP_NOACTIVATE | SWP_NOCOPYBITS|
|
---|
| 1582 | SWP_NOOWNERZORDER);
|
---|
| 1583 | pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
|
---|
| 1584 | SWP_FRAMECHANGED);
|
---|
| 1585 | retvalue = hdwp;
|
---|
| 1586 | goto END;
|
---|
| 1587 | }
|
---|
| 1588 | }
|
---|
| 1589 | if (pDWP->actualCount >= pDWP->suggestedCount)
|
---|
| 1590 | {
|
---|
[3766] | 1591 | //DWP structure already contains WINDOWPOS, allocated with (count-1)
|
---|
| 1592 | //in BeginDeferWindowPos; pDWP->suggestedCount alloc increases it by one
|
---|
[2469] | 1593 | newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
|
---|
| 1594 | sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
|
---|
| 1595 | if (!newhdwp)
|
---|
| 1596 | {
|
---|
| 1597 | retvalue = 0;
|
---|
| 1598 | goto END;
|
---|
| 1599 | }
|
---|
| 1600 | pDWP = (DWP *) newhdwp;
|
---|
| 1601 | pDWP->suggestedCount++;
|
---|
| 1602 | }
|
---|
| 1603 | pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
|
---|
| 1604 | pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
|
---|
| 1605 | pDWP->winPos[pDWP->actualCount].x = x;
|
---|
| 1606 | pDWP->winPos[pDWP->actualCount].y = y;
|
---|
| 1607 | pDWP->winPos[pDWP->actualCount].cx = cx;
|
---|
| 1608 | pDWP->winPos[pDWP->actualCount].cy = cy;
|
---|
| 1609 | pDWP->winPos[pDWP->actualCount].flags = flags;
|
---|
| 1610 | pDWP->actualCount++;
|
---|
| 1611 | retvalue = newhdwp;
|
---|
| 1612 | END:
|
---|
| 1613 | return retvalue;
|
---|
| 1614 | }
|
---|
| 1615 | //******************************************************************************
|
---|
| 1616 | //******************************************************************************
|
---|
| 1617 | BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
|
---|
| 1618 | {
|
---|
| 1619 | DWP *pDWP;
|
---|
| 1620 | WINDOWPOS *winpos;
|
---|
| 1621 | BOOL res = TRUE;
|
---|
| 1622 | int i;
|
---|
| 1623 |
|
---|
| 1624 | pDWP = (DWP *) hdwp;
|
---|
| 1625 | if (!pDWP) {
|
---|
| 1626 | dprintf(("**EndDeferWindowPos invalid parameter\n"));
|
---|
| 1627 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 1628 | return FALSE;
|
---|
| 1629 | }
|
---|
| 1630 | dprintf(("**EndDeferWindowPos for %d windows", pDWP->actualCount));
|
---|
| 1631 | for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
|
---|
| 1632 | {
|
---|
[4457] | 1633 | dprintf(("**EndDeferWindowPos %x (%d,%d) (%d,%d) %x", winpos->hwnd, winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags));
|
---|
[2469] | 1634 | if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
|
---|
| 1635 | winpos->x, winpos->y, winpos->cx,
|
---|
| 1636 | winpos->cy, winpos->flags )))
|
---|
| 1637 | break;
|
---|
| 1638 | }
|
---|
| 1639 | dprintf(("**EndDeferWindowPos DONE"));
|
---|
| 1640 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
---|
| 1641 | return res;
|
---|
| 1642 | }
|
---|
| 1643 | //******************************************************************************
|
---|
| 1644 | //******************************************************************************
|
---|
[7875] | 1645 | HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
|
---|
[2469] | 1646 | {
|
---|
| 1647 | dprintf(("USER32: ChildWindowFromPoint\n"));
|
---|
| 1648 | return ChildWindowFromPointEx(hwnd, pt, 0);
|
---|
| 1649 | }
|
---|
| 1650 | /*****************************************************************************
|
---|
| 1651 | * Name : HWND WIN32API ChildWindowFromPointEx
|
---|
| 1652 | * Purpose : pt: client coordinates
|
---|
| 1653 | * Parameters:
|
---|
| 1654 | * Variables :
|
---|
| 1655 | * Result : If the function succeeds, the return value is the window handle.
|
---|
| 1656 | * If the function fails, the return value is zero
|
---|
| 1657 | * Remark :
|
---|
[3942] | 1658 | * Status : COMPLETELY IMPLEMENTED AND TESTED
|
---|
[2469] | 1659 | *
|
---|
| 1660 | * Author : Rene Pronk [Sun, 1999/08/08 23:30]
|
---|
| 1661 | *****************************************************************************/
|
---|
| 1662 | HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
|
---|
| 1663 | {
|
---|
| 1664 | RECT rect;
|
---|
| 1665 | HWND hWnd;
|
---|
| 1666 |
|
---|
| 1667 | dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
|
---|
| 1668 | hwndParent, pt, uFlags));
|
---|
| 1669 |
|
---|
| 1670 | if (GetWindowRect (hwndParent, &rect) == 0) {
|
---|
| 1671 | // oops, invalid handle
|
---|
| 1672 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1673 | return NULL;
|
---|
| 1674 | }
|
---|
| 1675 |
|
---|
| 1676 | ClientToScreen(hwndParent, &pt);
|
---|
| 1677 | if (PtInRect (&rect, pt) == 0) {
|
---|
| 1678 | // point is outside window
|
---|
| 1679 | return NULL;
|
---|
| 1680 | }
|
---|
| 1681 |
|
---|
| 1682 | // get first child
|
---|
| 1683 | hWnd = GetWindow (hwndParent, GW_CHILD);
|
---|
| 1684 |
|
---|
[4825] | 1685 | while (hWnd != NULL)
|
---|
| 1686 | {
|
---|
[2469] | 1687 | // do I need to skip this window?
|
---|
| 1688 | if (((uFlags & CWP_SKIPINVISIBLE) &&
|
---|
| 1689 | (IsWindowVisible (hWnd) == FALSE)) ||
|
---|
| 1690 | ((uFlags & CWP_SKIPDISABLED) &&
|
---|
| 1691 | (IsWindowEnabled (hWnd) == FALSE)) ||
|
---|
| 1692 | ((uFlags & CWP_SKIPTRANSPARENT) &&
|
---|
| 1693 | (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
|
---|
| 1694 | {
|
---|
| 1695 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
---|
| 1696 | continue;
|
---|
| 1697 | }
|
---|
| 1698 |
|
---|
| 1699 | // is the point in this window's rect?
|
---|
| 1700 | GetWindowRect (hWnd, &rect);
|
---|
| 1701 | if (PtInRect (&rect,pt) == FALSE) {
|
---|
| 1702 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
---|
| 1703 | continue;
|
---|
| 1704 | }
|
---|
| 1705 |
|
---|
| 1706 | dprintf(("ChildWindowFromPointEx returned %x", hWnd));
|
---|
| 1707 | // found it!
|
---|
| 1708 | return hWnd;
|
---|
| 1709 | }
|
---|
| 1710 | // the point is in the parentwindow but the parentwindow has no child
|
---|
| 1711 | // at this coordinate
|
---|
[4825] | 1712 | dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
|
---|
[2469] | 1713 | return hwndParent;
|
---|
| 1714 | }
|
---|
| 1715 | //******************************************************************************
|
---|
| 1716 | //******************************************************************************
|
---|
| 1717 | BOOL WIN32API CloseWindow(HWND hwnd)
|
---|
| 1718 | {
|
---|
| 1719 | Win32BaseWindow *window;
|
---|
| 1720 |
|
---|
| 1721 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1722 | if(!window) {
|
---|
| 1723 | dprintf(("CloseWindow, window %x not found", hwnd));
|
---|
| 1724 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1725 | return 0;
|
---|
| 1726 | }
|
---|
| 1727 | dprintf(("CloseWindow %x\n", hwnd));
|
---|
[5935] | 1728 | BOOL ret = window->CloseWindow();
|
---|
| 1729 | RELEASE_WNDOBJ(window);
|
---|
| 1730 | return ret;
|
---|
[2469] | 1731 | }
|
---|
| 1732 | //******************************************************************************
|
---|
[5409] | 1733 | //******************************************************************************
|
---|
[7875] | 1734 | static BOOL IsPointInWindow(HWND hwnd, POINT point)
|
---|
[5409] | 1735 | {
|
---|
| 1736 | RECT rectWindow;
|
---|
| 1737 | DWORD hittest, dwStyle, dwExStyle;
|
---|
| 1738 |
|
---|
| 1739 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
| 1740 | dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
|
---|
| 1741 |
|
---|
| 1742 | GetWindowRect(hwnd, &rectWindow);
|
---|
| 1743 |
|
---|
| 1744 | /* If point is in window, and window is visible, and it */
|
---|
| 1745 | /* is enabled (or it's a top-level window), then explore */
|
---|
| 1746 | /* its children. Otherwise, go to the next window. */
|
---|
| 1747 |
|
---|
| 1748 | if( (dwStyle & WS_VISIBLE) &&
|
---|
| 1749 | ((dwExStyle & (WS_EX_LAYERED | WS_EX_TRANSPARENT)) != (WS_EX_LAYERED | WS_EX_TRANSPARENT)) &&
|
---|
| 1750 | (!(dwStyle & WS_DISABLED) || ((dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) &&
|
---|
| 1751 | ((point.x >= rectWindow.left) && (point.x < rectWindow.right) &&
|
---|
| 1752 | (point.y >= rectWindow.top) && (point.y < rectWindow.bottom))
|
---|
| 1753 | #if 1
|
---|
| 1754 | )
|
---|
| 1755 | #else
|
---|
| 1756 | &&
|
---|
| 1757 | (wndPtr->hrgnWnd ? PtInRegion(wndPtr->hrgnWnd, 1))
|
---|
| 1758 | #endif
|
---|
| 1759 | {
|
---|
[9928] | 1760 | DWORD dwThreadId = GetCurrentThreadId();
|
---|
| 1761 |
|
---|
| 1762 | //Don't send WM_NCHITTEST if this window doesn't belong to the current thread
|
---|
| 1763 | if(dwThreadId != GetWindowThreadProcessId(hwnd, NULL))
|
---|
| 1764 | {
|
---|
| 1765 | return TRUE;
|
---|
| 1766 | }
|
---|
[5409] | 1767 | hittest = SendMessageA(hwnd, WM_NCHITTEST, 0, MAKELONG(point.x, point.y));
|
---|
| 1768 | if(hittest != HTTRANSPARENT) {
|
---|
| 1769 | return TRUE;
|
---|
| 1770 | }
|
---|
| 1771 | }
|
---|
| 1772 | return FALSE;
|
---|
| 1773 | }
|
---|
| 1774 | //******************************************************************************
|
---|
[2469] | 1775 | //TODO: Does this return handles of hidden or disabled windows?
|
---|
| 1776 | //******************************************************************************
|
---|
| 1777 | HWND WIN32API WindowFromPoint( POINT point)
|
---|
| 1778 | {
|
---|
| 1779 | HWND hwndOS2, hwnd;
|
---|
| 1780 | POINT wPoint;
|
---|
| 1781 |
|
---|
| 1782 | wPoint.x = point.x;
|
---|
| 1783 | wPoint.y = mapScreenY(point.y);
|
---|
| 1784 |
|
---|
| 1785 | hwndOS2 = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&wPoint);
|
---|
| 1786 | if(hwndOS2)
|
---|
| 1787 | {
|
---|
[5404] | 1788 | hwnd = OS2ToWin32Handle(hwndOS2);
|
---|
| 1789 | while(hwnd)
|
---|
| 1790 | {
|
---|
[5409] | 1791 | if(IsPointInWindow(hwnd, point)) {
|
---|
| 1792 | dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwnd));
|
---|
| 1793 | return hwnd;
|
---|
| 1794 | }
|
---|
[8027] | 1795 | #if 0
|
---|
| 1796 | //TODO: breaks a lot of things
|
---|
[8016] | 1797 | hwnd = GetWindow(hwnd, GW_HWNDNEXT);
|
---|
[8027] | 1798 | #else
|
---|
[5409] | 1799 | //try siblings
|
---|
| 1800 | HWND hwndSibling;
|
---|
| 1801 | HWND hwndParent = GetParent(hwnd);
|
---|
[5404] | 1802 |
|
---|
[5409] | 1803 | if(hwndParent) {
|
---|
| 1804 | hwndSibling = GetWindow(hwndParent, GW_CHILD);
|
---|
| 1805 | while(hwndSibling) {
|
---|
| 1806 | if(hwndSibling != hwnd) {
|
---|
| 1807 | if(IsPointInWindow(hwndSibling, point)) {
|
---|
| 1808 | dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwndSibling));
|
---|
| 1809 | return hwndSibling;
|
---|
| 1810 | }
|
---|
| 1811 | }
|
---|
| 1812 | hwndSibling = GetWindow(hwndSibling, GW_HWNDNEXT);
|
---|
[5404] | 1813 | }
|
---|
| 1814 | }
|
---|
[5409] | 1815 | hwnd = hwndParent;
|
---|
[8016] | 1816 | #endif
|
---|
[5404] | 1817 | }
|
---|
[2469] | 1818 | }
|
---|
| 1819 | dprintf(("WindowFromPoint (%d,%d) %x->1\n", point.x, point.y, hwndOS2));
|
---|
| 1820 | return windowDesktop->getWindowHandle();
|
---|
| 1821 | }
|
---|
| 1822 | //******************************************************************************
|
---|
| 1823 | //******************************************************************************
|
---|
| 1824 | BOOL WIN32API IsWindowUnicode(HWND hwnd)
|
---|
| 1825 | {
|
---|
| 1826 | Win32BaseWindow *window;
|
---|
| 1827 |
|
---|
| 1828 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1829 | if(!window) {
|
---|
| 1830 | dprintf(("IsWindowUnicode, window %x not found", hwnd));
|
---|
| 1831 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1832 | return 0;
|
---|
| 1833 | }
|
---|
[5935] | 1834 | BOOL ret = window->IsWindowUnicode();
|
---|
| 1835 | RELEASE_WNDOBJ(window);
|
---|
| 1836 | return ret;
|
---|
[2469] | 1837 | }
|
---|
| 1838 | /***********************************************************************
|
---|
| 1839 | * SwitchToThisWindow (USER32.539)
|
---|
| 1840 | */
|
---|
[9974] | 1841 | VOID WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore )
|
---|
[2469] | 1842 | {
|
---|
[9974] | 1843 | ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
|
---|
[2469] | 1844 | }
|
---|
| 1845 | //******************************************************************************
|
---|
| 1846 | //******************************************************************************
|
---|
| 1847 | BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
| 1848 | {
|
---|
[5935] | 1849 | return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
|
---|
[2469] | 1850 | }
|
---|
| 1851 | //******************************************************************************
|
---|
| 1852 | //******************************************************************************
|
---|
[7875] | 1853 | BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
[2469] | 1854 | {
|
---|
[5935] | 1855 | Win32BaseWindow *window;
|
---|
| 1856 | BOOL ret = TRUE;
|
---|
| 1857 | ULONG henum;
|
---|
| 1858 | HWND hwndNext;
|
---|
[2469] | 1859 |
|
---|
[5935] | 1860 | if(lpfn == NULL) {
|
---|
| 1861 | dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
|
---|
[2469] | 1862 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
| 1863 | return FALSE;
|
---|
[5935] | 1864 | }
|
---|
| 1865 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1866 | if(!window) {
|
---|
[2469] | 1867 | dprintf(("EnumChildWindows, window %x not found", hwnd));
|
---|
| 1868 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1869 | return FALSE;
|
---|
[5935] | 1870 | }
|
---|
| 1871 | ret = window->EnumChildWindows(lpfn, lParam);
|
---|
| 1872 | RELEASE_WNDOBJ(window);
|
---|
| 1873 | return ret;
|
---|
[2469] | 1874 | }
|
---|
| 1875 | //******************************************************************************
|
---|
| 1876 | //******************************************************************************
|
---|
| 1877 | BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
---|
| 1878 | {
|
---|
[5935] | 1879 | return windowDesktop->EnumWindows(lpfn, lParam);
|
---|
[2469] | 1880 | }
|
---|
| 1881 | //******************************************************************************
|
---|
| 1882 | //******************************************************************************
|
---|
[6395] | 1883 | UINT WIN32API ArrangeIconicWindows( HWND parent)
|
---|
[2469] | 1884 | {
|
---|
[6395] | 1885 | RECT rectParent;
|
---|
| 1886 | HWND hwndChild;
|
---|
| 1887 | INT x, y, xspacing, yspacing;
|
---|
| 1888 |
|
---|
| 1889 | dprintf(("USER32: ArrangeIconicWindows %x", parent));
|
---|
| 1890 | dprintf(("USER32: TODO: icon title!!"));
|
---|
| 1891 |
|
---|
| 1892 | GetClientRect(parent, &rectParent);
|
---|
| 1893 | x = rectParent.left;
|
---|
| 1894 | y = rectParent.bottom;
|
---|
| 1895 | xspacing = GetSystemMetrics(SM_CXICONSPACING);
|
---|
| 1896 | yspacing = GetSystemMetrics(SM_CYICONSPACING);
|
---|
| 1897 |
|
---|
| 1898 | hwndChild = GetWindow( parent, GW_CHILD );
|
---|
| 1899 | while (hwndChild)
|
---|
| 1900 | {
|
---|
| 1901 | if( IsIconic( hwndChild ) )
|
---|
| 1902 | {
|
---|
| 1903 | // WND *wndPtr = WIN_FindWndPtr(hwndChild);
|
---|
[21916] | 1904 |
|
---|
[6395] | 1905 | // WINPOS_ShowIconTitle( wndPtr, FALSE );
|
---|
[21916] | 1906 |
|
---|
[6395] | 1907 | SetWindowPos( hwndChild, 0, x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2,
|
---|
| 1908 | y - yspacing - GetSystemMetrics(SM_CYICON)/2, 0, 0,
|
---|
| 1909 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
|
---|
| 1910 | // if( IsWindow(hwndChild) )
|
---|
| 1911 | // WINPOS_ShowIconTitle(wndPtr , TRUE );
|
---|
| 1912 | // WIN_ReleaseWndPtr(wndPtr);
|
---|
| 1913 |
|
---|
| 1914 | if (x <= rectParent.right - xspacing) x += xspacing;
|
---|
| 1915 | else
|
---|
| 1916 | {
|
---|
| 1917 | x = rectParent.left;
|
---|
| 1918 | y -= yspacing;
|
---|
| 1919 | }
|
---|
| 1920 | }
|
---|
| 1921 | hwndChild = GetWindow( hwndChild, GW_HWNDNEXT );
|
---|
| 1922 | }
|
---|
| 1923 | return yspacing;
|
---|
[2469] | 1924 | }
|
---|
| 1925 | //******************************************************************************
|
---|
| 1926 | //restores iconized window to previous size/position
|
---|
| 1927 | //******************************************************************************
|
---|
| 1928 | BOOL WIN32API OpenIcon(HWND hwnd)
|
---|
| 1929 | {
|
---|
[5935] | 1930 | dprintf(("USER32: OpenIcon %x", hwnd));
|
---|
[2469] | 1931 |
|
---|
[5935] | 1932 | if(!IsIconic(hwnd))
|
---|
[2469] | 1933 | return FALSE;
|
---|
[5935] | 1934 | ShowWindow(hwnd, SW_SHOWNORMAL);
|
---|
| 1935 | return TRUE;
|
---|
[2469] | 1936 | }
|
---|
| 1937 | //******************************************************************************
|
---|
[4463] | 1938 | //SDK: Windows can only be shown with ShowOwnedPopups if they were previously
|
---|
| 1939 | // hidden with the same api
|
---|
| 1940 | //TODO: -> needs testing
|
---|
[2469] | 1941 | //******************************************************************************
|
---|
[7875] | 1942 | BOOL WIN32API ShowOwnedPopups(HWND hwndOwner, BOOL fShow)
|
---|
[2469] | 1943 | {
|
---|
[5935] | 1944 | Win32BaseWindow *window, *owner;
|
---|
| 1945 | HWND hwnd;
|
---|
[4463] | 1946 |
|
---|
[5935] | 1947 | owner = Win32BaseWindow::GetWindowFromHandle(hwndOwner);
|
---|
| 1948 | if(!owner) {
|
---|
[4463] | 1949 | dprintf(("ShowOwnedPopups, window %x not found", hwndOwner));
|
---|
| 1950 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 1951 | return FALSE;
|
---|
[5935] | 1952 | }
|
---|
| 1953 | dprintf(("USER32: ShowOwnedPopups %x %d", hwndOwner, fShow));
|
---|
[4463] | 1954 |
|
---|
[5935] | 1955 | hwnd = GetWindow(GetDesktopWindow(), GW_CHILD);
|
---|
| 1956 | while(hwnd) {
|
---|
[4463] | 1957 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 1958 | if(window) {
|
---|
| 1959 | if(window == owner && (window->getStyle() & WS_POPUP))
|
---|
| 1960 | {
|
---|
| 1961 | if(fShow) {
|
---|
| 1962 | if(window->getFlags() & WIN_NEEDS_SHOW_OWNEDPOPUP)
|
---|
| 1963 | {
|
---|
| 1964 | /*
|
---|
| 1965 | * In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING,
|
---|
| 1966 | * regardless of the state of the owner
|
---|
| 1967 | */
|
---|
| 1968 | SendMessageA(hwnd, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
|
---|
| 1969 | window->setFlags(window->getFlags() & ~WIN_NEEDS_SHOW_OWNEDPOPUP);
|
---|
| 1970 | }
|
---|
| 1971 | }
|
---|
| 1972 | else
|
---|
| 1973 | {
|
---|
| 1974 | if(IsWindowVisible(hwnd))
|
---|
| 1975 | {
|
---|
| 1976 | /*
|
---|
| 1977 | * In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING,
|
---|
| 1978 | * regardless of the state of the owner
|
---|
| 1979 | */
|
---|
| 1980 | SendMessageA(hwnd, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
|
---|
| 1981 | window->setFlags(window->getFlags() | WIN_NEEDS_SHOW_OWNEDPOPUP);
|
---|
| 1982 | }
|
---|
| 1983 | }
|
---|
| 1984 | }
|
---|
[5935] | 1985 | RELEASE_WNDOBJ(window);
|
---|
[4463] | 1986 | }
|
---|
[5935] | 1987 | else dprintf(("WARNING: window %x is not valid", hwnd));
|
---|
[4463] | 1988 |
|
---|
| 1989 | hwnd = GetWindow(hwnd, GW_HWNDNEXT);
|
---|
[5935] | 1990 | }
|
---|
| 1991 | RELEASE_WNDOBJ(owner);
|
---|
| 1992 | return TRUE;
|
---|
[2469] | 1993 | }
|
---|
| 1994 | //******************************************************************************
|
---|
| 1995 | //******************************************************************************
|
---|
[7875] | 1996 | HWND WIN32API GetForegroundWindow()
|
---|
[2469] | 1997 | {
|
---|
[6972] | 1998 | HWND hwnd;
|
---|
[3513] | 1999 |
|
---|
[6972] | 2000 | hwnd = OS2ToWin32Handle(OSLibWinQueryActiveWindow());
|
---|
| 2001 | return hwnd;
|
---|
[2469] | 2002 | }
|
---|
| 2003 | //******************************************************************************
|
---|
[6972] | 2004 |
|
---|
| 2005 | /******************************************************************************
|
---|
| 2006 | * The return value identifies the most recently active pop-up window.
|
---|
| 2007 | * The return value is the same as the hWnd parameter, if any of the
|
---|
| 2008 | * following conditions are met:
|
---|
| 2009 | *
|
---|
| 2010 | * - The window identified by hWnd was most recently active.
|
---|
| 2011 | * - The window identified by hWnd does not own any pop-up windows.
|
---|
| 2012 | * - The window identified by hWnd is not a top-level window or it is
|
---|
| 2013 | * owned by another window.
|
---|
| 2014 | */
|
---|
[7875] | 2015 | HWND WIN32API GetLastActivePopup(HWND hWnd)
|
---|
[2469] | 2016 | {
|
---|
[6972] | 2017 | Win32BaseWindow *owner;
|
---|
[2469] | 2018 |
|
---|
[6972] | 2019 | owner = Win32BaseWindow::GetWindowFromHandle(hWnd);
|
---|
[21916] | 2020 | if(!owner)
|
---|
[6972] | 2021 | {
|
---|
| 2022 | dprintf(("GetLastActivePopup, window %x not found", hWnd));
|
---|
| 2023 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2024 | return hWnd;
|
---|
| 2025 | }
|
---|
[2469] | 2026 |
|
---|
[6972] | 2027 | HWND hwndRetVal = owner->getLastActive();
|
---|
| 2028 | if (!IsWindow( hwndRetVal ))
|
---|
| 2029 | hwndRetVal = owner->getWindowHandle();
|
---|
[21916] | 2030 |
|
---|
[6972] | 2031 | RELEASE_WNDOBJ(owner);
|
---|
[21916] | 2032 |
|
---|
[6972] | 2033 | return hwndRetVal;
|
---|
[2469] | 2034 | }
|
---|
| 2035 | //******************************************************************************
|
---|
| 2036 | //******************************************************************************
|
---|
[8016] | 2037 | DWORD WIN32API GetWindowThreadProcessId(HWND hwnd, PDWORD lpdwProcessId)
|
---|
[2469] | 2038 | {
|
---|
[8016] | 2039 | Win32BaseWindow *window;
|
---|
| 2040 | DWORD dwThreadId;
|
---|
[7808] | 2041 |
|
---|
[8016] | 2042 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2043 | if(!window) {
|
---|
| 2044 | dprintf(("GetWindowThreadProcessId, window %x not found", hwnd));
|
---|
| 2045 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2046 | return 0;
|
---|
[7808] | 2047 | }
|
---|
[8016] | 2048 | dwThreadId = window->getThreadId();
|
---|
| 2049 | if(lpdwProcessId) {
|
---|
| 2050 | *lpdwProcessId = window->getProcessId();
|
---|
| 2051 | }
|
---|
| 2052 | RELEASE_WNDOBJ(window);
|
---|
[21916] | 2053 |
|
---|
[7808] | 2054 | return dwThreadId;
|
---|
[2469] | 2055 | }
|
---|
| 2056 | //******************************************************************************
|
---|
| 2057 | //******************************************************************************
|
---|
[7875] | 2058 | DWORD WIN32API GetWindowContextHelpId(HWND hwnd)
|
---|
[2469] | 2059 | {
|
---|
| 2060 | Win32BaseWindow *window;
|
---|
| 2061 |
|
---|
| 2062 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2063 | if(!window) {
|
---|
| 2064 | dprintf(("GetWindowContextHelpId, window %x not found", hwnd));
|
---|
| 2065 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2066 | return 0;
|
---|
| 2067 | }
|
---|
| 2068 | dprintf(("GetWindowContextHelpId %x", hwnd));
|
---|
[5935] | 2069 | DWORD ret = window->getWindowContextHelpId();
|
---|
| 2070 | RELEASE_WNDOBJ(window);
|
---|
| 2071 | return ret;
|
---|
[2469] | 2072 | }
|
---|
| 2073 | //******************************************************************************
|
---|
| 2074 | //******************************************************************************
|
---|
[7875] | 2075 | BOOL WIN32API SetWindowContextHelpId(HWND hwnd, DWORD dwContextHelpId)
|
---|
[2469] | 2076 | {
|
---|
| 2077 | Win32BaseWindow *window;
|
---|
| 2078 |
|
---|
| 2079 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2080 | if(!window) {
|
---|
| 2081 | dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
|
---|
| 2082 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2083 | return 0;
|
---|
| 2084 | }
|
---|
| 2085 | dprintf(("SetWindowContextHelpId %x %d", hwnd, dwContextHelpId));
|
---|
| 2086 | window->setWindowContextHelpId(dwContextHelpId);
|
---|
[5935] | 2087 | RELEASE_WNDOBJ(window);
|
---|
[2469] | 2088 | return(TRUE);
|
---|
| 2089 | }
|
---|
| 2090 | //******************************************************************************
|
---|
| 2091 | //******************************************************************************
|
---|
[7875] | 2092 | HANDLE WIN32API GetPropA(HWND hwnd, LPCSTR str )
|
---|
[3493] | 2093 | {
|
---|
| 2094 | Win32BaseWindow *window;
|
---|
| 2095 |
|
---|
| 2096 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2097 | if(!window) {
|
---|
| 2098 | dprintf(("GetPropA, window %x not found", hwnd));
|
---|
| 2099 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2100 | return 0;
|
---|
| 2101 | }
|
---|
[5935] | 2102 | HANDLE ret = window->getProp(str);
|
---|
| 2103 | RELEASE_WNDOBJ(window);
|
---|
| 2104 | return ret;
|
---|
[3493] | 2105 | }
|
---|
| 2106 | //******************************************************************************
|
---|
| 2107 | //******************************************************************************
|
---|
[7875] | 2108 | HANDLE WIN32API GetPropW(HWND hwnd, LPCWSTR str)
|
---|
[3493] | 2109 | {
|
---|
[7182] | 2110 | Win32BaseWindow *window;
|
---|
| 2111 | LPSTR strA;
|
---|
| 2112 | HANDLE ret;
|
---|
[3493] | 2113 |
|
---|
[7182] | 2114 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2115 | if(!window) {
|
---|
| 2116 | dprintf(("GetPropW, window %x not found", hwnd));
|
---|
| 2117 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2118 | return 0;
|
---|
| 2119 | }
|
---|
| 2120 |
|
---|
| 2121 | if(HIWORD(str)) {
|
---|
| 2122 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
| 2123 | }
|
---|
| 2124 | else strA = (LPSTR)str;
|
---|
| 2125 |
|
---|
| 2126 | ret = window->getProp(strA);
|
---|
| 2127 |
|
---|
| 2128 | RELEASE_WNDOBJ(window);
|
---|
| 2129 | if(HIWORD(str)) HeapFree( GetProcessHeap(), 0, strA );
|
---|
[3493] | 2130 | return ret;
|
---|
| 2131 | }
|
---|
| 2132 | //******************************************************************************
|
---|
| 2133 | //******************************************************************************
|
---|
[7875] | 2134 | BOOL WIN32API SetPropA(HWND hwnd, LPCSTR str, HANDLE handle )
|
---|
[3493] | 2135 | {
|
---|
| 2136 | Win32BaseWindow *window;
|
---|
| 2137 |
|
---|
| 2138 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2139 | if(!window) {
|
---|
| 2140 | dprintf(("SetPropA, window %x not found", hwnd));
|
---|
| 2141 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2142 | return FALSE;
|
---|
| 2143 | }
|
---|
[5935] | 2144 | BOOL ret = window->setProp(str, handle);
|
---|
| 2145 | RELEASE_WNDOBJ(window);
|
---|
| 2146 | return ret;
|
---|
[3493] | 2147 | }
|
---|
| 2148 | //******************************************************************************
|
---|
| 2149 | //******************************************************************************
|
---|
[7875] | 2150 | BOOL SetPropW(HWND hwnd, LPCWSTR str, HANDLE handle )
|
---|
[3493] | 2151 | {
|
---|
| 2152 | BOOL ret;
|
---|
| 2153 | LPSTR strA;
|
---|
| 2154 |
|
---|
| 2155 | if (!HIWORD(str))
|
---|
| 2156 | return SetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str), handle );
|
---|
| 2157 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
| 2158 | ret = SetPropA( hwnd, strA, handle );
|
---|
| 2159 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
| 2160 | return ret;
|
---|
| 2161 | }
|
---|
| 2162 | //******************************************************************************
|
---|
| 2163 | //******************************************************************************
|
---|
[7875] | 2164 | HANDLE WIN32API RemovePropA(HWND hwnd, LPCSTR str)
|
---|
[3493] | 2165 | {
|
---|
| 2166 | Win32BaseWindow *window;
|
---|
| 2167 |
|
---|
| 2168 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2169 | if(!window) {
|
---|
| 2170 | dprintf(("RemovePropA, window %x not found", hwnd));
|
---|
| 2171 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2172 | return 0;
|
---|
| 2173 | }
|
---|
[5935] | 2174 | HANDLE ret = window->removeProp(str);
|
---|
| 2175 | RELEASE_WNDOBJ(window);
|
---|
| 2176 | return ret;
|
---|
[3493] | 2177 | }
|
---|
| 2178 | //******************************************************************************
|
---|
| 2179 | //******************************************************************************
|
---|
[7875] | 2180 | HANDLE WIN32API RemovePropW(HWND hwnd, LPCWSTR str)
|
---|
[3493] | 2181 | {
|
---|
| 2182 | LPSTR strA;
|
---|
| 2183 | HANDLE ret;
|
---|
| 2184 |
|
---|
| 2185 | if (!HIWORD(str))
|
---|
| 2186 | return RemovePropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
|
---|
| 2187 | strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
|
---|
| 2188 | ret = RemovePropA( hwnd, strA );
|
---|
| 2189 | HeapFree( GetProcessHeap(), 0, strA );
|
---|
| 2190 | return ret;
|
---|
| 2191 | }
|
---|
| 2192 | //******************************************************************************
|
---|
| 2193 | //******************************************************************************
|
---|
[7875] | 2194 | INT WIN32API EnumPropsA(HWND hwnd, PROPENUMPROCA func )
|
---|
[3493] | 2195 | {
|
---|
| 2196 | return EnumPropsExA( hwnd, (PROPENUMPROCEXA)func, 0 );
|
---|
| 2197 | }
|
---|
| 2198 | //******************************************************************************
|
---|
| 2199 | //******************************************************************************
|
---|
[7875] | 2200 | INT WIN32API EnumPropsW(HWND hwnd, PROPENUMPROCW func )
|
---|
[3493] | 2201 | {
|
---|
| 2202 | return EnumPropsExW( hwnd, (PROPENUMPROCEXW)func, 0 );
|
---|
| 2203 | }
|
---|
| 2204 | //******************************************************************************
|
---|
| 2205 | //******************************************************************************
|
---|
[7875] | 2206 | INT WIN32API EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam)
|
---|
[3493] | 2207 | {
|
---|
| 2208 | Win32BaseWindow *window;
|
---|
| 2209 |
|
---|
| 2210 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2211 | if(!window) {
|
---|
| 2212 | dprintf(("EnumPropsExA, window %x not found", hwnd));
|
---|
| 2213 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2214 | return -1;
|
---|
| 2215 | }
|
---|
[5935] | 2216 | INT ret = window->enumPropsExA(func, lParam);
|
---|
| 2217 | RELEASE_WNDOBJ(window);
|
---|
| 2218 | return ret;
|
---|
[3493] | 2219 | }
|
---|
| 2220 | //******************************************************************************
|
---|
| 2221 | //******************************************************************************
|
---|
[7875] | 2222 | INT WIN32API EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
|
---|
[3493] | 2223 | {
|
---|
| 2224 | Win32BaseWindow *window;
|
---|
| 2225 |
|
---|
| 2226 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
| 2227 | if(!window) {
|
---|
| 2228 | dprintf(("EnumPropsExA, window %x not found", hwnd));
|
---|
| 2229 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2230 | return -1;
|
---|
| 2231 | }
|
---|
[5935] | 2232 | INT ret = window->enumPropsExW(func, lParam);
|
---|
| 2233 | RELEASE_WNDOBJ(window);
|
---|
| 2234 | return ret;
|
---|
[3493] | 2235 | }
|
---|
| 2236 | //******************************************************************************
|
---|
[21916] | 2237 | //The GetWindowModuleFileName function retrieves the full path and file name of
|
---|
[10316] | 2238 | //the module associated with the specified window handle.
|
---|
[3493] | 2239 | //******************************************************************************
|
---|
[10316] | 2240 | UINT WIN32API GetWindowModuleFileNameA(HWND hwnd, LPTSTR lpszFileName, UINT cchFileNameMax)
|
---|
| 2241 | {
|
---|
| 2242 | WNDPROC lpfnWindowProc;
|
---|
[6972] | 2243 |
|
---|
[10316] | 2244 | if (!IsWindow(hwnd)) {
|
---|
| 2245 | dprintf(("warning: GetWindowModuleFileName: window %x not found!", hwnd));
|
---|
| 2246 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
| 2247 | return 0;
|
---|
| 2248 | }
|
---|
| 2249 | lpfnWindowProc = (WNDPROC)GetWindowLongA(hwnd, GWL_WNDPROC);
|
---|
[10450] | 2250 | return GetProcModuleFileNameA((ULONG)lpfnWindowProc, lpszFileName, cchFileNameMax);
|
---|
[10316] | 2251 | }
|
---|
| 2252 | //******************************************************************************
|
---|
| 2253 | //******************************************************************************
|
---|
[6972] | 2254 |
|
---|
[10316] | 2255 |
|
---|
[6972] | 2256 | /*****************************************************************************
|
---|
| 2257 | * Name : BOOL WIN32API AnyPopup
|
---|
| 2258 | * Purpose : The AnyPopup function indicates whether an owned, visible,
|
---|
| 2259 | * top-level pop-up, or overlapped window exists on the screen. The
|
---|
| 2260 | * function searches the entire Windows screen, not just the calling
|
---|
| 2261 | * application's client area.
|
---|
| 2262 | * Parameters: VOID
|
---|
| 2263 | * Variables :
|
---|
| 2264 | * Result : If a pop-up window exists, the return value is TRUE even if the
|
---|
| 2265 | * pop-up window is completely covered by other windows. Otherwise,
|
---|
| 2266 | * it is FALSE.
|
---|
| 2267 | * Remark : AnyPopup is a Windows version 1.x function and is retained for
|
---|
| 2268 | * compatibility purposes. It is generally not useful.
|
---|
| 2269 | * Status : UNTESTED STUB
|
---|
| 2270 | *
|
---|
| 2271 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
---|
| 2272 | *****************************************************************************/
|
---|
[7875] | 2273 | BOOL WIN32API AnyPopup()
|
---|
[6972] | 2274 | {
|
---|
| 2275 | dprintf(("USER32:AnyPopup() not implemented.\n"));
|
---|
| 2276 |
|
---|
| 2277 | return (FALSE);
|
---|
| 2278 | }
|
---|
[21916] | 2279 |
|
---|
| 2280 | #ifdef __cplusplus
|
---|
| 2281 | } // extern "C"
|
---|
| 2282 | #endif
|
---|