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