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