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