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