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