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