| 1 | /* $Id: window.cpp,v 1.6 1999-09-23 10:33:59 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 window apis for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1999 Sander van Leeuwen
|
|---|
| 6 | *
|
|---|
| 7 | * Parts based on Wine Windows code (windows\win.c)
|
|---|
| 8 | *
|
|---|
| 9 | * Copyright 1993, 1994 Alexandre Julliard
|
|---|
| 10 | *
|
|---|
| 11 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 12 | *
|
|---|
| 13 | *
|
|---|
| 14 | * TODO: Decide what to do about commands for OS/2 windows (non-Win32 apps)
|
|---|
| 15 | *
|
|---|
| 16 | */
|
|---|
| 17 |
|
|---|
| 18 | #include <os2win.h>
|
|---|
| 19 | #include <misc.h>
|
|---|
| 20 | #include <win32wbase.h>
|
|---|
| 21 | #include <win32wmdiclient.h>
|
|---|
| 22 | #include <win32wdesktop.h>
|
|---|
| 23 | #include <oslibwin.h>
|
|---|
| 24 | #include <oslibgdi.h>
|
|---|
| 25 | #include "user32.h"
|
|---|
| 26 | #include "winicon.h"
|
|---|
| 27 |
|
|---|
| 28 | //******************************************************************************
|
|---|
| 29 | //******************************************************************************
|
|---|
| 30 | HWND WIN32API CreateWindowExA(DWORD exStyle, LPCSTR className,
|
|---|
| 31 | LPCSTR windowName, DWORD style, INT x,
|
|---|
| 32 | INT y, INT width, INT height,
|
|---|
| 33 | HWND parent, HMENU menu,
|
|---|
| 34 | HINSTANCE instance, LPVOID data )
|
|---|
| 35 | {
|
|---|
| 36 | Win32BaseWindow *window;
|
|---|
| 37 | ATOM classAtom;
|
|---|
| 38 | CREATESTRUCTA cs;
|
|---|
| 39 |
|
|---|
| 40 | if(exStyle & WS_EX_MDICHILD)
|
|---|
| 41 | return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
|---|
| 42 |
|
|---|
| 43 | //TODO: According to the docs className can be a 16 bits atom
|
|---|
| 44 | // Wine seems to assume it's a string though...
|
|---|
| 45 | /* Find the class atom */
|
|---|
| 46 | if (!(classAtom = GlobalFindAtomA(className)))
|
|---|
| 47 | {
|
|---|
| 48 | dprintf(("CreateWindowEx32A: bad class name "));
|
|---|
| 49 | if (!HIWORD(className)) {
|
|---|
| 50 | dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
|
|---|
| 51 | }
|
|---|
| 52 | else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
|
|---|
| 53 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 54 | return 0;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | /* Create the window */
|
|---|
| 58 | cs.lpCreateParams = data;
|
|---|
| 59 | cs.hInstance = instance;
|
|---|
| 60 | cs.hMenu = menu;
|
|---|
| 61 | cs.hwndParent = parent;
|
|---|
| 62 | cs.x = x;
|
|---|
| 63 | cs.y = y;
|
|---|
| 64 | cs.cx = width;
|
|---|
| 65 | cs.cy = height;
|
|---|
| 66 | cs.style = style;
|
|---|
| 67 | cs.lpszName = windowName;
|
|---|
| 68 | cs.lpszClass = className;
|
|---|
| 69 | cs.dwExStyle = exStyle;
|
|---|
| 70 | dprintf(("CreateWindowExA: (%d,%d) (%d,%d), %x %x", x, y, width, height, style, exStyle));
|
|---|
| 71 |
|
|---|
| 72 | //TODO: According to the docs className can be a 16 bits atom
|
|---|
| 73 | // Wine seems to assume it's a string though...
|
|---|
| 74 | if(!stricmp(className, MDICLIENTCLASSNAMEA)) {
|
|---|
| 75 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, FALSE);
|
|---|
| 76 | }
|
|---|
| 77 | else {
|
|---|
| 78 | window = new Win32BaseWindow( &cs, classAtom, FALSE );
|
|---|
| 79 | }
|
|---|
| 80 | if(window == NULL)
|
|---|
| 81 | {
|
|---|
| 82 | dprintf(("Win32BaseWindow creation failed!!"));
|
|---|
| 83 | return 0;
|
|---|
| 84 | }
|
|---|
| 85 | if(GetLastError() != 0)
|
|---|
| 86 | {
|
|---|
| 87 | dprintf(("Win32BaseWindow error found!!"));
|
|---|
| 88 | delete window;
|
|---|
| 89 | return 0;
|
|---|
| 90 | }
|
|---|
| 91 | return window->getWindowHandle();
|
|---|
| 92 | }
|
|---|
| 93 | //******************************************************************************
|
|---|
| 94 | //******************************************************************************
|
|---|
| 95 | HWND WIN32API CreateWindowExW(DWORD exStyle, LPCWSTR className,
|
|---|
| 96 | LPCWSTR windowName, DWORD style, INT x,
|
|---|
| 97 | INT y, INT width, INT height,
|
|---|
| 98 | HWND parent, HMENU menu,
|
|---|
| 99 | HINSTANCE instance, LPVOID data )
|
|---|
| 100 | {
|
|---|
| 101 | Win32BaseWindow *window;
|
|---|
| 102 | ATOM classAtom;
|
|---|
| 103 | CREATESTRUCTA cs;
|
|---|
| 104 |
|
|---|
| 105 | if(exStyle & WS_EX_MDICHILD)
|
|---|
| 106 | return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
|---|
| 107 |
|
|---|
| 108 | //TODO: According to the docs className can be a 16 bits atom
|
|---|
| 109 | // Wine seems to assume it's a string though...
|
|---|
| 110 | /* Find the class atom */
|
|---|
| 111 | if (!(classAtom = GlobalFindAtomW(className)))
|
|---|
| 112 | {
|
|---|
| 113 | dprintf(("CreateWindowEx32A: bad class name "));
|
|---|
| 114 | if (!HIWORD(className)) {
|
|---|
| 115 | dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
|
|---|
| 116 | }
|
|---|
| 117 | // else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
|
|---|
| 118 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 119 | return 0;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | /* Create the window */
|
|---|
| 123 | cs.lpCreateParams = data;
|
|---|
| 124 | cs.hInstance = instance;
|
|---|
| 125 | cs.hMenu = menu;
|
|---|
| 126 | cs.hwndParent = parent;
|
|---|
| 127 | cs.x = x;
|
|---|
| 128 | cs.y = y;
|
|---|
| 129 | cs.cx = width;
|
|---|
| 130 | cs.cy = height;
|
|---|
| 131 | cs.style = style;
|
|---|
| 132 | cs.lpszName = (LPSTR)windowName;
|
|---|
| 133 | cs.lpszClass = (LPSTR)className;
|
|---|
| 134 | cs.dwExStyle = exStyle;
|
|---|
| 135 |
|
|---|
| 136 | //TODO: According to the docs className can be a 16 bits atom
|
|---|
| 137 | // Wine seems to assume it's a string though...
|
|---|
| 138 | if(!lstrcmpW(className, (LPWSTR)MDICLIENTCLASSNAMEW)) {
|
|---|
| 139 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, TRUE);
|
|---|
| 140 | }
|
|---|
| 141 | else {
|
|---|
| 142 | window = new Win32BaseWindow( &cs, classAtom, TRUE );
|
|---|
| 143 | }
|
|---|
| 144 | if(window == NULL)
|
|---|
| 145 | {
|
|---|
| 146 | dprintf(("Win32BaseWindow creation failed!!"));
|
|---|
| 147 | return 0;
|
|---|
| 148 | }
|
|---|
| 149 | if(GetLastError() != 0)
|
|---|
| 150 | {
|
|---|
| 151 | dprintf(("Win32BaseWindow error found!!"));
|
|---|
| 152 | delete window;
|
|---|
| 153 | return 0;
|
|---|
| 154 | }
|
|---|
| 155 | return window->getWindowHandle();
|
|---|
| 156 | }
|
|---|
| 157 | //******************************************************************************
|
|---|
| 158 | //******************************************************************************
|
|---|
| 159 | HWND WIN32API CreateMDIWindowA(LPCSTR lpszClassName, LPCSTR lpszWindowName,
|
|---|
| 160 | DWORD dwStyle, int x, int y, int nWidth,
|
|---|
| 161 | int nHeight, HWND hwndParent,
|
|---|
| 162 | HINSTANCE hInstance, LPARAM lParam )
|
|---|
| 163 | {
|
|---|
| 164 | HWND hwnd;
|
|---|
| 165 | MDICREATESTRUCTA cs;
|
|---|
| 166 | Win32BaseWindow *window;
|
|---|
| 167 |
|
|---|
| 168 | window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
|
|---|
| 169 | if(!window) {
|
|---|
| 170 | dprintf(("CreateMDIWindowA, window %x not found", hwndParent));
|
|---|
| 171 | return 0;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | dprintf(("USER32: CreateMDIWindowA\n"));
|
|---|
| 175 | cs.szClass = lpszClassName;
|
|---|
| 176 | cs.szTitle = lpszWindowName;
|
|---|
| 177 | cs.hOwner = hInstance;
|
|---|
| 178 | cs.x = x;
|
|---|
| 179 | cs.y = y;
|
|---|
| 180 | cs.cx = nHeight;
|
|---|
| 181 | cs.cy = nWidth;
|
|---|
| 182 | cs.style = dwStyle;
|
|---|
| 183 | cs.lParam = lParam;
|
|---|
| 184 |
|
|---|
| 185 | return window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
|
|---|
| 186 | }
|
|---|
| 187 | //******************************************************************************
|
|---|
| 188 | //******************************************************************************
|
|---|
| 189 | HWND WIN32API CreateMDIWindowW(LPCWSTR lpszClassName, LPCWSTR lpszWindowName,
|
|---|
| 190 | DWORD dwStyle, int x, int y, int nWidth,
|
|---|
| 191 | int nHeight, HWND hwndParent,
|
|---|
| 192 | HINSTANCE hInstance, LPARAM lParam )
|
|---|
| 193 | {
|
|---|
| 194 | HWND hwnd;
|
|---|
| 195 | MDICREATESTRUCTW cs;
|
|---|
| 196 | Win32BaseWindow *window;
|
|---|
| 197 |
|
|---|
| 198 | window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
|
|---|
| 199 | if(!window) {
|
|---|
| 200 | dprintf(("CreateMDIWindowW, window %x not found", hwndParent));
|
|---|
| 201 | return 0;
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | dprintf(("USER32: CreateMDIWindowW\n"));
|
|---|
| 205 | cs.szClass = lpszClassName;
|
|---|
| 206 | cs.szTitle = lpszWindowName;
|
|---|
| 207 | cs.hOwner = hInstance;
|
|---|
| 208 | cs.x = x;
|
|---|
| 209 | cs.y = y;
|
|---|
| 210 | cs.cx = nHeight;
|
|---|
| 211 | cs.cy = nWidth;
|
|---|
| 212 | cs.style = dwStyle;
|
|---|
| 213 | cs.lParam = lParam;
|
|---|
| 214 |
|
|---|
| 215 | return window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
|
|---|
| 216 | }
|
|---|
| 217 | //******************************************************************************
|
|---|
| 218 | //******************************************************************************
|
|---|
| 219 | BOOL WIN32API DestroyWindow(HWND hwnd)
|
|---|
| 220 | {
|
|---|
| 221 | Win32BaseWindow *window;
|
|---|
| 222 |
|
|---|
| 223 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 224 | if(!window) {
|
|---|
| 225 | dprintf(("DestroyWindow, window %x not found", hwnd));
|
|---|
| 226 | return 0;
|
|---|
| 227 | }
|
|---|
| 228 | dprintf(("DestroyWindow %x", hwnd));
|
|---|
| 229 | return window->DestroyWindow();
|
|---|
| 230 | }
|
|---|
| 231 | //******************************************************************************
|
|---|
| 232 | //******************************************************************************
|
|---|
| 233 | HWND WIN32API SetActiveWindow( HWND hwnd)
|
|---|
| 234 | {
|
|---|
| 235 | Win32BaseWindow *window;
|
|---|
| 236 |
|
|---|
| 237 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 238 | if(!window) {
|
|---|
| 239 | dprintf(("SetActiveWindow, window %x not found", hwnd));
|
|---|
| 240 | return 0;
|
|---|
| 241 | }
|
|---|
| 242 | dprintf(("SetActiveWindow %x", hwnd));
|
|---|
| 243 | return window->SetActiveWindow();
|
|---|
| 244 | }
|
|---|
| 245 | //******************************************************************************
|
|---|
| 246 | //******************************************************************************
|
|---|
| 247 | HWND WIN32API GetParent( HWND hwnd)
|
|---|
| 248 | {
|
|---|
| 249 | Win32BaseWindow *window;
|
|---|
| 250 |
|
|---|
| 251 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 252 | if(!window) {
|
|---|
| 253 | dprintf(("GetParent, window %x not found", hwnd));
|
|---|
| 254 | return 0;
|
|---|
| 255 | }
|
|---|
| 256 | dprintf(("GetParent %x", hwnd));
|
|---|
| 257 | return window->GetParent();
|
|---|
| 258 | }
|
|---|
| 259 | //******************************************************************************
|
|---|
| 260 | //******************************************************************************
|
|---|
| 261 | HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
|
|---|
| 262 | {
|
|---|
| 263 | Win32BaseWindow *window;
|
|---|
| 264 |
|
|---|
| 265 | window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
|
|---|
| 266 | if(!window) {
|
|---|
| 267 | dprintf(("SetParent, window %x not found", hwndChild));
|
|---|
| 268 | return 0;
|
|---|
| 269 | }
|
|---|
| 270 | dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
|
|---|
| 271 | return window->SetParent(hwndNewParent);
|
|---|
| 272 | }
|
|---|
| 273 | //******************************************************************************
|
|---|
| 274 | //******************************************************************************
|
|---|
| 275 | BOOL WIN32API IsChild( HWND hwndParent, HWND hwnd)
|
|---|
| 276 | {
|
|---|
| 277 | Win32BaseWindow *window;
|
|---|
| 278 |
|
|---|
| 279 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 280 | if(!window) {
|
|---|
| 281 | dprintf(("IsChild, window %x not found", hwnd));
|
|---|
| 282 | return 0;
|
|---|
| 283 | }
|
|---|
| 284 | dprintf(("IsChild %x %x", hwndParent, hwnd));
|
|---|
| 285 | return window->IsChild(hwndParent);
|
|---|
| 286 | }
|
|---|
| 287 | //******************************************************************************
|
|---|
| 288 | //******************************************************************************
|
|---|
| 289 | HWND WIN32API GetTopWindow( HWND hwnd)
|
|---|
| 290 | {
|
|---|
| 291 | Win32BaseWindow *window;
|
|---|
| 292 |
|
|---|
| 293 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 294 | if(!window) {
|
|---|
| 295 | dprintf(("GetTopWindow, window %x not found", hwnd));
|
|---|
| 296 | return 0;
|
|---|
| 297 | }
|
|---|
| 298 | dprintf(("GetTopWindow %x", hwnd));
|
|---|
| 299 | return window->GetTopWindow();
|
|---|
| 300 | }
|
|---|
| 301 | //******************************************************************************
|
|---|
| 302 | //******************************************************************************
|
|---|
| 303 | #if 0
|
|---|
| 304 | BOOL WIN32API UpdateWindow(HWND hwnd)
|
|---|
| 305 | {
|
|---|
| 306 | Win32BaseWindow *window;
|
|---|
| 307 |
|
|---|
| 308 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 309 | if(!window) {
|
|---|
| 310 | dprintf(("UpdateWindow, window %x not found", hwnd));
|
|---|
| 311 | return 0;
|
|---|
| 312 | }
|
|---|
| 313 | dprintf(("UpdateWindow %x", hwnd));
|
|---|
| 314 | return window->UpdateWindow();
|
|---|
| 315 | }
|
|---|
| 316 | #endif
|
|---|
| 317 | //******************************************************************************
|
|---|
| 318 | //******************************************************************************
|
|---|
| 319 | BOOL WIN32API IsIconic( HWND hwnd)
|
|---|
| 320 | {
|
|---|
| 321 | Win32BaseWindow *window;
|
|---|
| 322 |
|
|---|
| 323 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 324 | if(!window) {
|
|---|
| 325 | dprintf(("IsIconic, window %x not found", hwnd));
|
|---|
| 326 | return 0;
|
|---|
| 327 | }
|
|---|
| 328 | dprintf(("IsIconic %x", hwnd));
|
|---|
| 329 | return window->IsIconic();
|
|---|
| 330 | }
|
|---|
| 331 | //******************************************************************************
|
|---|
| 332 | //******************************************************************************
|
|---|
| 333 | HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
|
|---|
| 334 | {
|
|---|
| 335 | Win32BaseWindow *window;
|
|---|
| 336 |
|
|---|
| 337 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 338 | if(!window) {
|
|---|
| 339 | dprintf(("GetWindow, window %x not found", hwnd));
|
|---|
| 340 | return 0;
|
|---|
| 341 | }
|
|---|
| 342 | dprintf(("GetWindow %x %d", hwnd, uCmd));
|
|---|
| 343 | return window->GetWindow(uCmd);
|
|---|
| 344 | }
|
|---|
| 345 | //******************************************************************************
|
|---|
| 346 | //******************************************************************************
|
|---|
| 347 | BOOL WIN32API EnableWindow( HWND hwnd, BOOL fEnable)
|
|---|
| 348 | {
|
|---|
| 349 | Win32BaseWindow *window;
|
|---|
| 350 |
|
|---|
| 351 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 352 | if(!window) {
|
|---|
| 353 | dprintf(("EnableWindow, window %x not found", hwnd));
|
|---|
| 354 | return 0;
|
|---|
| 355 | }
|
|---|
| 356 | dprintf(("EnableWindow %x %d", hwnd, fEnable));
|
|---|
| 357 | return window->EnableWindow(fEnable);
|
|---|
| 358 | }
|
|---|
| 359 | //******************************************************************************
|
|---|
| 360 | //******************************************************************************
|
|---|
| 361 | BOOL WIN32API BringWindowToTop(HWND hwnd)
|
|---|
| 362 | {
|
|---|
| 363 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
|
|---|
| 364 | }
|
|---|
| 365 | //******************************************************************************
|
|---|
| 366 | //******************************************************************************
|
|---|
| 367 | HWND WIN32API GetActiveWindow()
|
|---|
| 368 | {
|
|---|
| 369 | return Win32BaseWindow::GetActiveWindow();
|
|---|
| 370 | }
|
|---|
| 371 | //******************************************************************************
|
|---|
| 372 | //******************************************************************************
|
|---|
| 373 | BOOL WIN32API ShowWindow(HWND hwnd, int nCmdShow)
|
|---|
| 374 | {
|
|---|
| 375 | Win32BaseWindow *window;
|
|---|
| 376 |
|
|---|
| 377 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 378 | if(!window) {
|
|---|
| 379 | dprintf(("ShowWindow, window %x not found", hwnd));
|
|---|
| 380 | return 0;
|
|---|
| 381 | }
|
|---|
| 382 | dprintf(("ShowWindow %x", hwnd));
|
|---|
| 383 | return window->ShowWindow(nCmdShow);
|
|---|
| 384 | }
|
|---|
| 385 | //******************************************************************************
|
|---|
| 386 | //******************************************************************************
|
|---|
| 387 | BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
|
|---|
| 388 | {
|
|---|
| 389 | Win32BaseWindow *window;
|
|---|
| 390 |
|
|---|
| 391 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 392 | if(!window) {
|
|---|
| 393 | dprintf(("SetWindowPos, window %x not found", hwnd));
|
|---|
| 394 | return 0;
|
|---|
| 395 | }
|
|---|
| 396 | dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
|
|---|
| 397 | return window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
|
|---|
| 398 | }
|
|---|
| 399 | //******************************************************************************
|
|---|
| 400 | //******************************************************************************
|
|---|
| 401 | BOOL WIN32API SetWindowPlacement( HWND arg1, const WINDOWPLACEMENT * arg2)
|
|---|
| 402 | {
|
|---|
| 403 | dprintf(("USER32: SetWindowPlacement\n"));
|
|---|
| 404 | return O32_SetWindowPlacement(arg1, arg2);
|
|---|
| 405 | }
|
|---|
| 406 | //******************************************************************************
|
|---|
| 407 | //******************************************************************************
|
|---|
| 408 | BOOL WIN32API GetWindowPlacement( HWND arg1, LPWINDOWPLACEMENT arg2)
|
|---|
| 409 | {
|
|---|
| 410 | #ifdef DEBUG
|
|---|
| 411 | WriteLog("USER32: GetWindowPlacement\n");
|
|---|
| 412 | #endif
|
|---|
| 413 | return O32_GetWindowPlacement(arg1, arg2);
|
|---|
| 414 | }
|
|---|
| 415 | //******************************************************************************
|
|---|
| 416 | //******************************************************************************
|
|---|
| 417 | BOOL WIN32API IsWindow( HWND hwnd)
|
|---|
| 418 | {
|
|---|
| 419 | Win32BaseWindow *window;
|
|---|
| 420 |
|
|---|
| 421 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 422 | if(!window) {
|
|---|
| 423 | dprintf(("IsWindow, window %x not found", hwnd));
|
|---|
| 424 | return FALSE;
|
|---|
| 425 | }
|
|---|
| 426 | dprintf(("IsWindow %x", hwnd));
|
|---|
| 427 | return window->IsWindow();
|
|---|
| 428 | }
|
|---|
| 429 | //******************************************************************************
|
|---|
| 430 | //******************************************************************************
|
|---|
| 431 | BOOL WIN32API IsWindowEnabled( HWND hwnd)
|
|---|
| 432 | {
|
|---|
| 433 | Win32BaseWindow *window;
|
|---|
| 434 |
|
|---|
| 435 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 436 | if(!window) {
|
|---|
| 437 | dprintf(("IsWindowEnabled, window %x not found", hwnd));
|
|---|
| 438 | return 0;
|
|---|
| 439 | }
|
|---|
| 440 | dprintf(("IsWindowEnabled %x", hwnd));
|
|---|
| 441 | return window->IsWindowEnabled();
|
|---|
| 442 | }
|
|---|
| 443 | //******************************************************************************
|
|---|
| 444 | //******************************************************************************
|
|---|
| 445 | BOOL WIN32API IsWindowVisible( HWND hwnd)
|
|---|
| 446 | {
|
|---|
| 447 | Win32BaseWindow *window;
|
|---|
| 448 |
|
|---|
| 449 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 450 | if(!window) {
|
|---|
| 451 | dprintf(("IsWindowVisible, window %x not found", hwnd));
|
|---|
| 452 | return 0;
|
|---|
| 453 | }
|
|---|
| 454 | dprintf(("IsWindowVisible %x", hwnd));
|
|---|
| 455 | return window->IsWindowVisible();
|
|---|
| 456 | }
|
|---|
| 457 | //******************************************************************************
|
|---|
| 458 | //******************************************************************************
|
|---|
| 459 | HWND WIN32API SetFocus (HWND hwnd)
|
|---|
| 460 | {
|
|---|
| 461 | HWND lastFocus, lastFocus_W, hwnd_O;
|
|---|
| 462 | BOOL activate;
|
|---|
| 463 |
|
|---|
| 464 | hwnd_O = Win32BaseWindow::Win32ToOS2Handle (hwnd);
|
|---|
| 465 | lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
|
|---|
| 466 | activate = ((hwnd_O == lastFocus) || OSLibWinIsChild (lastFocus, hwnd_O));
|
|---|
| 467 | lastFocus_W = Win32BaseWindow::OS2ToWin32Handle (lastFocus);
|
|---|
| 468 |
|
|---|
| 469 | dprintf(("USER32: SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
|
|---|
| 470 |
|
|---|
| 471 | return (OSLibWinSetFocus (OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
|
|---|
| 472 | }
|
|---|
| 473 | //******************************************************************************
|
|---|
| 474 | //******************************************************************************
|
|---|
| 475 | HWND WIN32API GetFocus(void)
|
|---|
| 476 | {
|
|---|
| 477 | HWND hwnd;
|
|---|
| 478 | // dprintf(("USER32: GetFocus\n"));
|
|---|
| 479 |
|
|---|
| 480 | hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
|
|---|
| 481 | return Win32BaseWindow::OS2ToWin32Handle(hwnd);
|
|---|
| 482 | }
|
|---|
| 483 | //******************************************************************************
|
|---|
| 484 | //******************************************************************************
|
|---|
| 485 | /***********************************************************************
|
|---|
| 486 | * GetInternalWindowPos (USER32.245)
|
|---|
| 487 | */
|
|---|
| 488 | UINT WIN32API GetInternalWindowPos(HWND hwnd,
|
|---|
| 489 | LPRECT rectWnd,
|
|---|
| 490 | LPPOINT ptIcon )
|
|---|
| 491 | {
|
|---|
| 492 | WINDOWPLACEMENT wndpl;
|
|---|
| 493 |
|
|---|
| 494 | dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
|
|---|
| 495 | hwnd,
|
|---|
| 496 | rectWnd,
|
|---|
| 497 | ptIcon));
|
|---|
| 498 |
|
|---|
| 499 | if (GetWindowPlacement( hwnd, &wndpl ))
|
|---|
| 500 | {
|
|---|
| 501 | if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
|
|---|
| 502 | if (ptIcon) *ptIcon = wndpl.ptMinPosition;
|
|---|
| 503 | return wndpl.showCmd;
|
|---|
| 504 | }
|
|---|
| 505 | return 0;
|
|---|
| 506 | }
|
|---|
| 507 | //******************************************************************************
|
|---|
| 508 | //******************************************************************************
|
|---|
| 509 | BOOL WIN32API IsZoomed( HWND arg1)
|
|---|
| 510 | {
|
|---|
| 511 | #ifdef DEBUG
|
|---|
| 512 | WriteLog("USER32: IsZoomed\n");
|
|---|
| 513 | #endif
|
|---|
| 514 | return O32_IsZoomed(arg1);
|
|---|
| 515 | }
|
|---|
| 516 | //******************************************************************************
|
|---|
| 517 | //******************************************************************************
|
|---|
| 518 | BOOL WIN32API LockWindowUpdate( HWND arg1)
|
|---|
| 519 | {
|
|---|
| 520 | #ifdef DEBUG
|
|---|
| 521 | WriteLog("USER32: LockWindowUpdate\n");
|
|---|
| 522 | #endif
|
|---|
| 523 | return O32_LockWindowUpdate(arg1);
|
|---|
| 524 | }
|
|---|
| 525 | //******************************************************************************
|
|---|
| 526 | //******************************************************************************
|
|---|
| 527 |
|
|---|
| 528 | #if 0
|
|---|
| 529 | BOOL WIN32API RedrawWindow( HWND arg1, const RECT * arg2, HRGN arg3, UINT arg4)
|
|---|
| 530 | {
|
|---|
| 531 | BOOL rc;
|
|---|
| 532 |
|
|---|
| 533 | rc = O32_RedrawWindow(arg1, arg2, arg3, arg4);
|
|---|
| 534 | #ifdef DEBUG
|
|---|
| 535 | WriteLog("USER32: RedrawWindow %X , %X, %X, %X returned %d\n", arg1, arg2, arg3, arg4, rc);
|
|---|
| 536 | #endif
|
|---|
| 537 | InvalidateRect(arg1, arg2, TRUE);
|
|---|
| 538 | UpdateWindow(arg1);
|
|---|
| 539 | SendMessageA(arg1, WM_PAINT, 0, 0);
|
|---|
| 540 | return(rc);
|
|---|
| 541 | }
|
|---|
| 542 | #endif
|
|---|
| 543 | //******************************************************************************
|
|---|
| 544 | //******************************************************************************
|
|---|
| 545 | BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
|
|---|
| 546 | {
|
|---|
| 547 | Win32BaseWindow *window;
|
|---|
| 548 |
|
|---|
| 549 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 550 | if(!window) {
|
|---|
| 551 | dprintf(("GetWindowRect, window %x not found", hwnd));
|
|---|
| 552 | return 0;
|
|---|
| 553 | }
|
|---|
| 554 | dprintf(("GetWindowRect %x", hwnd));
|
|---|
| 555 | return window->GetWindowRect(pRect);
|
|---|
| 556 | }
|
|---|
| 557 | //******************************************************************************
|
|---|
| 558 | //******************************************************************************
|
|---|
| 559 | int WIN32API GetWindowTextLengthA( HWND hwnd)
|
|---|
| 560 | {
|
|---|
| 561 | Win32BaseWindow *window;
|
|---|
| 562 |
|
|---|
| 563 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 564 | if(!window) {
|
|---|
| 565 | dprintf(("GetWindowTextLength, window %x not found", hwnd));
|
|---|
| 566 | return 0;
|
|---|
| 567 | }
|
|---|
| 568 | dprintf(("GetWindowTextLength %x", hwnd));
|
|---|
| 569 | return window->GetWindowTextLength();
|
|---|
| 570 | }
|
|---|
| 571 | //******************************************************************************
|
|---|
| 572 | //******************************************************************************
|
|---|
| 573 | int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
|
|---|
| 574 | {
|
|---|
| 575 | Win32BaseWindow *window;
|
|---|
| 576 | int rc;
|
|---|
| 577 |
|
|---|
| 578 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 579 | if(!window) {
|
|---|
| 580 | dprintf(("GetWindowTextA, window %x not found", hwnd));
|
|---|
| 581 | return 0;
|
|---|
| 582 | }
|
|---|
| 583 | rc = window->GetWindowTextA(lpsz, cch);
|
|---|
| 584 | dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
|
|---|
| 585 | return rc;
|
|---|
| 586 | }
|
|---|
| 587 | //******************************************************************************
|
|---|
| 588 | //******************************************************************************
|
|---|
| 589 | int WIN32API GetWindowTextLengthW( HWND hwnd)
|
|---|
| 590 | {
|
|---|
| 591 | dprintf(("USER32: GetWindowTextLengthW\n"));
|
|---|
| 592 | return GetWindowTextLengthA(hwnd);
|
|---|
| 593 | }
|
|---|
| 594 | //******************************************************************************
|
|---|
| 595 | //******************************************************************************
|
|---|
| 596 | int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
|
|---|
| 597 | {
|
|---|
| 598 | Win32BaseWindow *window;
|
|---|
| 599 |
|
|---|
| 600 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 601 | if(!window) {
|
|---|
| 602 | dprintf(("GetWindowTextW, window %x not found", hwnd));
|
|---|
| 603 | return 0;
|
|---|
| 604 | }
|
|---|
| 605 | dprintf(("GetWindowTextW %x", hwnd));
|
|---|
| 606 | return window->GetWindowTextW(lpsz, cch);
|
|---|
| 607 | }
|
|---|
| 608 | //******************************************************************************
|
|---|
| 609 | //******************************************************************************
|
|---|
| 610 | BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
|
|---|
| 611 | {
|
|---|
| 612 | Win32BaseWindow *window;
|
|---|
| 613 |
|
|---|
| 614 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 615 | if(!window) {
|
|---|
| 616 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
|---|
| 617 | return 0;
|
|---|
| 618 | }
|
|---|
| 619 | dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
|
|---|
| 620 | return window->SetWindowTextA((LPSTR)lpsz);
|
|---|
| 621 | }
|
|---|
| 622 | //******************************************************************************
|
|---|
| 623 | //******************************************************************************
|
|---|
| 624 | BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
|
|---|
| 625 | {
|
|---|
| 626 | Win32BaseWindow *window;
|
|---|
| 627 |
|
|---|
| 628 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 629 | if(!window) {
|
|---|
| 630 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
|---|
| 631 | return 0;
|
|---|
| 632 | }
|
|---|
| 633 | dprintf(("SetWindowTextW %x", hwnd));
|
|---|
| 634 | return window->SetWindowTextW((LPWSTR)lpsz);
|
|---|
| 635 | }
|
|---|
| 636 | /*******************************************************************
|
|---|
| 637 | * InternalGetWindowText (USER32.326)
|
|---|
| 638 | */
|
|---|
| 639 | int WIN32API InternalGetWindowText(HWND hwnd,
|
|---|
| 640 | LPWSTR lpString,
|
|---|
| 641 | INT nMaxCount )
|
|---|
| 642 | {
|
|---|
| 643 | dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
|
|---|
| 644 | hwnd,
|
|---|
| 645 | lpString,
|
|---|
| 646 | nMaxCount));
|
|---|
| 647 |
|
|---|
| 648 | return GetWindowTextW(hwnd,lpString,nMaxCount);
|
|---|
| 649 | }
|
|---|
| 650 | //******************************************************************************
|
|---|
| 651 | //TODO: Correct?
|
|---|
| 652 | //******************************************************************************
|
|---|
| 653 | BOOL WIN32API SetForegroundWindow(HWND hwnd)
|
|---|
| 654 | {
|
|---|
| 655 | dprintf((" SetForegroundWindow %x", hwnd));
|
|---|
| 656 |
|
|---|
| 657 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER );
|
|---|
| 658 | }
|
|---|
| 659 | //******************************************************************************
|
|---|
| 660 | //******************************************************************************
|
|---|
| 661 | BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
|
|---|
| 662 | {
|
|---|
| 663 | BOOL rc;
|
|---|
| 664 |
|
|---|
| 665 | hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd);
|
|---|
| 666 | rc = OSLibWinQueryWindowRect(hwnd, pRect);
|
|---|
| 667 | dprintf(("USER32: GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
|---|
| 668 | return rc;
|
|---|
| 669 | }
|
|---|
| 670 | //******************************************************************************
|
|---|
| 671 | //******************************************************************************
|
|---|
| 672 | BOOL WIN32API AdjustWindowRect( PRECT arg1, DWORD arg2, BOOL arg3)
|
|---|
| 673 | {
|
|---|
| 674 | #ifdef DEBUG
|
|---|
| 675 | WriteLog("USER32: AdjustWindowRect\n");
|
|---|
| 676 | #endif
|
|---|
| 677 | return O32_AdjustWindowRect(arg1, arg2, arg3);
|
|---|
| 678 | }
|
|---|
| 679 | //******************************************************************************
|
|---|
| 680 | //******************************************************************************
|
|---|
| 681 | BOOL WIN32API AdjustWindowRectEx( PRECT arg1, DWORD arg2, BOOL arg3, DWORD arg4)
|
|---|
| 682 | {
|
|---|
| 683 | #ifdef DEBUG
|
|---|
| 684 | WriteLog("USER32: AdjustWindowRectEx\n");
|
|---|
| 685 | #endif
|
|---|
| 686 | return O32_AdjustWindowRectEx(arg1, arg2, arg3, arg4);
|
|---|
| 687 | }
|
|---|
| 688 | //******************************************************************************
|
|---|
| 689 | //******************************************************************************
|
|---|
| 690 | HWND WIN32API GetDesktopWindow(void)
|
|---|
| 691 | {
|
|---|
| 692 | dprintf(("USER32: GetDesktopWindow\n"));
|
|---|
| 693 | return windowDesktop->getWindowHandle();
|
|---|
| 694 | }
|
|---|
| 695 | //******************************************************************************
|
|---|
| 696 | //******************************************************************************
|
|---|
| 697 | HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
|
|---|
| 698 | {
|
|---|
| 699 | if(!lpszClass) {
|
|---|
| 700 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 701 | return 0;
|
|---|
| 702 | }
|
|---|
| 703 | if(HIWORD(lpszClass)) {
|
|---|
| 704 | dprintf(("USER32: FindWindow %s %s\n", lpszClass, lpszWindow));
|
|---|
| 705 | }
|
|---|
| 706 | else dprintf(("USER32: FindWindow %x %s\n", lpszClass, lpszWindow));
|
|---|
| 707 |
|
|---|
| 708 | return Win32BaseWindow::FindWindowEx(OSLIB_HWND_DESKTOP, 0, (LPSTR)lpszClass, (LPSTR)lpszWindow);
|
|---|
| 709 | }
|
|---|
| 710 | //******************************************************************************
|
|---|
| 711 | //******************************************************************************
|
|---|
| 712 | HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
|
|---|
| 713 | {
|
|---|
| 714 | if(!lpszClass) {
|
|---|
| 715 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 716 | return 0;
|
|---|
| 717 | }
|
|---|
| 718 | if(HIWORD(lpszClass)) {
|
|---|
| 719 | dprintf(("USER32: FindWindowExA (%x,%x) %s %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
|
|---|
| 720 | }
|
|---|
| 721 | else dprintf(("USER32: FindWindowExA (%x,%x)%x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
|
|---|
| 722 |
|
|---|
| 723 | return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
|
|---|
| 724 | }
|
|---|
| 725 | /*****************************************************************************
|
|---|
| 726 | * Name : HWND WIN32API FindWindowExW
|
|---|
| 727 | * Purpose : The FindWindowEx function retrieves the handle of a window whose
|
|---|
| 728 | * class name and window name match the specified strings. The
|
|---|
| 729 | * function searches child windows, beginning with the one following
|
|---|
| 730 | * the given child window.
|
|---|
| 731 | * Parameters: HWND hwndParent handle of parent window
|
|---|
| 732 | * HWND hwndChildAfter handle of a child window
|
|---|
| 733 | * LPCTSTR lpszClass address of class name
|
|---|
| 734 | * LPCTSTR lpszWindow address of window name
|
|---|
| 735 | * Variables :
|
|---|
| 736 | * Result : If the function succeeds, the return value is the handle of the
|
|---|
| 737 | * window that has the specified class and window names.
|
|---|
| 738 | * If the function fails, the return value is NULL. To get extended
|
|---|
| 739 | * error information, call GetLastError.
|
|---|
| 740 | * Remark :
|
|---|
| 741 | * Status : UNTESTED STUB
|
|---|
| 742 | *
|
|---|
| 743 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 744 | *****************************************************************************/
|
|---|
| 745 |
|
|---|
| 746 | HWND WIN32API FindWindowExW(HWND hwndParent,
|
|---|
| 747 | HWND hwndChildAfter,
|
|---|
| 748 | LPCWSTR lpszClass,
|
|---|
| 749 | LPCWSTR lpszWindow)
|
|---|
| 750 | {
|
|---|
| 751 | if(!lpszClass) {
|
|---|
| 752 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 753 | return 0;
|
|---|
| 754 | }
|
|---|
| 755 | dprintf(("USER32: FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
|
|---|
| 756 |
|
|---|
| 757 | return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
|
|---|
| 758 | }
|
|---|
| 759 | //******************************************************************************
|
|---|
| 760 | //******************************************************************************
|
|---|
| 761 | BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
|
|---|
| 762 | {
|
|---|
| 763 | dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
|
|---|
| 764 | return OSLibWinFlashWindow(Win32BaseWindow::Win32ToOS2Handle(hwnd), fFlash);
|
|---|
| 765 | }
|
|---|
| 766 | //******************************************************************************
|
|---|
| 767 | //******************************************************************************
|
|---|
| 768 | BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
|
|---|
| 769 | BOOL repaint )
|
|---|
| 770 | {
|
|---|
| 771 | int flags = SWP_NOZORDER | SWP_NOACTIVATE;
|
|---|
| 772 |
|
|---|
| 773 | if (!repaint) flags |= SWP_NOREDRAW;
|
|---|
| 774 | dprintf(("MoveWindow: %04x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
|
|---|
| 775 |
|
|---|
| 776 | return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
|
|---|
| 777 | }
|
|---|
| 778 | //******************************************************************************
|
|---|
| 779 | //******************************************************************************
|
|---|
| 780 | BOOL WIN32API ClientToScreen( HWND arg1, PPOINT arg2)
|
|---|
| 781 | {
|
|---|
| 782 | #ifdef DEBUG
|
|---|
| 783 | //// WriteLog("USER32: ClientToScreen\n");
|
|---|
| 784 | #endif
|
|---|
| 785 | return O32_ClientToScreen(arg1, arg2);
|
|---|
| 786 | }
|
|---|
| 787 | //******************************************************************************
|
|---|
| 788 | //******************************************************************************
|
|---|
| 789 | HDWP WIN32API BeginDeferWindowPos( int arg1)
|
|---|
| 790 | {
|
|---|
| 791 | #ifdef DEBUG
|
|---|
| 792 | WriteLog("USER32: BeginDeferWindowPos\n");
|
|---|
| 793 | #endif
|
|---|
| 794 | return O32_BeginDeferWindowPos(arg1);
|
|---|
| 795 | }
|
|---|
| 796 | //******************************************************************************
|
|---|
| 797 | //******************************************************************************
|
|---|
| 798 | HDWP WIN32API DeferWindowPos( HDWP arg1, HWND arg2, HWND arg3, int arg4, int arg5, int arg6, int arg7, UINT arg8)
|
|---|
| 799 | {
|
|---|
| 800 | #ifdef DEBUG
|
|---|
| 801 | WriteLog("USER32: DeferWindowPos\n");
|
|---|
| 802 | #endif
|
|---|
| 803 | return O32_DeferWindowPos(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
|
|---|
| 804 | }
|
|---|
| 805 | //******************************************************************************
|
|---|
| 806 | //******************************************************************************
|
|---|
| 807 | HWND WIN32API ChildWindowFromPoint( HWND arg1, POINT arg2)
|
|---|
| 808 | {
|
|---|
| 809 | #ifdef DEBUG
|
|---|
| 810 | WriteLog("USER32: ChildWindowFromPoint\n");
|
|---|
| 811 | #endif
|
|---|
| 812 | return O32_ChildWindowFromPoint(arg1, arg2);
|
|---|
| 813 | }
|
|---|
| 814 | //******************************************************************************
|
|---|
| 815 | //******************************************************************************
|
|---|
| 816 | /*****************************************************************************
|
|---|
| 817 | * Name : HWND WIN32API ChildWindowFromPointEx
|
|---|
| 818 | * Purpose : The GetWindowRect function retrieves the dimensions of the
|
|---|
| 819 | * bounding rectangle of the specified window. The dimensions are
|
|---|
| 820 | * given in screen coordinates that are relative to the upper-left
|
|---|
| 821 | * corner of the screen.
|
|---|
| 822 | * Parameters:
|
|---|
| 823 | * Variables :
|
|---|
| 824 | * Result : If the function succeeds, the return value is the window handle.
|
|---|
| 825 | * If the function fails, the return value is zero
|
|---|
| 826 | * Remark :
|
|---|
| 827 | * Status : FULLY IMPLEMENTED AND TESTED
|
|---|
| 828 | *
|
|---|
| 829 | * Author : Rene Pronk [Sun, 1999/08/08 23:30]
|
|---|
| 830 | *****************************************************************************/
|
|---|
| 831 |
|
|---|
| 832 | HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
|
|---|
| 833 | {
|
|---|
| 834 | RECT rect;
|
|---|
| 835 | HWND hWnd;
|
|---|
| 836 | POINT absolutePt;
|
|---|
| 837 |
|
|---|
| 838 | dprintf(("USER32: ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
|
|---|
| 839 | hwndParent, pt, uFlags));
|
|---|
| 840 |
|
|---|
| 841 | if (GetWindowRect (hwndParent, &rect) == 0) {
|
|---|
| 842 | // oops, invalid handle
|
|---|
| 843 | return NULL;
|
|---|
| 844 | }
|
|---|
| 845 |
|
|---|
| 846 | // absolutePt has its top in the upper-left corner of the screen
|
|---|
| 847 | absolutePt = pt;
|
|---|
| 848 | ClientToScreen (hwndParent, &absolutePt);
|
|---|
| 849 |
|
|---|
| 850 | // make rect the size of the parent window
|
|---|
| 851 | GetWindowRect (hwndParent, &rect);
|
|---|
| 852 | rect.right = rect.right - rect.left;
|
|---|
| 853 | rect.bottom = rect.bottom - rect.top;
|
|---|
| 854 | rect.left = 0;
|
|---|
| 855 | rect.top = 0;
|
|---|
| 856 |
|
|---|
| 857 | if (PtInRect (&rect, pt) == 0) {
|
|---|
| 858 | // point is outside window
|
|---|
| 859 | return NULL;
|
|---|
| 860 | }
|
|---|
| 861 |
|
|---|
| 862 | // get first child
|
|---|
| 863 | hWnd = GetWindow (hwndParent, GW_CHILD);
|
|---|
| 864 |
|
|---|
| 865 | while (hWnd != NULL) {
|
|---|
| 866 |
|
|---|
| 867 | // do I need to skip this window?
|
|---|
| 868 | if (((uFlags & CWP_SKIPINVISIBLE) &&
|
|---|
| 869 | (IsWindowVisible (hWnd) == FALSE)) ||
|
|---|
| 870 | ((uFlags & CWP_SKIPDISABLED) &&
|
|---|
| 871 | (IsWindowEnabled (hWnd) == FALSE)) ||
|
|---|
| 872 | ((uFlags & CWP_SKIPTRANSPARENT) &&
|
|---|
| 873 | (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
|
|---|
| 874 |
|
|---|
| 875 | {
|
|---|
| 876 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
|---|
| 877 | continue;
|
|---|
| 878 | }
|
|---|
| 879 |
|
|---|
| 880 | // is the point in this window's rect?
|
|---|
| 881 | GetWindowRect (hWnd, &rect);
|
|---|
| 882 | if (PtInRect (&rect, absolutePt) == FALSE) {
|
|---|
| 883 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
|---|
| 884 | continue;
|
|---|
| 885 | }
|
|---|
| 886 |
|
|---|
| 887 | // found it!
|
|---|
| 888 | return hWnd;
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 | // the point is in the parentwindow but the parentwindow has no child
|
|---|
| 892 | // at this coordinate
|
|---|
| 893 | return hwndParent;
|
|---|
| 894 | }
|
|---|
| 895 | //******************************************************************************
|
|---|
| 896 | //******************************************************************************
|
|---|
| 897 | BOOL WIN32API CloseWindow(HWND hwnd)
|
|---|
| 898 | {
|
|---|
| 899 | Win32BaseWindow *window;
|
|---|
| 900 |
|
|---|
| 901 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 902 | if(!window) {
|
|---|
| 903 | dprintf(("CloseWindow, window %x not found", hwnd));
|
|---|
| 904 | return 0;
|
|---|
| 905 | }
|
|---|
| 906 | dprintf(("CloseWindow %x\n", hwnd));
|
|---|
| 907 | return window->CloseWindow();
|
|---|
| 908 | }
|
|---|
| 909 | //******************************************************************************
|
|---|
| 910 | //TODO: Does this return handles of hidden or disabled windows?
|
|---|
| 911 | //******************************************************************************
|
|---|
| 912 | HWND WIN32API WindowFromPoint( POINT point)
|
|---|
| 913 | {
|
|---|
| 914 | HWND hwnd;
|
|---|
| 915 |
|
|---|
| 916 | dprintf(("WindowFromPoint (%d,%d)\n", point.x, point.y));
|
|---|
| 917 | hwnd = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&point);
|
|---|
| 918 | if(hwnd) {
|
|---|
| 919 | return Win32BaseWindow::OS2ToWin32Handle(hwnd);
|
|---|
| 920 | }
|
|---|
| 921 | return 0;
|
|---|
| 922 | }
|
|---|
| 923 | //******************************************************************************
|
|---|
| 924 | //******************************************************************************
|
|---|
| 925 | BOOL WIN32API IsWindowUnicode(HWND hwnd)
|
|---|
| 926 | {
|
|---|
| 927 | Win32BaseWindow *window;
|
|---|
| 928 |
|
|---|
| 929 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 930 | if(!window) {
|
|---|
| 931 | dprintf(("IsWindowUnicode, window %x not found", hwnd));
|
|---|
| 932 | return 0;
|
|---|
| 933 | }
|
|---|
| 934 | return window->IsUnicode();
|
|---|
| 935 | }
|
|---|
| 936 | /*****************************************************************************
|
|---|
| 937 | * Name : WORD WIN32API CascadeWindows
|
|---|
| 938 | * Purpose : The CascadeWindows function cascades the specified windows or
|
|---|
| 939 | * the child windows of the specified parent window.
|
|---|
| 940 | * Parameters: HWND hwndParent handle of parent window
|
|---|
| 941 | * UINT wHow types of windows not to arrange
|
|---|
| 942 | * CONST RECT * lpRect rectangle to arrange windows in
|
|---|
| 943 | * UINT cKids number of windows to arrange
|
|---|
| 944 | * const HWND FAR * lpKids array of window handles
|
|---|
| 945 | * Variables :
|
|---|
| 946 | * Result : If the function succeeds, the return value is the number of windows arranged.
|
|---|
| 947 | * If the function fails, the return value is zero.
|
|---|
| 948 | * Remark :
|
|---|
| 949 | * Status : UNTESTED STUB
|
|---|
| 950 | *
|
|---|
| 951 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 952 | *****************************************************************************/
|
|---|
| 953 |
|
|---|
| 954 | WORD WIN32API CascadeWindows(HWND hwndParent,
|
|---|
| 955 | UINT wHow,
|
|---|
| 956 | CONST LPRECT lpRect,
|
|---|
| 957 | UINT cKids,
|
|---|
| 958 | const HWND *lpKids)
|
|---|
| 959 | {
|
|---|
| 960 | dprintf(("USER32:CascadeWindows(%08xh,%u,%08xh,%u,%08x) not implemented.\n",
|
|---|
| 961 | hwndParent,
|
|---|
| 962 | wHow,
|
|---|
| 963 | lpRect,
|
|---|
| 964 | cKids,
|
|---|
| 965 | lpKids));
|
|---|
| 966 |
|
|---|
| 967 | return (0);
|
|---|
| 968 | }
|
|---|
| 969 | /*****************************************************************************
|
|---|
| 970 | * Name : BOOL WIN32API SwitchToThisWindow
|
|---|
| 971 | * Purpose : Unknown
|
|---|
| 972 | * Parameters: Unknown
|
|---|
| 973 | * Variables :
|
|---|
| 974 | * Result :
|
|---|
| 975 | * Remark :
|
|---|
| 976 | * Status : UNTESTED UNKNOWN STUB
|
|---|
| 977 | *
|
|---|
| 978 | * Author : Patrick Haller [Wed, 1998/06/16 11:55]
|
|---|
| 979 | *****************************************************************************/
|
|---|
| 980 |
|
|---|
| 981 | BOOL WIN32API SwitchToThisWindow(HWND hwnd,
|
|---|
| 982 | BOOL x2)
|
|---|
| 983 | {
|
|---|
| 984 | dprintf(("USER32: SwitchToThisWindow(%08xh,%08xh) not implemented.\n",
|
|---|
| 985 | hwnd,
|
|---|
| 986 | x2));
|
|---|
| 987 |
|
|---|
| 988 | return (FALSE); /* default */
|
|---|
| 989 | }
|
|---|
| 990 | //******************************************************************************
|
|---|
| 991 | //******************************************************************************
|
|---|
| 992 | BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 993 | {
|
|---|
| 994 | Win32BaseWindow *window;
|
|---|
| 995 | BOOL rc;
|
|---|
| 996 | ULONG henum;
|
|---|
| 997 | HWND hwndNext;
|
|---|
| 998 | ULONG tid;
|
|---|
| 999 | ULONG pid, curpid;
|
|---|
| 1000 |
|
|---|
| 1001 | dprintf(("EnumThreadWindows\n"));
|
|---|
| 1002 |
|
|---|
| 1003 | curpid = GetCurrentProcessId();
|
|---|
| 1004 |
|
|---|
| 1005 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
|
|---|
| 1006 | while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
|
|---|
| 1007 | {
|
|---|
| 1008 | OSLibWinQueryWindowProcess(hwndNext, &pid, &tid);
|
|---|
| 1009 | if(!(curpid == pid && dwThreadId == tid))
|
|---|
| 1010 | continue;
|
|---|
| 1011 |
|
|---|
| 1012 | window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
|
|---|
| 1013 | if(window == NULL) {
|
|---|
| 1014 | //OS/2 window or non-frame window, so skip it
|
|---|
| 1015 | continue;
|
|---|
| 1016 | }
|
|---|
| 1017 | if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
|
|---|
| 1018 | break;
|
|---|
| 1019 | }
|
|---|
| 1020 | OSLibWinEndEnumWindows (henum);
|
|---|
| 1021 | return TRUE;
|
|---|
| 1022 | }
|
|---|
| 1023 | //******************************************************************************
|
|---|
| 1024 | //******************************************************************************
|
|---|
| 1025 | BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 1026 | {
|
|---|
| 1027 | Win32BaseWindow *window, *parentwindow;
|
|---|
| 1028 | BOOL rc = TRUE;
|
|---|
| 1029 | ULONG henum;
|
|---|
| 1030 | HWND hwndNext;
|
|---|
| 1031 |
|
|---|
| 1032 | dprintf(("EnumChildWindows %x %x\n", hwnd, lParam));
|
|---|
| 1033 |
|
|---|
| 1034 | parentwindow = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1035 | if(!parentwindow) {
|
|---|
| 1036 | dprintf(("EnumChildWindows, window %x not found", hwnd));
|
|---|
| 1037 | return FALSE;
|
|---|
| 1038 | }
|
|---|
| 1039 |
|
|---|
| 1040 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
|
|---|
| 1041 | while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
|
|---|
| 1042 | {
|
|---|
| 1043 | window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
|
|---|
| 1044 | if(window == NULL) {
|
|---|
| 1045 | //OS/2 window or non-frame window, so skip it
|
|---|
| 1046 | continue;
|
|---|
| 1047 | }
|
|---|
| 1048 | if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
|
|---|
| 1049 | {
|
|---|
| 1050 | rc = FALSE;
|
|---|
| 1051 | break;
|
|---|
| 1052 | }
|
|---|
| 1053 | }
|
|---|
| 1054 | OSLibWinEndEnumWindows(henum);
|
|---|
| 1055 | return rc;
|
|---|
| 1056 | }
|
|---|
| 1057 | //******************************************************************************
|
|---|
| 1058 | //******************************************************************************
|
|---|
| 1059 | BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 1060 | {
|
|---|
| 1061 | Win32BaseWindow *window;
|
|---|
| 1062 | BOOL rc;
|
|---|
| 1063 | ULONG henum;
|
|---|
| 1064 | HWND hwndNext, hwndParent = OSLIB_HWND_DESKTOP;
|
|---|
| 1065 |
|
|---|
| 1066 | dprintf(("EnumThreadWindows\n"));
|
|---|
| 1067 |
|
|---|
| 1068 | do {
|
|---|
| 1069 | henum = OSLibWinBeginEnumWindows(hwndParent);
|
|---|
| 1070 | while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
|
|---|
| 1071 | {
|
|---|
| 1072 | window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
|
|---|
| 1073 | if(window == NULL) {
|
|---|
| 1074 | //OS/2 window or non-frame window, so skip it
|
|---|
| 1075 | continue;
|
|---|
| 1076 | }
|
|---|
| 1077 | if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE) {
|
|---|
| 1078 | goto Abort;
|
|---|
| 1079 | }
|
|---|
| 1080 | }
|
|---|
| 1081 | if(hwndParent == OSLIB_HWND_OBJECT)
|
|---|
| 1082 | break;
|
|---|
| 1083 | hwndParent = OSLIB_HWND_OBJECT;
|
|---|
| 1084 | OSLibWinEndEnumWindows(henum);
|
|---|
| 1085 | }
|
|---|
| 1086 | while(TRUE);
|
|---|
| 1087 |
|
|---|
| 1088 | Abort:
|
|---|
| 1089 | OSLibWinEndEnumWindows(henum);
|
|---|
| 1090 | return TRUE;
|
|---|
| 1091 | }
|
|---|
| 1092 | //******************************************************************************
|
|---|
| 1093 | //******************************************************************************
|
|---|
| 1094 | #if 0
|
|---|
| 1095 | BOOL WIN32API GetUpdateRect( HWND hwnd, PRECT lpRect, BOOL bErase)
|
|---|
| 1096 | {
|
|---|
| 1097 | dprintf(("GetUpdateRect %x %d\n", hwnd, bErase));
|
|---|
| 1098 | if (!lpRect) return FALSE;
|
|---|
| 1099 |
|
|---|
| 1100 | return OSLibWinQueryUpdateRect(Win32BaseWindow::Win32ToOS2Handle(hwnd), lpRect);
|
|---|
| 1101 | }
|
|---|
| 1102 | #endif
|
|---|
| 1103 | //******************************************************************************
|
|---|
| 1104 | //******************************************************************************
|
|---|
| 1105 | #if 0
|
|---|
| 1106 | BOOL WIN32API InvalidateRect(HWND hWnd, const RECT *lpRect, BOOL bErase)
|
|---|
| 1107 | {
|
|---|
| 1108 | #ifdef DEBUG
|
|---|
| 1109 | if(lpRect)
|
|---|
| 1110 | WriteLog("USER32: InvalidateRect for window %X (%d,%d)(%d,%d) %d\n", hWnd, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, bErase);
|
|---|
| 1111 | else WriteLog("USER32: InvalidateRect for window %X NULL, %d\n", hWnd, bErase);
|
|---|
| 1112 | #endif
|
|---|
| 1113 |
|
|---|
| 1114 | //CB: bErase no quite the same
|
|---|
| 1115 | hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
|
|---|
| 1116 | if (lpRect)
|
|---|
| 1117 | {
|
|---|
| 1118 | return OSLibWinInvalidateRect(hWnd, (PRECT)lpRect, bErase);
|
|---|
| 1119 | }
|
|---|
| 1120 | else return OSLibWinInvalidateRect(hWnd,NULL,bErase);
|
|---|
| 1121 | }
|
|---|
| 1122 | #endif
|
|---|
| 1123 | //******************************************************************************
|
|---|
| 1124 | //******************************************************************************
|
|---|
| 1125 | UINT WIN32API ArrangeIconicWindows( HWND arg1)
|
|---|
| 1126 | {
|
|---|
| 1127 | #ifdef DEBUG
|
|---|
| 1128 | WriteLog("USER32: ArrangeIconicWindows\n");
|
|---|
| 1129 | #endif
|
|---|
| 1130 | return O32_ArrangeIconicWindows(arg1);
|
|---|
| 1131 | }
|
|---|
| 1132 | //******************************************************************************
|
|---|
| 1133 | //restores iconized window to previous size/position
|
|---|
| 1134 | //******************************************************************************
|
|---|
| 1135 | BOOL WIN32API OpenIcon(HWND hwnd)
|
|---|
| 1136 | {
|
|---|
| 1137 | #ifdef DEBUG
|
|---|
| 1138 | WriteLog("USER32: OpenIcon\n");
|
|---|
| 1139 | #endif
|
|---|
| 1140 | if(!IsIconic(hwnd))
|
|---|
| 1141 | return FALSE;
|
|---|
| 1142 | ShowWindow(hwnd, SW_SHOWNORMAL);
|
|---|
| 1143 | return TRUE;
|
|---|
| 1144 | }
|
|---|
| 1145 | //******************************************************************************
|
|---|
| 1146 | //******************************************************************************
|
|---|
| 1147 | BOOL WIN32API ShowOwnedPopups( HWND arg1, BOOL arg2)
|
|---|
| 1148 | {
|
|---|
| 1149 | dprintf(("USER32: ShowOwnedPopups\n"));
|
|---|
| 1150 | return O32_ShowOwnedPopups(arg1, arg2);
|
|---|
| 1151 | }
|
|---|
| 1152 | //******************************************************************************
|
|---|
| 1153 | //******************************************************************************
|
|---|