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