| 1 | /* $Id: window.cpp,v 1.26 1999-10-27 18:25:24 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 window apis for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1999 Sander van Leeuwen
|
|---|
| 6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
|---|
| 7 | *
|
|---|
| 8 | * Parts based on Wine Windows code (windows\win.c)
|
|---|
| 9 | *
|
|---|
| 10 | * Copyright 1993, 1994 Alexandre Julliard
|
|---|
| 11 | *
|
|---|
| 12 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 13 | *
|
|---|
| 14 | *
|
|---|
| 15 | * TODO: Decide what to do about commands for OS/2 windows (non-Win32 apps)
|
|---|
| 16 | *
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include <os2win.h>
|
|---|
| 20 | #include <misc.h>
|
|---|
| 21 | #include <string.h>
|
|---|
| 22 | #include <stdio.h>
|
|---|
| 23 | #include <win32wbase.h>
|
|---|
| 24 | #include <win32wmdiclient.h>
|
|---|
| 25 | #include <win32wdesktop.h>
|
|---|
| 26 | #include "win32dlg.h"
|
|---|
| 27 | #include <oslibwin.h>
|
|---|
| 28 | #include <oslibgdi.h>
|
|---|
| 29 | #include "user32.h"
|
|---|
| 30 | #include "winicon.h"
|
|---|
| 31 | #include <win\winpos.h>
|
|---|
| 32 |
|
|---|
| 33 | //******************************************************************************
|
|---|
| 34 | //******************************************************************************
|
|---|
| 35 | HWND WIN32API CreateWindowExA(DWORD exStyle, LPCSTR className,
|
|---|
| 36 | LPCSTR windowName, DWORD style, INT x,
|
|---|
| 37 | INT y, INT width, INT height,
|
|---|
| 38 | HWND parent, HMENU menu,
|
|---|
| 39 | HINSTANCE instance, LPVOID data )
|
|---|
| 40 | {
|
|---|
| 41 | Win32BaseWindow *window;
|
|---|
| 42 | ATOM classAtom;
|
|---|
| 43 | CREATESTRUCTA cs;
|
|---|
| 44 | char tmpClass[20];
|
|---|
| 45 |
|
|---|
| 46 | if(exStyle & WS_EX_MDICHILD)
|
|---|
| 47 | return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
|---|
| 48 |
|
|---|
| 49 | /* Find the class atom */
|
|---|
| 50 | if (!HIWORD(className) || !(classAtom = GlobalFindAtomA(className)))
|
|---|
| 51 | {
|
|---|
| 52 | if (!HIWORD(className))
|
|---|
| 53 | {
|
|---|
| 54 | sprintf(tmpClass,"#%d", (int) className);
|
|---|
| 55 | classAtom = GlobalFindAtomA(tmpClass);
|
|---|
| 56 | className = tmpClass;
|
|---|
| 57 | }
|
|---|
| 58 | if (!classAtom)
|
|---|
| 59 | {
|
|---|
| 60 | if (!HIWORD(className)) {
|
|---|
| 61 | dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
|
|---|
| 62 | }
|
|---|
| 63 | else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
|
|---|
| 64 |
|
|---|
| 65 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 66 | return 0;
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | /* Create the window */
|
|---|
| 71 | cs.lpCreateParams = data;
|
|---|
| 72 | cs.hInstance = instance;
|
|---|
| 73 | cs.hMenu = menu;
|
|---|
| 74 | cs.hwndParent = parent;
|
|---|
| 75 | cs.x = x;
|
|---|
| 76 | cs.y = y;
|
|---|
| 77 | cs.cx = width;
|
|---|
| 78 | cs.cy = height;
|
|---|
| 79 | cs.style = style;
|
|---|
| 80 | cs.lpszName = windowName;
|
|---|
| 81 | cs.lpszClass = className;
|
|---|
| 82 | cs.dwExStyle = exStyle;
|
|---|
| 83 | if(HIWORD(className)) {
|
|---|
| 84 | dprintf(("CreateWindowExA: class %s parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle));
|
|---|
| 85 | }
|
|---|
| 86 | else dprintf(("CreateWindowExA: class %d parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle));
|
|---|
| 87 |
|
|---|
| 88 | if(!strcmpi(className, MDICLIENTCLASSNAMEA)) {
|
|---|
| 89 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, FALSE);
|
|---|
| 90 | }
|
|---|
| 91 | else
|
|---|
| 92 | if(!strcmpi((char *) className, DIALOG_CLASS_NAMEA))
|
|---|
| 93 | {
|
|---|
| 94 | DLG_TEMPLATE dlgTemplate = {0};
|
|---|
| 95 | dlgTemplate.style = cs.style;
|
|---|
| 96 | dlgTemplate.exStyle = cs.dwExStyle;
|
|---|
| 97 | dlgTemplate.x = cs.x;
|
|---|
| 98 | dlgTemplate.y = cs.y;
|
|---|
| 99 | dlgTemplate.cx = cs.cx;
|
|---|
| 100 | dlgTemplate.cy = cs.cy;
|
|---|
| 101 | dlgTemplate.className = cs.lpszClass;
|
|---|
| 102 | dlgTemplate.caption = cs.lpszName;
|
|---|
| 103 | window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
|
|---|
| 104 | (LPCSTR) &dlgTemplate,
|
|---|
| 105 | cs.hwndParent,
|
|---|
| 106 | NULL,
|
|---|
| 107 | (LPARAM) data,
|
|---|
| 108 | FALSE);
|
|---|
| 109 | }
|
|---|
| 110 | else {
|
|---|
| 111 | window = new Win32BaseWindow( &cs, classAtom, FALSE );
|
|---|
| 112 | }
|
|---|
| 113 | if(window == NULL)
|
|---|
| 114 | {
|
|---|
| 115 | dprintf(("Win32BaseWindow creation failed!!"));
|
|---|
| 116 | return 0;
|
|---|
| 117 | }
|
|---|
| 118 | if(GetLastError() != 0)
|
|---|
| 119 | {
|
|---|
| 120 | dprintf(("Win32BaseWindow error found!!"));
|
|---|
| 121 | delete window;
|
|---|
| 122 | return 0;
|
|---|
| 123 | }
|
|---|
| 124 | return window->getWindowHandle();
|
|---|
| 125 | }
|
|---|
| 126 | //******************************************************************************
|
|---|
| 127 | //******************************************************************************
|
|---|
| 128 | HWND WIN32API CreateWindowExW(DWORD exStyle, LPCWSTR className,
|
|---|
| 129 | LPCWSTR windowName, DWORD style, INT x,
|
|---|
| 130 | INT y, INT width, INT height,
|
|---|
| 131 | HWND parent, HMENU menu,
|
|---|
| 132 | HINSTANCE instance, LPVOID data )
|
|---|
| 133 | {
|
|---|
| 134 | Win32BaseWindow *window;
|
|---|
| 135 | ATOM classAtom;
|
|---|
| 136 | CREATESTRUCTA cs;
|
|---|
| 137 | char tmpClassA[20];
|
|---|
| 138 | WCHAR tmpClassW[20];
|
|---|
| 139 |
|
|---|
| 140 | if(exStyle & WS_EX_MDICHILD)
|
|---|
| 141 | return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
|
|---|
| 142 |
|
|---|
| 143 | /* Find the class atom */
|
|---|
| 144 | if (!HIWORD(className) || !(classAtom = GlobalFindAtomW(className)))
|
|---|
| 145 | {
|
|---|
| 146 | if (!HIWORD(className))
|
|---|
| 147 | {
|
|---|
| 148 | sprintf(tmpClassA,"#%d", (int) className);
|
|---|
| 149 | AsciiToUnicode(tmpClassA, tmpClassW);
|
|---|
| 150 | classAtom = GlobalFindAtomW(tmpClassW);
|
|---|
| 151 | className = (LPCWSTR)tmpClassW;
|
|---|
| 152 | }
|
|---|
| 153 | if (!classAtom)
|
|---|
| 154 | {
|
|---|
| 155 | if (!HIWORD(className)) {
|
|---|
| 156 | dprintf(("CreateWindowEx32W: bad class name %04x\n", LOWORD(className)));
|
|---|
| 157 | }
|
|---|
| 158 | else dprintf(("CreateWindowEx32W: bad class name "));
|
|---|
| 159 |
|
|---|
| 160 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 161 | return 0;
|
|---|
| 162 | }
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | /* Create the window */
|
|---|
| 166 | cs.lpCreateParams = data;
|
|---|
| 167 | cs.hInstance = instance;
|
|---|
| 168 | cs.hMenu = menu;
|
|---|
| 169 | cs.hwndParent = parent;
|
|---|
| 170 | cs.x = x;
|
|---|
| 171 | cs.y = y;
|
|---|
| 172 | cs.cx = width;
|
|---|
| 173 | cs.cy = height;
|
|---|
| 174 | cs.style = style;
|
|---|
| 175 | cs.lpszName = (LPSTR)windowName;
|
|---|
| 176 | cs.lpszClass = (LPSTR)className;
|
|---|
| 177 | cs.dwExStyle = exStyle;
|
|---|
| 178 |
|
|---|
| 179 | if(!lstrcmpiW(className, (LPWSTR)MDICLIENTCLASSNAMEW)) {
|
|---|
| 180 | window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, TRUE);
|
|---|
| 181 | }
|
|---|
| 182 | else
|
|---|
| 183 | if(!lstrcmpiW(className, (LPWSTR)DIALOG_CLASS_NAMEW))
|
|---|
| 184 | {
|
|---|
| 185 | DLG_TEMPLATE dlgTemplate = {0};
|
|---|
| 186 | dlgTemplate.style = cs.style;
|
|---|
| 187 | dlgTemplate.exStyle = cs.dwExStyle;
|
|---|
| 188 | dlgTemplate.x = cs.x;
|
|---|
| 189 | dlgTemplate.y = cs.y;
|
|---|
| 190 | dlgTemplate.cx = cs.cx;
|
|---|
| 191 | dlgTemplate.cy = cs.cy;
|
|---|
| 192 | dlgTemplate.className = cs.lpszClass;
|
|---|
| 193 | dlgTemplate.caption = cs.lpszName;
|
|---|
| 194 | window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
|
|---|
| 195 | (LPCSTR) &dlgTemplate,
|
|---|
| 196 | cs.hwndParent,
|
|---|
| 197 | NULL,
|
|---|
| 198 | (LPARAM) data,
|
|---|
| 199 | TRUE);
|
|---|
| 200 | }
|
|---|
| 201 | else {
|
|---|
| 202 | window = new Win32BaseWindow( &cs, classAtom, TRUE );
|
|---|
| 203 | }
|
|---|
| 204 | if(window == NULL)
|
|---|
| 205 | {
|
|---|
| 206 | dprintf(("Win32BaseWindow creation failed!!"));
|
|---|
| 207 | return 0;
|
|---|
| 208 | }
|
|---|
| 209 | if(GetLastError() != 0)
|
|---|
| 210 | {
|
|---|
| 211 | dprintf(("Win32BaseWindow error found!!"));
|
|---|
| 212 | delete window;
|
|---|
| 213 | return 0;
|
|---|
| 214 | }
|
|---|
| 215 | return window->getWindowHandle();
|
|---|
| 216 | }
|
|---|
| 217 | //******************************************************************************
|
|---|
| 218 | //******************************************************************************
|
|---|
| 219 | HWND WIN32API CreateMDIWindowA(LPCSTR lpszClassName, LPCSTR lpszWindowName,
|
|---|
| 220 | DWORD dwStyle, int x, int y, int nWidth,
|
|---|
| 221 | int nHeight, HWND hwndParent,
|
|---|
| 222 | HINSTANCE hInstance, LPARAM lParam )
|
|---|
| 223 | {
|
|---|
| 224 | HWND hwnd;
|
|---|
| 225 | MDICREATESTRUCTA cs;
|
|---|
| 226 | Win32BaseWindow *window;
|
|---|
| 227 |
|
|---|
| 228 | window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
|
|---|
| 229 | if(!window) {
|
|---|
| 230 | dprintf(("CreateMDIWindowA, window %x not found", hwndParent));
|
|---|
| 231 | return 0;
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | dprintf(("USER32: CreateMDIWindowA\n"));
|
|---|
| 235 | cs.szClass = lpszClassName;
|
|---|
| 236 | cs.szTitle = lpszWindowName;
|
|---|
| 237 | cs.hOwner = hInstance;
|
|---|
| 238 | cs.x = x;
|
|---|
| 239 | cs.y = y;
|
|---|
| 240 | cs.cx = nHeight;
|
|---|
| 241 | cs.cy = nWidth;
|
|---|
| 242 | cs.style = dwStyle;
|
|---|
| 243 | cs.lParam = lParam;
|
|---|
| 244 |
|
|---|
| 245 | return window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
|
|---|
| 246 | }
|
|---|
| 247 | //******************************************************************************
|
|---|
| 248 | //******************************************************************************
|
|---|
| 249 | HWND WIN32API CreateMDIWindowW(LPCWSTR lpszClassName, LPCWSTR lpszWindowName,
|
|---|
| 250 | DWORD dwStyle, int x, int y, int nWidth,
|
|---|
| 251 | int nHeight, HWND hwndParent,
|
|---|
| 252 | HINSTANCE hInstance, LPARAM lParam )
|
|---|
| 253 | {
|
|---|
| 254 | HWND hwnd;
|
|---|
| 255 | MDICREATESTRUCTW cs;
|
|---|
| 256 | Win32BaseWindow *window;
|
|---|
| 257 |
|
|---|
| 258 | window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
|
|---|
| 259 | if(!window) {
|
|---|
| 260 | dprintf(("CreateMDIWindowW, window %x not found", hwndParent));
|
|---|
| 261 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 262 | return 0;
|
|---|
| 263 | }
|
|---|
| 264 |
|
|---|
| 265 | dprintf(("USER32: CreateMDIWindowW\n"));
|
|---|
| 266 | cs.szClass = lpszClassName;
|
|---|
| 267 | cs.szTitle = lpszWindowName;
|
|---|
| 268 | cs.hOwner = hInstance;
|
|---|
| 269 | cs.x = x;
|
|---|
| 270 | cs.y = y;
|
|---|
| 271 | cs.cx = nHeight;
|
|---|
| 272 | cs.cy = nWidth;
|
|---|
| 273 | cs.style = dwStyle;
|
|---|
| 274 | cs.lParam = lParam;
|
|---|
| 275 |
|
|---|
| 276 | return window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
|
|---|
| 277 | }
|
|---|
| 278 | //******************************************************************************
|
|---|
| 279 | //******************************************************************************
|
|---|
| 280 | BOOL WIN32API DestroyWindow(HWND hwnd)
|
|---|
| 281 | {
|
|---|
| 282 | Win32BaseWindow *window;
|
|---|
| 283 |
|
|---|
| 284 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 285 | if(!window) {
|
|---|
| 286 | dprintf(("DestroyWindow, window %x not found", hwnd));
|
|---|
| 287 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 288 | return 0;
|
|---|
| 289 | }
|
|---|
| 290 | dprintf(("DestroyWindow %x", hwnd));
|
|---|
| 291 | return window->DestroyWindow();
|
|---|
| 292 | }
|
|---|
| 293 | //******************************************************************************
|
|---|
| 294 | //******************************************************************************
|
|---|
| 295 | HWND WIN32API SetActiveWindow( HWND hwnd)
|
|---|
| 296 | {
|
|---|
| 297 | Win32BaseWindow *window;
|
|---|
| 298 |
|
|---|
| 299 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 300 | if(!window) {
|
|---|
| 301 | dprintf(("SetActiveWindow, window %x not found", hwnd));
|
|---|
| 302 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 303 | return 0;
|
|---|
| 304 | }
|
|---|
| 305 | dprintf(("SetActiveWindow %x", hwnd));
|
|---|
| 306 | return window->SetActiveWindow();
|
|---|
| 307 | }
|
|---|
| 308 | //******************************************************************************
|
|---|
| 309 | //******************************************************************************
|
|---|
| 310 | HWND WIN32API GetParent( HWND hwnd)
|
|---|
| 311 | {
|
|---|
| 312 | Win32BaseWindow *window;
|
|---|
| 313 |
|
|---|
| 314 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 315 | if(!window) {
|
|---|
| 316 | dprintf(("GetParent, window %x not found", hwnd));
|
|---|
| 317 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 318 | return 0;
|
|---|
| 319 | }
|
|---|
| 320 | // dprintf(("GetParent %x", hwnd));
|
|---|
| 321 | return window->GetParent();
|
|---|
| 322 | }
|
|---|
| 323 | //******************************************************************************
|
|---|
| 324 | //******************************************************************************
|
|---|
| 325 | HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
|
|---|
| 326 | {
|
|---|
| 327 | Win32BaseWindow *window;
|
|---|
| 328 |
|
|---|
| 329 | window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
|
|---|
| 330 | if(!window) {
|
|---|
| 331 | dprintf(("SetParent, window %x not found", hwndChild));
|
|---|
| 332 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 333 | return 0;
|
|---|
| 334 | }
|
|---|
| 335 | dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
|
|---|
| 336 | return window->SetParent(hwndNewParent);
|
|---|
| 337 | }
|
|---|
| 338 | //******************************************************************************
|
|---|
| 339 | //******************************************************************************
|
|---|
| 340 | BOOL WIN32API IsChild( HWND hwndParent, HWND hwnd)
|
|---|
| 341 | {
|
|---|
| 342 | Win32BaseWindow *window;
|
|---|
| 343 |
|
|---|
| 344 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 345 | if(!window) {
|
|---|
| 346 | dprintf(("IsChild, window %x not found", hwnd));
|
|---|
| 347 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 348 | return 0;
|
|---|
| 349 | }
|
|---|
| 350 | dprintf(("IsChild %x %x", hwndParent, hwnd));
|
|---|
| 351 | return window->IsChild(hwndParent);
|
|---|
| 352 | }
|
|---|
| 353 | //******************************************************************************
|
|---|
| 354 | //******************************************************************************
|
|---|
| 355 | HWND WIN32API GetTopWindow( HWND hwnd)
|
|---|
| 356 | {
|
|---|
| 357 | Win32BaseWindow *window;
|
|---|
| 358 |
|
|---|
| 359 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 360 | if(!window) {
|
|---|
| 361 | dprintf(("GetTopWindow, window %x not found", hwnd));
|
|---|
| 362 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 363 | return 0;
|
|---|
| 364 | }
|
|---|
| 365 | return window->GetTopWindow();
|
|---|
| 366 | }
|
|---|
| 367 | //******************************************************************************
|
|---|
| 368 | //******************************************************************************
|
|---|
| 369 | BOOL WIN32API IsIconic( HWND hwnd)
|
|---|
| 370 | {
|
|---|
| 371 | Win32BaseWindow *window;
|
|---|
| 372 |
|
|---|
| 373 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 374 | if(!window) {
|
|---|
| 375 | dprintf(("IsIconic, window %x not found", hwnd));
|
|---|
| 376 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 377 | return 0;
|
|---|
| 378 | }
|
|---|
| 379 | dprintf(("IsIconic %x", hwnd));
|
|---|
| 380 | return window->IsIconic();
|
|---|
| 381 | }
|
|---|
| 382 | //******************************************************************************
|
|---|
| 383 | //******************************************************************************
|
|---|
| 384 | HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
|
|---|
| 385 | {
|
|---|
| 386 | Win32BaseWindow *window;
|
|---|
| 387 | HWND rc;
|
|---|
| 388 |
|
|---|
| 389 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 390 | if(!window) {
|
|---|
| 391 | dprintf(("GetWindow, window %x not found", hwnd));
|
|---|
| 392 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 393 | return 0;
|
|---|
| 394 | }
|
|---|
| 395 | rc = window->GetWindow(uCmd);
|
|---|
| 396 | return rc;
|
|---|
| 397 | }
|
|---|
| 398 | //******************************************************************************
|
|---|
| 399 | //******************************************************************************
|
|---|
| 400 | BOOL WIN32API EnableWindow( HWND hwnd, BOOL fEnable)
|
|---|
| 401 | {
|
|---|
| 402 | Win32BaseWindow *window;
|
|---|
| 403 |
|
|---|
| 404 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 405 | if(!window) {
|
|---|
| 406 | dprintf(("EnableWindow, window %x not found", hwnd));
|
|---|
| 407 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 408 | return 0;
|
|---|
| 409 | }
|
|---|
| 410 | dprintf(("EnableWindow %x %d", hwnd, fEnable));
|
|---|
| 411 | return window->EnableWindow(fEnable);
|
|---|
| 412 | }
|
|---|
| 413 | //******************************************************************************
|
|---|
| 414 | //******************************************************************************
|
|---|
| 415 | BOOL WIN32API BringWindowToTop(HWND hwnd)
|
|---|
| 416 | {
|
|---|
| 417 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
|
|---|
| 418 | }
|
|---|
| 419 | //******************************************************************************
|
|---|
| 420 | //******************************************************************************
|
|---|
| 421 | HWND WIN32API GetActiveWindow()
|
|---|
| 422 | {
|
|---|
| 423 | return Win32BaseWindow::GetActiveWindow();
|
|---|
| 424 | }
|
|---|
| 425 | //******************************************************************************
|
|---|
| 426 | //******************************************************************************
|
|---|
| 427 | BOOL WIN32API ShowWindow(HWND hwnd, int nCmdShow)
|
|---|
| 428 | {
|
|---|
| 429 | Win32BaseWindow *window;
|
|---|
| 430 |
|
|---|
| 431 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 432 | if(!window) {
|
|---|
| 433 | dprintf(("ShowWindow, window %x not found", hwnd));
|
|---|
| 434 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 435 | return 0;
|
|---|
| 436 | }
|
|---|
| 437 | dprintf(("ShowWindow %x", hwnd));
|
|---|
| 438 | return window->ShowWindow(nCmdShow);
|
|---|
| 439 | }
|
|---|
| 440 | //******************************************************************************
|
|---|
| 441 | //******************************************************************************
|
|---|
| 442 | BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
|
|---|
| 443 | {
|
|---|
| 444 | Win32BaseWindow *window;
|
|---|
| 445 |
|
|---|
| 446 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 447 | if(!window) {
|
|---|
| 448 | dprintf(("SetWindowPos, window %x not found", hwnd));
|
|---|
| 449 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 450 | return 0;
|
|---|
| 451 | }
|
|---|
| 452 | dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
|
|---|
| 453 | return window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
|
|---|
| 454 | }
|
|---|
| 455 | //******************************************************************************
|
|---|
| 456 | //******************************************************************************
|
|---|
| 457 | BOOL WIN32API SetWindowPlacement(HWND hwnd, const WINDOWPLACEMENT *winpos)
|
|---|
| 458 | {
|
|---|
| 459 | Win32BaseWindow *window;
|
|---|
| 460 |
|
|---|
| 461 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 462 | if(!window) {
|
|---|
| 463 | dprintf(("SetWindowPlacement, window %x not found", hwnd));
|
|---|
| 464 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 465 | return 0;
|
|---|
| 466 | }
|
|---|
| 467 | return window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
|
|---|
| 468 | }
|
|---|
| 469 | //******************************************************************************
|
|---|
| 470 | //******************************************************************************
|
|---|
| 471 | BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT arg2)
|
|---|
| 472 | {
|
|---|
| 473 | dprintf(("USER32: GetWindowPlacement\n"));
|
|---|
| 474 | return O32_GetWindowPlacement(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd), arg2);
|
|---|
| 475 | }
|
|---|
| 476 | //******************************************************************************
|
|---|
| 477 | //******************************************************************************
|
|---|
| 478 | BOOL WIN32API IsWindow( HWND hwnd)
|
|---|
| 479 | {
|
|---|
| 480 | Win32BaseWindow *window;
|
|---|
| 481 |
|
|---|
| 482 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 483 | if(!window) {
|
|---|
| 484 | dprintf(("IsWindow, window %x not found", hwnd));
|
|---|
| 485 | return FALSE;
|
|---|
| 486 | }
|
|---|
| 487 | dprintf(("IsWindow %x", hwnd));
|
|---|
| 488 | return window->IsWindow();
|
|---|
| 489 | }
|
|---|
| 490 | //******************************************************************************
|
|---|
| 491 | //******************************************************************************
|
|---|
| 492 | BOOL WIN32API IsWindowEnabled( HWND hwnd)
|
|---|
| 493 | {
|
|---|
| 494 | Win32BaseWindow *window;
|
|---|
| 495 |
|
|---|
| 496 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 497 | if(!window) {
|
|---|
| 498 | dprintf(("IsWindowEnabled, window %x not found", hwnd));
|
|---|
| 499 | return 0;
|
|---|
| 500 | }
|
|---|
| 501 | dprintf(("IsWindowEnabled %x", hwnd));
|
|---|
| 502 | return window->IsWindowEnabled();
|
|---|
| 503 | }
|
|---|
| 504 | //******************************************************************************
|
|---|
| 505 | //******************************************************************************
|
|---|
| 506 | BOOL WIN32API IsWindowVisible( HWND hwnd)
|
|---|
| 507 | {
|
|---|
| 508 | Win32BaseWindow *window;
|
|---|
| 509 | BOOL rc;
|
|---|
| 510 |
|
|---|
| 511 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 512 | if(!window) {
|
|---|
| 513 | dprintf(("IsWindowVisible, window %x not found", hwnd));
|
|---|
| 514 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 515 | return 0;
|
|---|
| 516 | }
|
|---|
| 517 | rc = window->IsWindowVisible();
|
|---|
| 518 | dprintf(("IsWindowVisible %x returned %d", hwnd, rc));
|
|---|
| 519 | return rc;
|
|---|
| 520 | }
|
|---|
| 521 | //******************************************************************************
|
|---|
| 522 | //******************************************************************************
|
|---|
| 523 | HWND WIN32API SetFocus (HWND hwnd)
|
|---|
| 524 | {
|
|---|
| 525 | HWND lastFocus, lastFocus_W, hwnd_O;
|
|---|
| 526 | BOOL activate;
|
|---|
| 527 |
|
|---|
| 528 | hwnd_O = Win32BaseWindow::Win32ToOS2Handle (hwnd);
|
|---|
| 529 | lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
|
|---|
| 530 | activate = ((hwnd_O == lastFocus) || OSLibWinIsChild (lastFocus, hwnd_O));
|
|---|
| 531 | lastFocus_W = Win32BaseWindow::OS2ToWin32Handle (lastFocus);
|
|---|
| 532 |
|
|---|
| 533 | dprintf(("SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
|
|---|
| 534 |
|
|---|
| 535 | return (OSLibWinSetFocus (OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
|
|---|
| 536 | }
|
|---|
| 537 | //******************************************************************************
|
|---|
| 538 | //******************************************************************************
|
|---|
| 539 | HWND WIN32API GetFocus(void)
|
|---|
| 540 | {
|
|---|
| 541 | HWND hwnd;
|
|---|
| 542 |
|
|---|
| 543 | hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
|
|---|
| 544 | dprintf(("USER32: GetFocus %x\n", hwnd));
|
|---|
| 545 | hwnd = Win32BaseWindow::OS2ToWin32Handle(hwnd);
|
|---|
| 546 | return hwnd;
|
|---|
| 547 | }
|
|---|
| 548 | //******************************************************************************
|
|---|
| 549 | //******************************************************************************
|
|---|
| 550 | /***********************************************************************
|
|---|
| 551 | * GetInternalWindowPos (USER32.245)
|
|---|
| 552 | */
|
|---|
| 553 | UINT WIN32API GetInternalWindowPos(HWND hwnd,
|
|---|
| 554 | LPRECT rectWnd,
|
|---|
| 555 | LPPOINT ptIcon )
|
|---|
| 556 | {
|
|---|
| 557 | WINDOWPLACEMENT wndpl;
|
|---|
| 558 |
|
|---|
| 559 | dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
|
|---|
| 560 | hwnd,
|
|---|
| 561 | rectWnd,
|
|---|
| 562 | ptIcon));
|
|---|
| 563 |
|
|---|
| 564 | if (GetWindowPlacement( hwnd, &wndpl ))
|
|---|
| 565 | {
|
|---|
| 566 | if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
|
|---|
| 567 | if (ptIcon) *ptIcon = wndpl.ptMinPosition;
|
|---|
| 568 | return wndpl.showCmd;
|
|---|
| 569 | }
|
|---|
| 570 | return 0;
|
|---|
| 571 | }
|
|---|
| 572 | //******************************************************************************
|
|---|
| 573 | //******************************************************************************
|
|---|
| 574 | BOOL WIN32API IsZoomed(HWND hwnd)
|
|---|
| 575 | {
|
|---|
| 576 | dprintf(("USER32: IsZoomed\n"));
|
|---|
| 577 | return O32_IsZoomed(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
|
|---|
| 578 | }
|
|---|
| 579 | //******************************************************************************
|
|---|
| 580 | //******************************************************************************
|
|---|
| 581 | BOOL WIN32API LockWindowUpdate(HWND hwnd)
|
|---|
| 582 | {
|
|---|
| 583 | dprintf(("USER32: LockWindowUpdate\n"));
|
|---|
| 584 | return O32_LockWindowUpdate(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
|
|---|
| 585 | }
|
|---|
| 586 | //******************************************************************************
|
|---|
| 587 | //******************************************************************************
|
|---|
| 588 | BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
|
|---|
| 589 | {
|
|---|
| 590 | Win32BaseWindow *window;
|
|---|
| 591 | BOOL rc;
|
|---|
| 592 |
|
|---|
| 593 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 594 | if(!window) {
|
|---|
| 595 | dprintf(("GetWindowRect, window %x not found", hwnd));
|
|---|
| 596 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 597 | return 0;
|
|---|
| 598 | }
|
|---|
| 599 | rc = window->GetWindowRect(pRect);
|
|---|
| 600 | dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
|---|
| 601 | return rc;
|
|---|
| 602 | }
|
|---|
| 603 | //******************************************************************************
|
|---|
| 604 | //******************************************************************************
|
|---|
| 605 | int WIN32API GetWindowTextLengthA( HWND hwnd)
|
|---|
| 606 | {
|
|---|
| 607 | Win32BaseWindow *window;
|
|---|
| 608 |
|
|---|
| 609 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 610 | if(!window) {
|
|---|
| 611 | dprintf(("GetWindowTextLength, window %x not found", hwnd));
|
|---|
| 612 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 613 | return 0;
|
|---|
| 614 | }
|
|---|
| 615 | dprintf(("GetWindowTextLength %x", hwnd));
|
|---|
| 616 | return window->GetWindowTextLength();
|
|---|
| 617 | }
|
|---|
| 618 | //******************************************************************************
|
|---|
| 619 | //******************************************************************************
|
|---|
| 620 | int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
|
|---|
| 621 | {
|
|---|
| 622 | Win32BaseWindow *window;
|
|---|
| 623 | int rc;
|
|---|
| 624 |
|
|---|
| 625 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 626 | if(!window) {
|
|---|
| 627 | dprintf(("GetWindowTextA, window %x not found", hwnd));
|
|---|
| 628 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 629 | return 0;
|
|---|
| 630 | }
|
|---|
| 631 | rc = window->GetWindowTextA(lpsz, cch);
|
|---|
| 632 | dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
|
|---|
| 633 | return rc;
|
|---|
| 634 | }
|
|---|
| 635 | //******************************************************************************
|
|---|
| 636 | //******************************************************************************
|
|---|
| 637 | int WIN32API GetWindowTextLengthW( HWND hwnd)
|
|---|
| 638 | {
|
|---|
| 639 | dprintf(("USER32: GetWindowTextLengthW\n"));
|
|---|
| 640 | return GetWindowTextLengthA(hwnd);
|
|---|
| 641 | }
|
|---|
| 642 | //******************************************************************************
|
|---|
| 643 | //******************************************************************************
|
|---|
| 644 | int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
|
|---|
| 645 | {
|
|---|
| 646 | Win32BaseWindow *window;
|
|---|
| 647 |
|
|---|
| 648 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 649 | if(!window) {
|
|---|
| 650 | dprintf(("GetWindowTextW, window %x not found", hwnd));
|
|---|
| 651 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 652 | return 0;
|
|---|
| 653 | }
|
|---|
| 654 | dprintf(("GetWindowTextW %x", hwnd));
|
|---|
| 655 | return window->GetWindowTextW(lpsz, cch);
|
|---|
| 656 | }
|
|---|
| 657 | //******************************************************************************
|
|---|
| 658 | //******************************************************************************
|
|---|
| 659 | BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
|
|---|
| 660 | {
|
|---|
| 661 | Win32BaseWindow *window;
|
|---|
| 662 |
|
|---|
| 663 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 664 | if(!window) {
|
|---|
| 665 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
|---|
| 666 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 667 | return 0;
|
|---|
| 668 | }
|
|---|
| 669 | dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
|
|---|
| 670 | return window->SetWindowTextA((LPSTR)lpsz);
|
|---|
| 671 | }
|
|---|
| 672 | //******************************************************************************
|
|---|
| 673 | //******************************************************************************
|
|---|
| 674 | BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
|
|---|
| 675 | {
|
|---|
| 676 | Win32BaseWindow *window;
|
|---|
| 677 |
|
|---|
| 678 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 679 | if(!window) {
|
|---|
| 680 | dprintf(("SetWindowTextA, window %x not found", hwnd));
|
|---|
| 681 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 682 | return 0;
|
|---|
| 683 | }
|
|---|
| 684 | dprintf(("SetWindowTextW %x", hwnd));
|
|---|
| 685 | return window->SetWindowTextW((LPWSTR)lpsz);
|
|---|
| 686 | }
|
|---|
| 687 | /*******************************************************************
|
|---|
| 688 | * InternalGetWindowText (USER32.326)
|
|---|
| 689 | */
|
|---|
| 690 | int WIN32API InternalGetWindowText(HWND hwnd,
|
|---|
| 691 | LPWSTR lpString,
|
|---|
| 692 | INT nMaxCount )
|
|---|
| 693 | {
|
|---|
| 694 | dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
|
|---|
| 695 | hwnd,
|
|---|
| 696 | lpString,
|
|---|
| 697 | nMaxCount));
|
|---|
| 698 |
|
|---|
| 699 | return GetWindowTextW(hwnd,lpString,nMaxCount);
|
|---|
| 700 | }
|
|---|
| 701 | //******************************************************************************
|
|---|
| 702 | //TODO: Correct?
|
|---|
| 703 | //******************************************************************************
|
|---|
| 704 | BOOL WIN32API SetForegroundWindow(HWND hwnd)
|
|---|
| 705 | {
|
|---|
| 706 | dprintf((" SetForegroundWindow %x", hwnd));
|
|---|
| 707 |
|
|---|
| 708 | return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER );
|
|---|
| 709 | }
|
|---|
| 710 | //******************************************************************************
|
|---|
| 711 | //******************************************************************************
|
|---|
| 712 | BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
|
|---|
| 713 | {
|
|---|
| 714 | BOOL rc;
|
|---|
| 715 | HWND hwndWin32 = hwnd;
|
|---|
| 716 |
|
|---|
| 717 | Win32BaseWindow *window;
|
|---|
| 718 |
|
|---|
| 719 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 720 | if(!window) {
|
|---|
| 721 | dprintf(("GetClientRect, window %x not found", hwnd));
|
|---|
| 722 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 723 | return 0;
|
|---|
| 724 | }
|
|---|
| 725 | *pRect = *window->getClientRect();
|
|---|
| 726 | OffsetRect(pRect, -pRect->left, -pRect->top);
|
|---|
| 727 | dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
|
|---|
| 728 | return TRUE;
|
|---|
| 729 | }
|
|---|
| 730 | //******************************************************************************
|
|---|
| 731 | //******************************************************************************
|
|---|
| 732 | BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
|
|---|
| 733 | {
|
|---|
| 734 | return AdjustWindowRectEx(rect, style, menu, 0);
|
|---|
| 735 | }
|
|---|
| 736 | //******************************************************************************
|
|---|
| 737 | //******************************************************************************
|
|---|
| 738 | BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
|
|---|
| 739 | {
|
|---|
| 740 | dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
|
|---|
| 741 |
|
|---|
| 742 | /* Correct the window style */
|
|---|
| 743 | if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
|
|---|
| 744 | style |= WS_CAPTION;
|
|---|
| 745 |
|
|---|
| 746 | style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL);
|
|---|
| 747 | exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
|
|---|
| 748 | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
|
|---|
| 749 | if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
|
|---|
| 750 |
|
|---|
| 751 | Win32BaseWindow::NC_AdjustRectOuter( rect, style, menu, exStyle );
|
|---|
| 752 | Win32BaseWindow::NC_AdjustRectInner( rect, style, exStyle );
|
|---|
| 753 |
|
|---|
| 754 | dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
|
|---|
| 755 | return TRUE;
|
|---|
| 756 | }
|
|---|
| 757 | //******************************************************************************
|
|---|
| 758 | /* Coordinate Space and Transformation Functions */
|
|---|
| 759 | //******************************************************************************
|
|---|
| 760 | int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
|
|---|
| 761 | UINT cPoints)
|
|---|
| 762 | {
|
|---|
| 763 | Win32BaseWindow *wndfrom, *wndto;
|
|---|
| 764 | int retval = 0;
|
|---|
| 765 | OSLIBPOINT point;
|
|---|
| 766 |
|
|---|
| 767 | if(lpPoints == NULL || cPoints == 0) {
|
|---|
| 768 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 769 | return 0;
|
|---|
| 770 | }
|
|---|
| 771 | if(hwndFrom)
|
|---|
| 772 | {
|
|---|
| 773 | wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
|
|---|
| 774 | if(!wndfrom) {
|
|---|
| 775 | dprintf(("MapWindowPoints, window %x not found", hwndFrom));
|
|---|
| 776 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 777 | return 0;
|
|---|
| 778 | }
|
|---|
| 779 | }
|
|---|
| 780 | else wndfrom = windowDesktop;
|
|---|
| 781 |
|
|---|
| 782 | if(hwndTo)
|
|---|
| 783 | {
|
|---|
| 784 | wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
|
|---|
| 785 | if(!wndto) {
|
|---|
| 786 | dprintf(("MapWindowPoints, window %x not found", hwndTo));
|
|---|
| 787 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 788 | return 0;
|
|---|
| 789 | }
|
|---|
| 790 | }
|
|---|
| 791 | else wndto = windowDesktop;
|
|---|
| 792 |
|
|---|
| 793 | if(wndto == wndfrom)
|
|---|
| 794 | return 0; //nothing to do
|
|---|
| 795 |
|
|---|
| 796 | dprintf(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
|
|---|
| 797 | point.x = lpPoints->x;
|
|---|
| 798 | point.y = wndfrom->getWindowHeight() - lpPoints->y;
|
|---|
| 799 |
|
|---|
| 800 | OSLibWinMapWindowPoints(wndfrom->getOS2WindowHandle(), wndto->getOS2WindowHandle(), &point, 1);
|
|---|
| 801 | point.y = wndto->getWindowHeight() - point.y;
|
|---|
| 802 |
|
|---|
| 803 | short int xinc = point.x - lpPoints->x;
|
|---|
| 804 | short int yinc = point.y - lpPoints->y;
|
|---|
| 805 |
|
|---|
| 806 | for(int i=0;i<cPoints;i++)
|
|---|
| 807 | {
|
|---|
| 808 | lpPoints[i].x += xinc;
|
|---|
| 809 | lpPoints[i].y += yinc;
|
|---|
| 810 | }
|
|---|
| 811 | retval = ((LONG)yinc << 16) | xinc;
|
|---|
| 812 | return retval;
|
|---|
| 813 | }
|
|---|
| 814 | //******************************************************************************
|
|---|
| 815 | //******************************************************************************
|
|---|
| 816 | BOOL WIN32API ScreenToClient (HWND hwnd, LPPOINT pt)
|
|---|
| 817 | {
|
|---|
| 818 | Win32BaseWindow *wnd;
|
|---|
| 819 | PRECT rcl;
|
|---|
| 820 |
|
|---|
| 821 | dprintf(("ScreenToClient %x (%d,%d)\n", hwnd, pt->x, pt->y));
|
|---|
| 822 |
|
|---|
| 823 | if (!hwnd) return (TRUE);
|
|---|
| 824 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
|---|
| 825 | if (!wnd) return (TRUE);
|
|---|
| 826 |
|
|---|
| 827 | rcl = wnd->getClientRect();
|
|---|
| 828 | pt->y = ScreenHeight - pt->y;
|
|---|
| 829 | OSLibWinMapWindowPoints (OSLIB_HWND_DESKTOP, wnd->getOS2WindowHandle(), (OSLIBPOINT *)pt, 1);
|
|---|
| 830 | pt->y = (rcl->bottom - rcl->top) - pt->y;
|
|---|
| 831 | dprintf(("ScreenToClient %x returned (%d,%d)\n", hwnd, pt->x, pt->y));
|
|---|
| 832 | return (TRUE);
|
|---|
| 833 | }
|
|---|
| 834 | //******************************************************************************
|
|---|
| 835 | //******************************************************************************
|
|---|
| 836 | HWND WIN32API GetDesktopWindow(void)
|
|---|
| 837 | {
|
|---|
| 838 | dprintf(("USER32: GetDesktopWindow\n"));
|
|---|
| 839 | return windowDesktop->getWindowHandle();
|
|---|
| 840 | }
|
|---|
| 841 | //******************************************************************************
|
|---|
| 842 | //******************************************************************************
|
|---|
| 843 | HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
|
|---|
| 844 | {
|
|---|
| 845 | if(!lpszClass) {
|
|---|
| 846 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 847 | return 0;
|
|---|
| 848 | }
|
|---|
| 849 | if(HIWORD(lpszClass)) {
|
|---|
| 850 | dprintf(("USER32: FindWindow %s %s\n", lpszClass, lpszWindow));
|
|---|
| 851 | }
|
|---|
| 852 | else dprintf(("USER32: FindWindow %x %s\n", lpszClass, lpszWindow));
|
|---|
| 853 |
|
|---|
| 854 | return Win32BaseWindow::FindWindowEx(OSLIB_HWND_DESKTOP, 0, (LPSTR)lpszClass, (LPSTR)lpszWindow);
|
|---|
| 855 | }
|
|---|
| 856 | //******************************************************************************
|
|---|
| 857 | //******************************************************************************
|
|---|
| 858 | HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
|
|---|
| 859 | {
|
|---|
| 860 | char *astring1 = UnicodeToAsciiString((LPWSTR)lpClassName);
|
|---|
| 861 | char *astring2 = UnicodeToAsciiString((LPWSTR)lpWindowName);
|
|---|
| 862 | HWND rc;
|
|---|
| 863 |
|
|---|
| 864 | rc = FindWindowA(astring1, astring2);
|
|---|
| 865 | FreeAsciiString(astring1);
|
|---|
| 866 | FreeAsciiString(astring2);
|
|---|
| 867 | return rc;
|
|---|
| 868 | }
|
|---|
| 869 | //******************************************************************************
|
|---|
| 870 | //******************************************************************************
|
|---|
| 871 | HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
|
|---|
| 872 | {
|
|---|
| 873 | if(!lpszClass) {
|
|---|
| 874 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 875 | return 0;
|
|---|
| 876 | }
|
|---|
| 877 | if(HIWORD(lpszClass)) {
|
|---|
| 878 | dprintf(("USER32: FindWindowExA (%x,%x) %s %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
|
|---|
| 879 | }
|
|---|
| 880 | else dprintf(("USER32: FindWindowExA (%x,%x)%x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
|
|---|
| 881 |
|
|---|
| 882 | return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
|
|---|
| 883 | }
|
|---|
| 884 | /*****************************************************************************
|
|---|
| 885 | * Name : HWND WIN32API FindWindowExW
|
|---|
| 886 | * Purpose : The FindWindowEx function retrieves the handle of a window whose
|
|---|
| 887 | * class name and window name match the specified strings. The
|
|---|
| 888 | * function searches child windows, beginning with the one following
|
|---|
| 889 | * the given child window.
|
|---|
| 890 | * Parameters: HWND hwndParent handle of parent window
|
|---|
| 891 | * HWND hwndChildAfter handle of a child window
|
|---|
| 892 | * LPCTSTR lpszClass address of class name
|
|---|
| 893 | * LPCTSTR lpszWindow address of window name
|
|---|
| 894 | * Variables :
|
|---|
| 895 | * Result : If the function succeeds, the return value is the handle of the
|
|---|
| 896 | * window that has the specified class and window names.
|
|---|
| 897 | * If the function fails, the return value is NULL. To get extended
|
|---|
| 898 | * error information, call GetLastError.
|
|---|
| 899 | * Remark :
|
|---|
| 900 | * Status : UNTESTED STUB
|
|---|
| 901 | *
|
|---|
| 902 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 903 | *****************************************************************************/
|
|---|
| 904 |
|
|---|
| 905 | HWND WIN32API FindWindowExW(HWND hwndParent,
|
|---|
| 906 | HWND hwndChildAfter,
|
|---|
| 907 | LPCWSTR lpszClass,
|
|---|
| 908 | LPCWSTR lpszWindow)
|
|---|
| 909 | {
|
|---|
| 910 | if(!lpszClass) {
|
|---|
| 911 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 912 | return 0;
|
|---|
| 913 | }
|
|---|
| 914 | dprintf(("USER32: FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
|
|---|
| 915 |
|
|---|
| 916 | return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
|
|---|
| 917 | }
|
|---|
| 918 | //******************************************************************************
|
|---|
| 919 | //******************************************************************************
|
|---|
| 920 | BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
|
|---|
| 921 | {
|
|---|
| 922 | dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
|
|---|
| 923 | return OSLibWinFlashWindow(Win32BaseWindow::Win32ToOS2Handle(hwnd), fFlash);
|
|---|
| 924 | }
|
|---|
| 925 | //******************************************************************************
|
|---|
| 926 | //******************************************************************************
|
|---|
| 927 | BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
|
|---|
| 928 | BOOL repaint )
|
|---|
| 929 | {
|
|---|
| 930 | int flags = SWP_NOZORDER | SWP_NOACTIVATE;
|
|---|
| 931 |
|
|---|
| 932 | if (!repaint) flags |= SWP_NOREDRAW;
|
|---|
| 933 | dprintf(("MoveWindow: %04x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
|
|---|
| 934 |
|
|---|
| 935 | return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
|
|---|
| 936 | }
|
|---|
| 937 | //******************************************************************************
|
|---|
| 938 | //******************************************************************************
|
|---|
| 939 | BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
|
|---|
| 940 | {
|
|---|
| 941 | Win32BaseWindow *wnd;
|
|---|
| 942 | PRECT rcl;
|
|---|
| 943 |
|
|---|
| 944 | dprintf(("ClientToScreen (%d,%d)\n", pt->x, pt->y));
|
|---|
| 945 | if (!hwnd) {
|
|---|
| 946 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 947 | return (FALSE);
|
|---|
| 948 | }
|
|---|
| 949 | wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
|
|---|
| 950 | if (!wnd) {
|
|---|
| 951 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 952 | return (FALSE);
|
|---|
| 953 | }
|
|---|
| 954 |
|
|---|
| 955 | rcl = wnd->getClientRect();
|
|---|
| 956 | pt->y = (rcl->bottom - rcl->top) - pt->y;
|
|---|
| 957 | OSLibWinMapWindowPoints (wnd->getOS2WindowHandle(), OSLIB_HWND_DESKTOP, (OSLIBPOINT *)pt, 1);
|
|---|
| 958 | pt->y = ScreenHeight - pt->y;
|
|---|
| 959 | dprintf(("ClientToScreen returned (%d,%d)\n", pt->x, pt->y));
|
|---|
| 960 | return (TRUE);
|
|---|
| 961 | }
|
|---|
| 962 | //******************************************************************************
|
|---|
| 963 | //******************************************************************************
|
|---|
| 964 | HDWP WIN32API BeginDeferWindowPos(int count)
|
|---|
| 965 | {
|
|---|
| 966 | HDWP handle;
|
|---|
| 967 | DWP *pDWP;
|
|---|
| 968 |
|
|---|
| 969 | dprintf(("USER32: BeginDeferWindowPos\n"));
|
|---|
| 970 | if (count <= 0)
|
|---|
| 971 | {
|
|---|
| 972 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 973 | return 0;
|
|---|
| 974 | }
|
|---|
| 975 | handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS) );
|
|---|
| 976 | if (!handle)
|
|---|
| 977 | return 0;
|
|---|
| 978 |
|
|---|
| 979 | pDWP = (DWP *) handle;
|
|---|
| 980 | pDWP->actualCount = 0;
|
|---|
| 981 | pDWP->suggestedCount = count;
|
|---|
| 982 | pDWP->valid = TRUE;
|
|---|
| 983 | pDWP->wMagic = DWP_MAGIC;
|
|---|
| 984 | pDWP->hwndParent = 0;
|
|---|
| 985 | return handle;
|
|---|
| 986 | }
|
|---|
| 987 | /***********************************************************************
|
|---|
| 988 | * DeferWindowPos (USER32.128)
|
|---|
| 989 | */
|
|---|
| 990 | HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
|
|---|
| 991 | INT x, INT y, INT cx, INT cy,
|
|---|
| 992 | UINT flags )
|
|---|
| 993 | {
|
|---|
| 994 | DWP *pDWP;
|
|---|
| 995 | int i;
|
|---|
| 996 | HDWP newhdwp = hdwp,retvalue;
|
|---|
| 997 | Win32BaseWindow *window;
|
|---|
| 998 |
|
|---|
| 999 | pDWP = (DWP *)hdwp;
|
|---|
| 1000 | if (!pDWP) {
|
|---|
| 1001 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 1002 | return 0;
|
|---|
| 1003 | }
|
|---|
| 1004 |
|
|---|
| 1005 | if (hwnd == GetDesktopWindow())
|
|---|
| 1006 | return 0;
|
|---|
| 1007 |
|
|---|
| 1008 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1009 | if(!window) {
|
|---|
| 1010 | dprintf(("DeferWindowPos, window %x not found", hwnd));
|
|---|
| 1011 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 1012 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
|---|
| 1013 | return 0;
|
|---|
| 1014 | }
|
|---|
| 1015 |
|
|---|
| 1016 |
|
|---|
| 1017 | /* Numega Bounds Checker Demo dislikes the following code.
|
|---|
| 1018 | In fact, I've not been able to find any "same parent" requirement in any docu
|
|---|
| 1019 | [AM 980509]
|
|---|
| 1020 | */
|
|---|
| 1021 | #if 0
|
|---|
| 1022 | /* All the windows of a DeferWindowPos() must have the same parent */
|
|---|
| 1023 | parent = pWnd->parent->hwndSelf;
|
|---|
| 1024 | if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
|
|---|
| 1025 | else if (parent != pDWP->hwndParent)
|
|---|
| 1026 | {
|
|---|
| 1027 | USER_HEAP_FREE( hdwp );
|
|---|
| 1028 | retvalue = 0;
|
|---|
| 1029 | goto END;
|
|---|
| 1030 | }
|
|---|
| 1031 | #endif
|
|---|
| 1032 |
|
|---|
| 1033 | for (i = 0; i < pDWP->actualCount; i++)
|
|---|
| 1034 | {
|
|---|
| 1035 | if (pDWP->winPos[i].hwnd == hwnd)
|
|---|
| 1036 | {
|
|---|
| 1037 | /* Merge with the other changes */
|
|---|
| 1038 | if (!(flags & SWP_NOZORDER))
|
|---|
| 1039 | {
|
|---|
| 1040 | pDWP->winPos[i].hwndInsertAfter = hwndAfter;
|
|---|
| 1041 | }
|
|---|
| 1042 | if (!(flags & SWP_NOMOVE))
|
|---|
| 1043 | {
|
|---|
| 1044 | pDWP->winPos[i].x = x;
|
|---|
| 1045 | pDWP->winPos[i].y = y;
|
|---|
| 1046 | }
|
|---|
| 1047 | if (!(flags & SWP_NOSIZE))
|
|---|
| 1048 | {
|
|---|
| 1049 | pDWP->winPos[i].cx = cx;
|
|---|
| 1050 | pDWP->winPos[i].cy = cy;
|
|---|
| 1051 | }
|
|---|
| 1052 | pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
|
|---|
| 1053 | SWP_NOZORDER | SWP_NOREDRAW |
|
|---|
| 1054 | SWP_NOACTIVATE | SWP_NOCOPYBITS|
|
|---|
| 1055 | SWP_NOOWNERZORDER);
|
|---|
| 1056 | pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
|
|---|
| 1057 | SWP_FRAMECHANGED);
|
|---|
| 1058 | retvalue = hdwp;
|
|---|
| 1059 | goto END;
|
|---|
| 1060 | }
|
|---|
| 1061 | }
|
|---|
| 1062 | if (pDWP->actualCount >= pDWP->suggestedCount)
|
|---|
| 1063 | {
|
|---|
| 1064 | newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
|
|---|
| 1065 | sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
|
|---|
| 1066 | if (!newhdwp)
|
|---|
| 1067 | {
|
|---|
| 1068 | retvalue = 0;
|
|---|
| 1069 | goto END;
|
|---|
| 1070 | }
|
|---|
| 1071 | pDWP = (DWP *) newhdwp;
|
|---|
| 1072 | pDWP->suggestedCount++;
|
|---|
| 1073 | }
|
|---|
| 1074 | pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
|
|---|
| 1075 | pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
|
|---|
| 1076 | pDWP->winPos[pDWP->actualCount].x = x;
|
|---|
| 1077 | pDWP->winPos[pDWP->actualCount].y = y;
|
|---|
| 1078 | pDWP->winPos[pDWP->actualCount].cx = cx;
|
|---|
| 1079 | pDWP->winPos[pDWP->actualCount].cy = cy;
|
|---|
| 1080 | pDWP->winPos[pDWP->actualCount].flags = flags;
|
|---|
| 1081 | pDWP->actualCount++;
|
|---|
| 1082 | retvalue = newhdwp;
|
|---|
| 1083 | END:
|
|---|
| 1084 | return retvalue;
|
|---|
| 1085 | }
|
|---|
| 1086 | //******************************************************************************
|
|---|
| 1087 | //******************************************************************************
|
|---|
| 1088 | BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
|
|---|
| 1089 | {
|
|---|
| 1090 | DWP *pDWP;
|
|---|
| 1091 | WINDOWPOS *winpos;
|
|---|
| 1092 | BOOL res = TRUE;
|
|---|
| 1093 | int i;
|
|---|
| 1094 |
|
|---|
| 1095 | pDWP = (DWP *) hdwp;
|
|---|
| 1096 | if (!pDWP) {
|
|---|
| 1097 | dprintf(("**EndDeferWindowPos invalid parameter\n"));
|
|---|
| 1098 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 1099 | return FALSE;
|
|---|
| 1100 | }
|
|---|
| 1101 | dprintf(("**EndDeferWindowPos for %d windows", pDWP->actualCount));
|
|---|
| 1102 | for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
|
|---|
| 1103 | {
|
|---|
| 1104 | dprintf(("**EndDeferWindowPos %x (%d,%d) (%d,%d) %x", winpos->hwnd, winpos->x, winpos->y, winpos->x, winpos->cy, winpos->flags));
|
|---|
| 1105 | if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
|
|---|
| 1106 | winpos->x, winpos->y, winpos->cx,
|
|---|
| 1107 | winpos->cy, winpos->flags )))
|
|---|
| 1108 | break;
|
|---|
| 1109 | }
|
|---|
| 1110 | dprintf(("**EndDeferWindowPos DONE"));
|
|---|
| 1111 | HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
|
|---|
| 1112 | return res;
|
|---|
| 1113 | }
|
|---|
| 1114 | //******************************************************************************
|
|---|
| 1115 | //******************************************************************************
|
|---|
| 1116 | HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
|
|---|
| 1117 | {
|
|---|
| 1118 | dprintf(("USER32: ChildWindowFromPoint\n"));
|
|---|
| 1119 | // return O32_ChildWindowFromPoint(arg1, arg2);
|
|---|
| 1120 | return ChildWindowFromPointEx(hwnd, pt, 0);
|
|---|
| 1121 | }
|
|---|
| 1122 | //******************************************************************************
|
|---|
| 1123 | //******************************************************************************
|
|---|
| 1124 | /*****************************************************************************
|
|---|
| 1125 | * Name : HWND WIN32API ChildWindowFromPointEx
|
|---|
| 1126 | * Purpose : The GetWindowRect function retrieves the dimensions of the
|
|---|
| 1127 | * bounding rectangle of the specified window. The dimensions are
|
|---|
| 1128 | * given in screen coordinates that are relative to the upper-left
|
|---|
| 1129 | * corner of the screen.
|
|---|
| 1130 | * Parameters:
|
|---|
| 1131 | * Variables :
|
|---|
| 1132 | * Result : If the function succeeds, the return value is the window handle.
|
|---|
| 1133 | * If the function fails, the return value is zero
|
|---|
| 1134 | * Remark :
|
|---|
| 1135 | * Status : FULLY IMPLEMENTED AND TESTED
|
|---|
| 1136 | *
|
|---|
| 1137 | * Author : Rene Pronk [Sun, 1999/08/08 23:30]
|
|---|
| 1138 | *****************************************************************************/
|
|---|
| 1139 |
|
|---|
| 1140 | HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
|
|---|
| 1141 | {
|
|---|
| 1142 | RECT rect;
|
|---|
| 1143 | HWND hWnd;
|
|---|
| 1144 | POINT absolutePt;
|
|---|
| 1145 |
|
|---|
| 1146 | dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
|
|---|
| 1147 | hwndParent, pt, uFlags));
|
|---|
| 1148 |
|
|---|
| 1149 | if (GetWindowRect (hwndParent, &rect) == 0) {
|
|---|
| 1150 | // oops, invalid handle
|
|---|
| 1151 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 1152 | return NULL;
|
|---|
| 1153 | }
|
|---|
| 1154 |
|
|---|
| 1155 | // absolutePt has its top in the upper-left corner of the screen
|
|---|
| 1156 | absolutePt = pt;
|
|---|
| 1157 | ClientToScreen (hwndParent, &absolutePt);
|
|---|
| 1158 |
|
|---|
| 1159 | // make rect the size of the parent window
|
|---|
| 1160 | GetWindowRect (hwndParent, &rect);
|
|---|
| 1161 | rect.right = rect.right - rect.left;
|
|---|
| 1162 | rect.bottom = rect.bottom - rect.top;
|
|---|
| 1163 | rect.left = 0;
|
|---|
| 1164 | rect.top = 0;
|
|---|
| 1165 |
|
|---|
| 1166 | if (PtInRect (&rect, pt) == 0) {
|
|---|
| 1167 | // point is outside window
|
|---|
| 1168 | return NULL;
|
|---|
| 1169 | }
|
|---|
| 1170 |
|
|---|
| 1171 | // get first child
|
|---|
| 1172 | hWnd = GetWindow (hwndParent, GW_CHILD);
|
|---|
| 1173 |
|
|---|
| 1174 | while (hWnd != NULL) {
|
|---|
| 1175 |
|
|---|
| 1176 | // do I need to skip this window?
|
|---|
| 1177 | if (((uFlags & CWP_SKIPINVISIBLE) &&
|
|---|
| 1178 | (IsWindowVisible (hWnd) == FALSE)) ||
|
|---|
| 1179 | ((uFlags & CWP_SKIPDISABLED) &&
|
|---|
| 1180 | (IsWindowEnabled (hWnd) == FALSE)) ||
|
|---|
| 1181 | ((uFlags & CWP_SKIPTRANSPARENT) &&
|
|---|
| 1182 | (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
|
|---|
| 1183 |
|
|---|
| 1184 | {
|
|---|
| 1185 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
|---|
| 1186 | continue;
|
|---|
| 1187 | }
|
|---|
| 1188 |
|
|---|
| 1189 | // is the point in this window's rect?
|
|---|
| 1190 | GetWindowRect (hWnd, &rect);
|
|---|
| 1191 | if (PtInRect (&rect, absolutePt) == FALSE) {
|
|---|
| 1192 | hWnd = GetWindow (hWnd, GW_HWNDNEXT);
|
|---|
| 1193 | continue;
|
|---|
| 1194 | }
|
|---|
| 1195 |
|
|---|
| 1196 | dprintf(("ChildWindowFromPointEx returned %x", hWnd));
|
|---|
| 1197 | // found it!
|
|---|
| 1198 | return hWnd;
|
|---|
| 1199 | }
|
|---|
| 1200 |
|
|---|
| 1201 | // the point is in the parentwindow but the parentwindow has no child
|
|---|
| 1202 | // at this coordinate
|
|---|
| 1203 | dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
|
|---|
| 1204 | return hwndParent;
|
|---|
| 1205 | }
|
|---|
| 1206 | //******************************************************************************
|
|---|
| 1207 | //******************************************************************************
|
|---|
| 1208 | BOOL WIN32API CloseWindow(HWND hwnd)
|
|---|
| 1209 | {
|
|---|
| 1210 | Win32BaseWindow *window;
|
|---|
| 1211 |
|
|---|
| 1212 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1213 | if(!window) {
|
|---|
| 1214 | dprintf(("CloseWindow, window %x not found", hwnd));
|
|---|
| 1215 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 1216 | return 0;
|
|---|
| 1217 | }
|
|---|
| 1218 | dprintf(("CloseWindow %x\n", hwnd));
|
|---|
| 1219 | return window->CloseWindow();
|
|---|
| 1220 | }
|
|---|
| 1221 | //******************************************************************************
|
|---|
| 1222 | //TODO: Does this return handles of hidden or disabled windows?
|
|---|
| 1223 | //******************************************************************************
|
|---|
| 1224 | HWND WIN32API WindowFromPoint( POINT point)
|
|---|
| 1225 | {
|
|---|
| 1226 | HWND hwnd;
|
|---|
| 1227 |
|
|---|
| 1228 | dprintf(("WindowFromPoint (%d,%d)\n", point.x, point.y));
|
|---|
| 1229 | hwnd = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&point);
|
|---|
| 1230 | if(hwnd) {
|
|---|
| 1231 | return Win32BaseWindow::OS2ToWin32Handle(hwnd);
|
|---|
| 1232 | }
|
|---|
| 1233 | return 0;
|
|---|
| 1234 | }
|
|---|
| 1235 | //******************************************************************************
|
|---|
| 1236 | //******************************************************************************
|
|---|
| 1237 | BOOL WIN32API IsWindowUnicode(HWND hwnd)
|
|---|
| 1238 | {
|
|---|
| 1239 | Win32BaseWindow *window;
|
|---|
| 1240 |
|
|---|
| 1241 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1242 | if(!window) {
|
|---|
| 1243 | dprintf(("IsWindowUnicode, window %x not found", hwnd));
|
|---|
| 1244 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 1245 | return 0;
|
|---|
| 1246 | }
|
|---|
| 1247 | return window->IsUnicode();
|
|---|
| 1248 | }
|
|---|
| 1249 | /*****************************************************************************
|
|---|
| 1250 | * Name : WORD WIN32API CascadeWindows
|
|---|
| 1251 | * Purpose : The CascadeWindows function cascades the specified windows or
|
|---|
| 1252 | * the child windows of the specified parent window.
|
|---|
| 1253 | * Parameters: HWND hwndParent handle of parent window
|
|---|
| 1254 | * UINT wHow types of windows not to arrange
|
|---|
| 1255 | * CONST RECT * lpRect rectangle to arrange windows in
|
|---|
| 1256 | * UINT cKids number of windows to arrange
|
|---|
| 1257 | * const HWND FAR * lpKids array of window handles
|
|---|
| 1258 | * Variables :
|
|---|
| 1259 | * Result : If the function succeeds, the return value is the number of windows arranged.
|
|---|
| 1260 | * If the function fails, the return value is zero.
|
|---|
| 1261 | * Remark :
|
|---|
| 1262 | * Status : UNTESTED STUB
|
|---|
| 1263 | *
|
|---|
| 1264 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 1265 | *****************************************************************************/
|
|---|
| 1266 |
|
|---|
| 1267 | WORD WIN32API CascadeWindows(HWND hwndParent,
|
|---|
| 1268 | UINT wHow,
|
|---|
| 1269 | CONST LPRECT lpRect,
|
|---|
| 1270 | UINT cKids,
|
|---|
| 1271 | const HWND *lpKids)
|
|---|
| 1272 | {
|
|---|
| 1273 | dprintf(("USER32:CascadeWindows(%08xh,%u,%08xh,%u,%08x) not implemented.\n",
|
|---|
| 1274 | hwndParent,
|
|---|
| 1275 | wHow,
|
|---|
| 1276 | lpRect,
|
|---|
| 1277 | cKids,
|
|---|
| 1278 | lpKids));
|
|---|
| 1279 |
|
|---|
| 1280 | return (0);
|
|---|
| 1281 | }
|
|---|
| 1282 | /*****************************************************************************
|
|---|
| 1283 | * Name : BOOL WIN32API SwitchToThisWindow
|
|---|
| 1284 | * Purpose : Unknown
|
|---|
| 1285 | * Parameters: Unknown
|
|---|
| 1286 | * Variables :
|
|---|
| 1287 | * Result :
|
|---|
| 1288 | * Remark :
|
|---|
| 1289 | * Status : UNTESTED UNKNOWN STUB
|
|---|
| 1290 | *
|
|---|
| 1291 | * Author : Patrick Haller [Wed, 1998/06/16 11:55]
|
|---|
| 1292 | *****************************************************************************/
|
|---|
| 1293 |
|
|---|
| 1294 | BOOL WIN32API SwitchToThisWindow(HWND hwnd,
|
|---|
| 1295 | BOOL x2)
|
|---|
| 1296 | {
|
|---|
| 1297 | dprintf(("USER32: SwitchToThisWindow(%08xh,%08xh) not implemented.\n",
|
|---|
| 1298 | hwnd,
|
|---|
| 1299 | x2));
|
|---|
| 1300 |
|
|---|
| 1301 | return (FALSE); /* default */
|
|---|
| 1302 | }
|
|---|
| 1303 | //******************************************************************************
|
|---|
| 1304 | //******************************************************************************
|
|---|
| 1305 | BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 1306 | {
|
|---|
| 1307 | Win32BaseWindow *window;
|
|---|
| 1308 | BOOL rc;
|
|---|
| 1309 | ULONG henum;
|
|---|
| 1310 | HWND hwndNext;
|
|---|
| 1311 | ULONG tid;
|
|---|
| 1312 | ULONG pid, curpid;
|
|---|
| 1313 |
|
|---|
| 1314 | dprintf(("EnumThreadWindows\n"));
|
|---|
| 1315 |
|
|---|
| 1316 | curpid = GetCurrentProcessId();
|
|---|
| 1317 |
|
|---|
| 1318 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
|
|---|
| 1319 | while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
|
|---|
| 1320 | {
|
|---|
| 1321 | OSLibWinQueryWindowProcess(hwndNext, &pid, &tid);
|
|---|
| 1322 | if(!(curpid == pid && dwThreadId == tid))
|
|---|
| 1323 | continue;
|
|---|
| 1324 |
|
|---|
| 1325 | window = Win32BaseWindow::GetWindowFromOS2Handle(hwndNext);
|
|---|
| 1326 | if(window == NULL) {
|
|---|
| 1327 | window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndNext);
|
|---|
| 1328 | if(!window) {
|
|---|
| 1329 | //OS/2 window or non-frame window, so skip it
|
|---|
| 1330 | continue;
|
|---|
| 1331 | }
|
|---|
| 1332 | }
|
|---|
| 1333 | if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
|
|---|
| 1334 | break;
|
|---|
| 1335 | }
|
|---|
| 1336 | OSLibWinEndEnumWindows (henum);
|
|---|
| 1337 | return TRUE;
|
|---|
| 1338 | }
|
|---|
| 1339 | //******************************************************************************
|
|---|
| 1340 | //******************************************************************************
|
|---|
| 1341 | BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 1342 | {
|
|---|
| 1343 | Win32BaseWindow *window;
|
|---|
| 1344 | BOOL rc = TRUE;
|
|---|
| 1345 | ULONG henum;
|
|---|
| 1346 | HWND hwndNext;
|
|---|
| 1347 |
|
|---|
| 1348 | if(lpfn == NULL) {
|
|---|
| 1349 | dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
|
|---|
| 1350 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 1351 | return FALSE;
|
|---|
| 1352 | }
|
|---|
| 1353 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 1354 | if(!window) {
|
|---|
| 1355 | dprintf(("EnumChildWindows, window %x not found", hwnd));
|
|---|
| 1356 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 1357 | return FALSE;
|
|---|
| 1358 | }
|
|---|
| 1359 | return window->EnumChildWindows(lpfn, lParam);
|
|---|
| 1360 | }
|
|---|
| 1361 | //******************************************************************************
|
|---|
| 1362 | //******************************************************************************
|
|---|
| 1363 | BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 1364 | {
|
|---|
| 1365 | Win32BaseWindow *window;
|
|---|
| 1366 | BOOL rc;
|
|---|
| 1367 | ULONG henum;
|
|---|
| 1368 | HWND hwndNext, hwndParent = OSLIB_HWND_DESKTOP;
|
|---|
| 1369 |
|
|---|
| 1370 | dprintf(("EnumThreadWindows\n"));
|
|---|
| 1371 |
|
|---|
| 1372 | do {
|
|---|
| 1373 | henum = OSLibWinBeginEnumWindows(hwndParent);
|
|---|
| 1374 | while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
|
|---|
| 1375 | {
|
|---|
| 1376 | window = Win32BaseWindow::GetWindowFromOS2Handle(hwndNext);
|
|---|
| 1377 | if(window == NULL) {
|
|---|
| 1378 | window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndNext);
|
|---|
| 1379 | if(!window) {
|
|---|
| 1380 | //OS/2 window or non-frame window, so skip it
|
|---|
| 1381 | continue;
|
|---|
| 1382 | }
|
|---|
| 1383 | }
|
|---|
| 1384 | if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE) {
|
|---|
| 1385 | goto Abort;
|
|---|
| 1386 | }
|
|---|
| 1387 | }
|
|---|
| 1388 | if(hwndParent == OSLIB_HWND_OBJECT)
|
|---|
| 1389 | break;
|
|---|
| 1390 | hwndParent = OSLIB_HWND_OBJECT;
|
|---|
| 1391 | OSLibWinEndEnumWindows(henum);
|
|---|
| 1392 | }
|
|---|
| 1393 | while(TRUE);
|
|---|
| 1394 |
|
|---|
| 1395 | Abort:
|
|---|
| 1396 | OSLibWinEndEnumWindows(henum);
|
|---|
| 1397 | return TRUE;
|
|---|
| 1398 | }
|
|---|
| 1399 | //******************************************************************************
|
|---|
| 1400 | //******************************************************************************
|
|---|
| 1401 | UINT WIN32API ArrangeIconicWindows( HWND arg1)
|
|---|
| 1402 | {
|
|---|
| 1403 | #ifdef DEBUG
|
|---|
| 1404 | WriteLog("USER32: ArrangeIconicWindows\n");
|
|---|
| 1405 | #endif
|
|---|
| 1406 | return O32_ArrangeIconicWindows(arg1);
|
|---|
| 1407 | }
|
|---|
| 1408 | //******************************************************************************
|
|---|
| 1409 | //restores iconized window to previous size/position
|
|---|
| 1410 | //******************************************************************************
|
|---|
| 1411 | BOOL WIN32API OpenIcon(HWND hwnd)
|
|---|
| 1412 | {
|
|---|
| 1413 | #ifdef DEBUG
|
|---|
| 1414 | WriteLog("USER32: OpenIcon\n");
|
|---|
| 1415 | #endif
|
|---|
| 1416 | if(!IsIconic(hwnd))
|
|---|
| 1417 | return FALSE;
|
|---|
| 1418 | ShowWindow(hwnd, SW_SHOWNORMAL);
|
|---|
| 1419 | return TRUE;
|
|---|
| 1420 | }
|
|---|
| 1421 | //******************************************************************************
|
|---|
| 1422 | //******************************************************************************
|
|---|
| 1423 | BOOL WIN32API ShowOwnedPopups( HWND arg1, BOOL arg2)
|
|---|
| 1424 | {
|
|---|
| 1425 | dprintf(("USER32: ShowOwnedPopups\n"));
|
|---|
| 1426 | return O32_ShowOwnedPopups(arg1, arg2);
|
|---|
| 1427 | }
|
|---|
| 1428 | //******************************************************************************
|
|---|
| 1429 | //******************************************************************************
|
|---|
| 1430 |
|
|---|