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