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