| 1 | /* $Id: win32wbase.cpp,v 1.177 2000-04-07 12:55:16 sandervl Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Win32 Window Base Class for OS/2 | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 6 | * Copyright 1999      Daniela Engert (dani@ngrt.de) | 
|---|
| 7 | * Copyright 1999-2000 Christoph Bratschi (cbratschi@datacomm.ch) | 
|---|
| 8 | * | 
|---|
| 9 | * Parts based on Wine Windows code (windows\win.c) | 
|---|
| 10 | *   Corel version: corel20000212 | 
|---|
| 11 | * | 
|---|
| 12 | * Copyright 1993, 1994, 1996 Alexandre Julliard | 
|---|
| 13 | *           1995 Alex Korobka | 
|---|
| 14 | * | 
|---|
| 15 | * TODO: Not thread/process safe | 
|---|
| 16 | * | 
|---|
| 17 | * NOTE: Client rectangle always relative to frame window; window rectangle in screen coordinates | 
|---|
| 18 | * | 
|---|
| 19 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 20 | * | 
|---|
| 21 | */ | 
|---|
| 22 | #include <os2win.h> | 
|---|
| 23 | #include <win.h> | 
|---|
| 24 | #include <stdlib.h> | 
|---|
| 25 | #include <string.h> | 
|---|
| 26 | #include <stdarg.h> | 
|---|
| 27 | #include <assert.h> | 
|---|
| 28 | #include <misc.h> | 
|---|
| 29 | #include <heapstring.h> | 
|---|
| 30 | #include <win32wbase.h> | 
|---|
| 31 | #include <winres.h> | 
|---|
| 32 | #include "wndmsg.h" | 
|---|
| 33 | #include "oslibwin.h" | 
|---|
| 34 | #include "oslibmsg.h" | 
|---|
| 35 | #include "oslibutil.h" | 
|---|
| 36 | #include "oslibgdi.h" | 
|---|
| 37 | #include "oslibres.h" | 
|---|
| 38 | #include "oslibdos.h" | 
|---|
| 39 | #include "syscolor.h" | 
|---|
| 40 | #include "win32wndhandle.h" | 
|---|
| 41 | #include "dc.h" | 
|---|
| 42 | #include "pmframe.h" | 
|---|
| 43 | #include "win32wdesktop.h" | 
|---|
| 44 | #include "pmwindow.h" | 
|---|
| 45 | #include "controls.h" | 
|---|
| 46 | #include <wprocess.h> | 
|---|
| 47 | #include <win\hook.h> | 
|---|
| 48 | #include <menu.h> | 
|---|
| 49 | #define INCL_TIMERWIN32 | 
|---|
| 50 | #include "timer.h" | 
|---|
| 51 |  | 
|---|
| 52 | #define DBG_LOCALLOG    DBG_win32wbase | 
|---|
| 53 | #include "dbglocal.h" | 
|---|
| 54 |  | 
|---|
| 55 | /* bits in the dwKeyData */ | 
|---|
| 56 | #define KEYDATA_ALT         0x2000 | 
|---|
| 57 | #define KEYDATA_PREVSTATE   0x4000 | 
|---|
| 58 |  | 
|---|
| 59 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle); | 
|---|
| 60 |  | 
|---|
| 61 | static fDestroyAll = FALSE; | 
|---|
| 62 | //For quick lookup of current process id | 
|---|
| 63 | static ULONG currentProcessId = -1; | 
|---|
| 64 |  | 
|---|
| 65 | //****************************************************************************** | 
|---|
| 66 | //****************************************************************************** | 
|---|
| 67 | Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType) | 
|---|
| 68 | { | 
|---|
| 69 | Init(); | 
|---|
| 70 | } | 
|---|
| 71 | //****************************************************************************** | 
|---|
| 72 | //****************************************************************************** | 
|---|
| 73 | Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode) | 
|---|
| 74 | : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow() | 
|---|
| 75 | { | 
|---|
| 76 | Init(); | 
|---|
| 77 | this->isUnicode = isUnicode; | 
|---|
| 78 | CreateWindowExA(lpCreateStructA, classAtom); | 
|---|
| 79 | } | 
|---|
| 80 | //****************************************************************************** | 
|---|
| 81 | //****************************************************************************** | 
|---|
| 82 | void Win32BaseWindow::Init() | 
|---|
| 83 | { | 
|---|
| 84 | isUnicode        = FALSE; | 
|---|
| 85 | fFirstShow       = TRUE; | 
|---|
| 86 | fIsDialog        = FALSE; | 
|---|
| 87 | fIsModalDialogOwner = FALSE; | 
|---|
| 88 | OS2HwndModalDialog  = 0; | 
|---|
| 89 | fInternalMsg     = FALSE; | 
|---|
| 90 | fNoSizeMsg       = FALSE; | 
|---|
| 91 | fIsDestroyed     = FALSE; | 
|---|
| 92 | fDestroyWindowCalled = FALSE; | 
|---|
| 93 | fCreated         = FALSE; | 
|---|
| 94 | fTaskList        = FALSE; | 
|---|
| 95 | fParentDC        = FALSE; | 
|---|
| 96 |  | 
|---|
| 97 | windowNameA      = NULL; | 
|---|
| 98 | windowNameW      = NULL; | 
|---|
| 99 | wndNameLength    = 0; | 
|---|
| 100 |  | 
|---|
| 101 | userWindowLong   = NULL;; | 
|---|
| 102 | nrUserWindowLong = 0; | 
|---|
| 103 |  | 
|---|
| 104 | magic            = WIN32PM_MAGIC; | 
|---|
| 105 | OS2Hwnd          = 0; | 
|---|
| 106 | OS2HwndFrame     = 0; | 
|---|
| 107 | hSysMenu         = 0; | 
|---|
| 108 | Win32Hwnd        = 0; | 
|---|
| 109 |  | 
|---|
| 110 | if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE) | 
|---|
| 111 | { | 
|---|
| 112 | dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!")); | 
|---|
| 113 | DebugInt3(); | 
|---|
| 114 | } | 
|---|
| 115 |  | 
|---|
| 116 | posx = posy      = 0; | 
|---|
| 117 | width = height   = 0; | 
|---|
| 118 |  | 
|---|
| 119 | dwExStyle        = 0; | 
|---|
| 120 | dwStyle          = 0; | 
|---|
| 121 | win32wndproc     = 0; | 
|---|
| 122 | hInstance        = 0; | 
|---|
| 123 | dwIDMenu         = 0; //0xFFFFFFFF; //default -1 | 
|---|
| 124 | userData         = 0; | 
|---|
| 125 | contextHelpId    = 0; | 
|---|
| 126 | hotkey           = 0; | 
|---|
| 127 |  | 
|---|
| 128 | pOldFrameProc = NULL; | 
|---|
| 129 |  | 
|---|
| 130 | hwndLinkAfter    = HWND_BOTTOM; | 
|---|
| 131 | flags            = 0; | 
|---|
| 132 | lastHitTestVal   = HTOS_NORMAL; | 
|---|
| 133 | owner            = NULL; | 
|---|
| 134 | windowClass      = 0; | 
|---|
| 135 |  | 
|---|
| 136 | hIcon              = 0; | 
|---|
| 137 | hIconSm            = 0; | 
|---|
| 138 |  | 
|---|
| 139 | EraseBkgndFlag     = TRUE; | 
|---|
| 140 |  | 
|---|
| 141 | horzScrollInfo     = NULL; | 
|---|
| 142 | vertScrollInfo     = NULL; | 
|---|
| 143 |  | 
|---|
| 144 | ownDC              = 0; | 
|---|
| 145 | hWindowRegion      = 0; | 
|---|
| 146 | hClipRegion        = 0; | 
|---|
| 147 |  | 
|---|
| 148 | if(currentProcessId == -1) | 
|---|
| 149 | { | 
|---|
| 150 | currentProcessId = GetCurrentProcessId(); | 
|---|
| 151 | } | 
|---|
| 152 | dwThreadId         = GetCurrentThreadId(); | 
|---|
| 153 | dwProcessId        = currentProcessId; | 
|---|
| 154 | } | 
|---|
| 155 | //****************************************************************************** | 
|---|
| 156 | //todo get rid of resources (menu, icon etc) | 
|---|
| 157 | //****************************************************************************** | 
|---|
| 158 | Win32BaseWindow::~Win32BaseWindow() | 
|---|
| 159 | { | 
|---|
| 160 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0); | 
|---|
| 161 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0); | 
|---|
| 162 |  | 
|---|
| 163 | if(!fDestroyAll && getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL) | 
|---|
| 164 | { | 
|---|
| 165 | //if we're the last child that's being destroyed and our | 
|---|
| 166 | //parent window was also destroyed, then we delete the parent object | 
|---|
| 167 | if(getParent()->IsWindowDestroyed()) | 
|---|
| 168 | { | 
|---|
| 169 | dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle())); | 
|---|
| 170 | delete getParent(); | 
|---|
| 171 | setParent(NULL);  //or else we'll crash in the dtor of the ChildWindow class | 
|---|
| 172 | } | 
|---|
| 173 | } | 
|---|
| 174 | else | 
|---|
| 175 | if(fDestroyAll) { | 
|---|
| 176 | dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA)); | 
|---|
| 177 | setParent(NULL);  //or else we'll crash in the dtor of the ChildWindow class | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 | if(isOwnDC()) | 
|---|
| 181 | releaseOwnDC(ownDC); | 
|---|
| 182 |  | 
|---|
| 183 | if(Win32Hwnd) | 
|---|
| 184 | HwFreeWindowHandle(Win32Hwnd); | 
|---|
| 185 |  | 
|---|
| 186 | if(userWindowLong) | 
|---|
| 187 | free(userWindowLong); | 
|---|
| 188 |  | 
|---|
| 189 | if(windowNameA) { | 
|---|
| 190 | free(windowNameA); | 
|---|
| 191 | windowNameA = NULL; | 
|---|
| 192 | } | 
|---|
| 193 | if(windowNameW) { | 
|---|
| 194 | free(windowNameW); | 
|---|
| 195 | windowNameW = NULL; | 
|---|
| 196 | } | 
|---|
| 197 | if(vertScrollInfo) { | 
|---|
| 198 | free(vertScrollInfo); | 
|---|
| 199 | vertScrollInfo = NULL; | 
|---|
| 200 | } | 
|---|
| 201 | if(horzScrollInfo) { | 
|---|
| 202 | free(horzScrollInfo); | 
|---|
| 203 | horzScrollInfo = NULL; | 
|---|
| 204 | } | 
|---|
| 205 | } | 
|---|
| 206 | //****************************************************************************** | 
|---|
| 207 | //****************************************************************************** | 
|---|
| 208 | void Win32BaseWindow::DestroyAll() | 
|---|
| 209 | { | 
|---|
| 210 | fDestroyAll = TRUE; | 
|---|
| 211 | GenericObject::DestroyAll(windows); | 
|---|
| 212 | } | 
|---|
| 213 | //****************************************************************************** | 
|---|
| 214 | //****************************************************************************** | 
|---|
| 215 | BOOL Win32BaseWindow::isChild() | 
|---|
| 216 | { | 
|---|
| 217 | return ((dwStyle & WS_CHILD) != 0); | 
|---|
| 218 | } | 
|---|
| 219 | //****************************************************************************** | 
|---|
| 220 | //****************************************************************************** | 
|---|
| 221 | BOOL Win32BaseWindow::IsWindowUnicode() | 
|---|
| 222 | { | 
|---|
| 223 | dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W)); | 
|---|
| 224 | return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W); | 
|---|
| 225 | } | 
|---|
| 226 | //****************************************************************************** | 
|---|
| 227 | //****************************************************************************** | 
|---|
| 228 | BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom) | 
|---|
| 229 | { | 
|---|
| 230 | char  buffer[256]; | 
|---|
| 231 |  | 
|---|
| 232 | #ifdef DEBUG | 
|---|
| 233 | PrintWindowStyle(cs->style, cs->dwExStyle); | 
|---|
| 234 | #endif | 
|---|
| 235 |  | 
|---|
| 236 | sw = SW_SHOW; | 
|---|
| 237 | SetLastError(0); | 
|---|
| 238 |  | 
|---|
| 239 | /* Find the parent window */ | 
|---|
| 240 | if (cs->hwndParent) | 
|---|
| 241 | { | 
|---|
| 242 | Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent); | 
|---|
| 243 | if(!window) { | 
|---|
| 244 | dprintf(("Bad parent %04x\n", cs->hwndParent )); | 
|---|
| 245 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 246 | return FALSE; | 
|---|
| 247 | } | 
|---|
| 248 | /* Make sure parent is valid */ | 
|---|
| 249 | if (!window->IsWindow() ) | 
|---|
| 250 | { | 
|---|
| 251 | dprintf(("Bad parent %04x\n", cs->hwndParent )); | 
|---|
| 252 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 253 | return FALSE; | 
|---|
| 254 | } | 
|---|
| 255 | /* Windows does this for overlapped windows | 
|---|
| 256 | * (I don't know about other styles.) */ | 
|---|
| 257 | if (cs->hwndParent == GetDesktopWindow() && (!(cs->style & WS_CHILD) || (cs->style & WS_POPUP))) | 
|---|
| 258 | { | 
|---|
| 259 | cs->hwndParent = 0; | 
|---|
| 260 | } | 
|---|
| 261 | } | 
|---|
| 262 | else | 
|---|
| 263 | if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) { | 
|---|
| 264 | dprintf(("No parent for child window\n" )); | 
|---|
| 265 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 266 | return FALSE;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */ | 
|---|
| 267 | } | 
|---|
| 268 |  | 
|---|
| 269 | /* Find the window class */ | 
|---|
| 270 | windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom); | 
|---|
| 271 | if (!windowClass) | 
|---|
| 272 | { | 
|---|
| 273 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); | 
|---|
| 274 | dprintf(("Bad class '%s'\n", buffer )); | 
|---|
| 275 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 276 | return 0; | 
|---|
| 277 | } | 
|---|
| 278 | #ifdef DEBUG | 
|---|
| 279 | if(HIWORD(cs->lpszClass)) | 
|---|
| 280 | { | 
|---|
| 281 | char *astring; | 
|---|
| 282 |  | 
|---|
| 283 | if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass); | 
|---|
| 284 | else          astring = (char *)cs->lpszClass; | 
|---|
| 285 |  | 
|---|
| 286 | dprintf(("Window class %s", astring)); | 
|---|
| 287 | if(isUnicode) FreeAsciiString(astring); | 
|---|
| 288 | } | 
|---|
| 289 | else  dprintf(("Window class %x", cs->lpszClass)); | 
|---|
| 290 | #endif | 
|---|
| 291 |  | 
|---|
| 292 | /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX | 
|---|
| 293 | * with an atom as the class name, put some programs expect to have a *REAL* string in | 
|---|
| 294 | * lpszClass when the CREATESTRUCT is sent with WM_CREATE | 
|---|
| 295 | */ | 
|---|
| 296 | if (!HIWORD(cs->lpszClass) ) { | 
|---|
| 297 | if (isUnicode) { | 
|---|
| 298 | GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) ); | 
|---|
| 299 | } | 
|---|
| 300 | else { | 
|---|
| 301 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); | 
|---|
| 302 | } | 
|---|
| 303 | cs->lpszClass = buffer; | 
|---|
| 304 | } | 
|---|
| 305 |  | 
|---|
| 306 | /* Fix the coordinates */ | 
|---|
| 307 | fXDefault = FALSE; | 
|---|
| 308 | fCXDefault = FALSE; | 
|---|
| 309 | if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16)) | 
|---|
| 310 | { | 
|---|
| 311 | /* Never believe Microsoft's documentation... CreateWindowEx doc says | 
|---|
| 312 | * that if an overlapped window is created with WS_VISIBLE style bit | 
|---|
| 313 | * set and the x parameter is set to CW_USEDEFAULT, the system ignores | 
|---|
| 314 | * the y parameter. However, disassembling NT implementation (WIN32K.SYS) | 
|---|
| 315 | * reveals that | 
|---|
| 316 | * | 
|---|
| 317 | * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 | 
|---|
| 318 | * 2) it does not ignore the y parameter as the docs claim; instead, it | 
|---|
| 319 | *    uses it as second parameter to ShowWindow() unless y is either | 
|---|
| 320 | *    CW_USEDEFAULT or CW_USEDEFAULT16. | 
|---|
| 321 | * | 
|---|
| 322 | * The fact that we didn't do 2) caused bogus windows pop up when wine | 
|---|
| 323 | * was running apps that were using this obscure feature. Example - | 
|---|
| 324 | * calc.exe that comes with Win98 (only Win98, it's different from | 
|---|
| 325 | * the one that comes with Win95 and NT) | 
|---|
| 326 | */ | 
|---|
| 327 | if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y; | 
|---|
| 328 |  | 
|---|
| 329 | /* We have saved cs->y, now we can trash it */ | 
|---|
| 330 | cs->x = 0; | 
|---|
| 331 | cs->y = 0; | 
|---|
| 332 | fXDefault = TRUE; | 
|---|
| 333 | } | 
|---|
| 334 | if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16)) | 
|---|
| 335 | { | 
|---|
| 336 | cs->cx = 600; /* FIXME */ | 
|---|
| 337 | cs->cy = 400; | 
|---|
| 338 | fCXDefault = TRUE; | 
|---|
| 339 | } | 
|---|
| 340 | if (cs->style & (WS_POPUP | WS_CHILD)) | 
|---|
| 341 | { | 
|---|
| 342 | fXDefault = FALSE; | 
|---|
| 343 | if (fCXDefault) | 
|---|
| 344 | { | 
|---|
| 345 | fCXDefault = FALSE; | 
|---|
| 346 | cs->cx = cs->cy = 0; | 
|---|
| 347 | } | 
|---|
| 348 | } | 
|---|
| 349 | if (fXDefault && !fCXDefault) fXDefault = FALSE; //CB: only x positioning doesn't work (calc.exe,cdrlabel.exe) | 
|---|
| 350 |  | 
|---|
| 351 | if (cs->x < 0) cs->x = 0; | 
|---|
| 352 | if (cs->y < 0) cs->y = 0; | 
|---|
| 353 |  | 
|---|
| 354 | //Allocate window words | 
|---|
| 355 | nrUserWindowLong = windowClass->getExtraWndWords(); | 
|---|
| 356 | if(nrUserWindowLong) { | 
|---|
| 357 | userWindowLong = (ULONG *)_smalloc(nrUserWindowLong); | 
|---|
| 358 | memset(userWindowLong, 0, nrUserWindowLong); | 
|---|
| 359 | } | 
|---|
| 360 |  | 
|---|
| 361 | if ((cs->style & WS_CHILD) && cs->hwndParent) | 
|---|
| 362 | { | 
|---|
| 363 | SetParent(cs->hwndParent); | 
|---|
| 364 | owner = GetWindowFromHandle(cs->hwndParent); | 
|---|
| 365 | if(owner == NULL) | 
|---|
| 366 | { | 
|---|
| 367 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent)); | 
|---|
| 368 | SetLastError(ERROR_INVALID_WINDOW_HANDLE); | 
|---|
| 369 | return FALSE; | 
|---|
| 370 | } | 
|---|
| 371 | //SvL: Shell positioning shouldn't be done for child windows! (breaks Notes) | 
|---|
| 372 | fXDefault = fCXDefault = FALSE; | 
|---|
| 373 | } | 
|---|
| 374 | else | 
|---|
| 375 | { | 
|---|
| 376 | SetParent(0); | 
|---|
| 377 | if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) { | 
|---|
| 378 | owner = NULL; | 
|---|
| 379 | } | 
|---|
| 380 | else | 
|---|
| 381 | { | 
|---|
| 382 | owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent(); | 
|---|
| 383 | if(owner == NULL) | 
|---|
| 384 | { | 
|---|
| 385 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent)); | 
|---|
| 386 | SetLastError(ERROR_INVALID_WINDOW_HANDLE); | 
|---|
| 387 | return FALSE; | 
|---|
| 388 | } | 
|---|
| 389 | } | 
|---|
| 390 | } | 
|---|
| 391 |  | 
|---|
| 392 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW); | 
|---|
| 393 | hInstance = cs->hInstance; | 
|---|
| 394 | dwStyle   = cs->style & ~WS_VISIBLE; | 
|---|
| 395 | dwExStyle = cs->dwExStyle; | 
|---|
| 396 |  | 
|---|
| 397 | hwndLinkAfter = HWND_TOP; | 
|---|
| 398 | if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX)) | 
|---|
| 399 | { | 
|---|
| 400 | hwndLinkAfter = HWND_BOTTOM; | 
|---|
| 401 | dwStyle |= WS_CLIPSIBLINGS; | 
|---|
| 402 | } | 
|---|
| 403 | else | 
|---|
| 404 | if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) { | 
|---|
| 405 | dwStyle |= WS_CLIPSIBLINGS; | 
|---|
| 406 | } | 
|---|
| 407 |  | 
|---|
| 408 | /* Increment class window counter */ | 
|---|
| 409 | windowClass->IncreaseWindowCount(); | 
|---|
| 410 |  | 
|---|
| 411 | if (HOOK_IsHooked( WH_CBT )) | 
|---|
| 412 | { | 
|---|
| 413 | CBT_CREATEWNDA cbtc; | 
|---|
| 414 | LRESULT ret; | 
|---|
| 415 |  | 
|---|
| 416 | cbtc.lpcs = cs; | 
|---|
| 417 | cbtc.hwndInsertAfter = hwndLinkAfter; | 
|---|
| 418 | ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc); | 
|---|
| 419 | if(ret) | 
|---|
| 420 | { | 
|---|
| 421 | dprintf(("CBT-hook returned 0!!")); | 
|---|
| 422 | SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error | 
|---|
| 423 | return FALSE; | 
|---|
| 424 | } | 
|---|
| 425 | } | 
|---|
| 426 |  | 
|---|
| 427 | /* Correct the window style */ | 
|---|
| 428 | if (!(cs->style & WS_CHILD)) | 
|---|
| 429 | { | 
|---|
| 430 | dwStyle |= WS_CLIPSIBLINGS; | 
|---|
| 431 | if (!(cs->style & WS_POPUP)) | 
|---|
| 432 | { | 
|---|
| 433 | dwStyle |= WS_CAPTION; | 
|---|
| 434 | flags |= WIN_NEED_SIZE; | 
|---|
| 435 | } | 
|---|
| 436 | } | 
|---|
| 437 | if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME; | 
|---|
| 438 |  | 
|---|
| 439 | if (cs->style & WS_HSCROLL) | 
|---|
| 440 | { | 
|---|
| 441 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO)); | 
|---|
| 442 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0; | 
|---|
| 443 | horzScrollInfo->MaxVal = 100; | 
|---|
| 444 | horzScrollInfo->flags  = ESB_ENABLE_BOTH; | 
|---|
| 445 | } | 
|---|
| 446 |  | 
|---|
| 447 | if (cs->style & WS_VSCROLL) | 
|---|
| 448 | { | 
|---|
| 449 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO)); | 
|---|
| 450 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0; | 
|---|
| 451 | vertScrollInfo->MaxVal = 100; | 
|---|
| 452 | vertScrollInfo->flags  = ESB_ENABLE_BOTH; | 
|---|
| 453 | } | 
|---|
| 454 |  | 
|---|
| 455 | if(HIWORD(cs->lpszName)) | 
|---|
| 456 | { | 
|---|
| 457 | if (!isUnicode) | 
|---|
| 458 | { | 
|---|
| 459 | wndNameLength = strlen(cs->lpszName); | 
|---|
| 460 | windowNameA = (LPSTR)_smalloc(wndNameLength+1); | 
|---|
| 461 | strcpy(windowNameA,cs->lpszName); | 
|---|
| 462 | windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); | 
|---|
| 463 | lstrcpyAtoW(windowNameW,windowNameA); | 
|---|
| 464 | windowNameA[wndNameLength] = 0; | 
|---|
| 465 | windowNameW[wndNameLength] = 0; | 
|---|
| 466 | } | 
|---|
| 467 | else | 
|---|
| 468 | { | 
|---|
| 469 | wndNameLength = lstrlenW((LPWSTR)cs->lpszName); | 
|---|
| 470 | windowNameA = (LPSTR)_smalloc(wndNameLength+1); | 
|---|
| 471 | lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName); | 
|---|
| 472 | windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); | 
|---|
| 473 | lstrcpyW(windowNameW,(LPWSTR)cs->lpszName); | 
|---|
| 474 | windowNameA[wndNameLength] = 0; | 
|---|
| 475 | windowNameW[wndNameLength] = 0; | 
|---|
| 476 | } | 
|---|
| 477 | } | 
|---|
| 478 |  | 
|---|
| 479 | //copy pointer of CREATESTRUCT for usage in MsgCreate method | 
|---|
| 480 | tmpcs = cs; | 
|---|
| 481 |  | 
|---|
| 482 | //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it | 
|---|
| 483 | THDB *thdb = GetThreadTHDB(); | 
|---|
| 484 |  | 
|---|
| 485 | if(thdb == NULL) { | 
|---|
| 486 | dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad | 
|---|
| 487 | ExitProcess(666); | 
|---|
| 488 | return FALSE; | 
|---|
| 489 | } | 
|---|
| 490 |  | 
|---|
| 491 | thdb->newWindow = (ULONG)this; | 
|---|
| 492 |  | 
|---|
| 493 | DWORD dwOSWinStyle; | 
|---|
| 494 |  | 
|---|
| 495 | OSLibWinConvertStyle(dwStyle,dwExStyle,&dwOSWinStyle); | 
|---|
| 496 | if (((dwStyle & (WS_CAPTION | WS_SYSMENU | 0xC0000000)) == (WS_CAPTION | WS_SYSMENU))) fTaskList = TRUE; | 
|---|
| 497 |  | 
|---|
| 498 | OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, | 
|---|
| 499 | dwOSWinStyle,(char *)windowNameA, | 
|---|
| 500 | (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, | 
|---|
| 501 | (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE, | 
|---|
| 502 | &OS2HwndFrame, 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle() & CS_SAVEBITS); | 
|---|
| 503 | if(OS2Hwnd == 0) { | 
|---|
| 504 | dprintf(("Window creation failed!!")); | 
|---|
| 505 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error | 
|---|
| 506 | return FALSE; | 
|---|
| 507 | } | 
|---|
| 508 |  | 
|---|
| 509 | SetLastError(0); | 
|---|
| 510 | return TRUE; | 
|---|
| 511 | } | 
|---|
| 512 | //****************************************************************************** | 
|---|
| 513 | //****************************************************************************** | 
|---|
| 514 | BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient) | 
|---|
| 515 | { | 
|---|
| 516 | CREATESTRUCTA  *cs = tmpcs;  //pointer to CREATESTRUCT used in CreateWindowExA method | 
|---|
| 517 | POINT maxSize, maxPos, minTrack, maxTrack; | 
|---|
| 518 |  | 
|---|
| 519 | OS2Hwnd      = hwndClient; | 
|---|
| 520 | OS2HwndFrame = hwndFrame; | 
|---|
| 521 |  | 
|---|
| 522 | fNoSizeMsg = TRUE; | 
|---|
| 523 |  | 
|---|
| 524 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) { | 
|---|
| 525 | dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd)); | 
|---|
| 526 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error | 
|---|
| 527 | return FALSE; | 
|---|
| 528 | } | 
|---|
| 529 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) { | 
|---|
| 530 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd)); | 
|---|
| 531 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error | 
|---|
| 532 | return FALSE; | 
|---|
| 533 | } | 
|---|
| 534 |  | 
|---|
| 535 | //adjust CW_USEDEFAULT position | 
|---|
| 536 | if (fXDefault | fCXDefault) | 
|---|
| 537 | { | 
|---|
| 538 | RECT rect; | 
|---|
| 539 |  | 
|---|
| 540 | OSLibWinQueryWindowRect(OS2HwndFrame,&rect,RELATIVE_TO_SCREEN); | 
|---|
| 541 | if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect); | 
|---|
| 542 | if (fXDefault) | 
|---|
| 543 | { | 
|---|
| 544 | cs->x = rect.left; | 
|---|
| 545 | cs->y = rect.top; | 
|---|
| 546 | if (!fCXDefault) | 
|---|
| 547 | { | 
|---|
| 548 | //CB: todo: adjust pos to screen rect | 
|---|
| 549 | } | 
|---|
| 550 | } | 
|---|
| 551 | if (fCXDefault) | 
|---|
| 552 | { | 
|---|
| 553 | cs->cx = rect.right-rect.left; | 
|---|
| 554 | cs->cy = rect.bottom-rect.top; | 
|---|
| 555 | } | 
|---|
| 556 | } | 
|---|
| 557 |  | 
|---|
| 558 | /* Send the WM_GETMINMAXINFO message and fix the size if needed */ | 
|---|
| 559 | if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) | 
|---|
| 560 | { | 
|---|
| 561 | GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack); | 
|---|
| 562 | if (maxSize.x < cs->cx) cs->cx = maxSize.x; | 
|---|
| 563 | if (maxSize.y < cs->cy) cs->cy = maxSize.y; | 
|---|
| 564 | if (cs->cx < minTrack.x) cs->cx = minTrack.x; | 
|---|
| 565 | if (cs->cy < minTrack.y) cs->cy = minTrack.y; | 
|---|
| 566 | } | 
|---|
| 567 |  | 
|---|
| 568 | if(cs->style & WS_CHILD) | 
|---|
| 569 | { | 
|---|
| 570 | if(cs->cx < 0) cs->cx = 0; | 
|---|
| 571 | if(cs->cy < 0) cs->cy = 0; | 
|---|
| 572 | } | 
|---|
| 573 | else | 
|---|
| 574 | { | 
|---|
| 575 | if (cs->cx <= 0) cs->cx = 1; | 
|---|
| 576 | if (cs->cy <= 0) cs->cy = 1; | 
|---|
| 577 | } | 
|---|
| 578 |  | 
|---|
| 579 | OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame); | 
|---|
| 580 |  | 
|---|
| 581 | fakeWinBase.hwndThis     = OS2Hwnd; | 
|---|
| 582 | fakeWinBase.pWindowClass = windowClass; | 
|---|
| 583 |  | 
|---|
| 584 | //Set icon from window or class | 
|---|
| 585 | if (hIcon) | 
|---|
| 586 | OSLibWinSetIcon(OS2HwndFrame,hIcon); | 
|---|
| 587 | else if (windowClass->getIcon()) | 
|---|
| 588 | OSLibWinSetIcon(OS2HwndFrame,windowClass->getIcon()); | 
|---|
| 589 |  | 
|---|
| 590 | /* Get class or window DC if needed */ | 
|---|
| 591 | if(windowClass->getStyle() & CS_OWNDC) { | 
|---|
| 592 | dprintf(("Class with CS_OWNDC style")); | 
|---|
| 593 | ownDC = GetDC(getWindowHandle()); //TODO: or GetWindowDC??? | 
|---|
| 594 | } | 
|---|
| 595 | else | 
|---|
| 596 | if (windowClass->getStyle() & CS_PARENTDC)  { | 
|---|
| 597 | dprintf(("WARNING: Class with CS_PARENTDC style!")); | 
|---|
| 598 | fParentDC = TRUE; | 
|---|
| 599 | ownDC = 0; | 
|---|
| 600 | } | 
|---|
| 601 | else | 
|---|
| 602 | if (windowClass->getStyle() & CS_CLASSDC)  { | 
|---|
| 603 | dprintf(("WARNING: Class with CS_CLASSDC style!")); | 
|---|
| 604 | ownDC = 0; | 
|---|
| 605 | } | 
|---|
| 606 | /* Set the window menu */ | 
|---|
| 607 | if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION ) | 
|---|
| 608 | { | 
|---|
| 609 | if (cs->hMenu) { | 
|---|
| 610 | ::SetMenu(getWindowHandle(), cs->hMenu); | 
|---|
| 611 | } | 
|---|
| 612 | else { | 
|---|
| 613 | if (windowClass->getMenuNameA()) { | 
|---|
| 614 | cs->hMenu = LoadMenuA(windowClass->getInstance(),windowClass->getMenuNameA()); | 
|---|
| 615 | #if 0 //CB: hack for treeview test cases bug | 
|---|
| 616 | if (!cs->hMenu) cs->hMenu = LoadMenuA(windowClass->getInstance(),"MYAPP"); | 
|---|
| 617 | #endif | 
|---|
| 618 | if (cs->hMenu) ::SetMenu(getWindowHandle(), cs->hMenu ); | 
|---|
| 619 | } | 
|---|
| 620 | } | 
|---|
| 621 | } | 
|---|
| 622 | else | 
|---|
| 623 | { | 
|---|
| 624 | setWindowId((DWORD)cs->hMenu); | 
|---|
| 625 | } | 
|---|
| 626 | hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0; | 
|---|
| 627 |  | 
|---|
| 628 | // Subclass frame | 
|---|
| 629 | pOldFrameProc = FrameSubclassFrameWindow(this); | 
|---|
| 630 |  | 
|---|
| 631 | //preset rects | 
|---|
| 632 | rectWindow.left = cs->x; | 
|---|
| 633 | rectWindow.right = cs->x+cs->cx; | 
|---|
| 634 | rectWindow.top = cs->y; | 
|---|
| 635 | rectWindow.bottom = cs->y+cs->cy; | 
|---|
| 636 | rectClient = rectWindow; //dummy client rect | 
|---|
| 637 | OffsetRect(&rectClient, -rectClient.left, -rectClient.top); | 
|---|
| 638 |  | 
|---|
| 639 | if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow); | 
|---|
| 640 | /* Send the WM_CREATE message | 
|---|
| 641 | * Perhaps we shouldn't allow width/height changes as well. | 
|---|
| 642 | * See p327 in "Internals". | 
|---|
| 643 | */ | 
|---|
| 644 | maxPos.x = rectWindow.left; maxPos.y = rectWindow.top; | 
|---|
| 645 |  | 
|---|
| 646 | //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE | 
|---|
| 647 | fCreated = TRUE; | 
|---|
| 648 |  | 
|---|
| 649 | if (SendInternalMessageA(WM_NCCREATE,0,(LPARAM)cs)) | 
|---|
| 650 | { | 
|---|
| 651 | RECT tmpRect; | 
|---|
| 652 |  | 
|---|
| 653 | //CB: recheck flags | 
|---|
| 654 | if (cs->style & (WS_POPUP | WS_CHILD)) | 
|---|
| 655 | { | 
|---|
| 656 | fXDefault = FALSE; | 
|---|
| 657 | if (fCXDefault) | 
|---|
| 658 | { | 
|---|
| 659 | fCXDefault = FALSE; | 
|---|
| 660 | cs->cx = cs->cy = 0; | 
|---|
| 661 | } | 
|---|
| 662 | } | 
|---|
| 663 | //update rect | 
|---|
| 664 | rectWindow.left = cs->x; | 
|---|
| 665 | rectWindow.right = cs->x+cs->cx; | 
|---|
| 666 | rectWindow.top = cs->y; | 
|---|
| 667 | rectWindow.bottom = cs->y+cs->cy; | 
|---|
| 668 | tmpRect = rectWindow; | 
|---|
| 669 | if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow); | 
|---|
| 670 | OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top); | 
|---|
| 671 |  | 
|---|
| 672 | rectClient = rectWindow; | 
|---|
| 673 | OffsetRect(&rectClient, -rectClient.left, -rectClient.top); | 
|---|
| 674 |  | 
|---|
| 675 | //set the window size and update the client | 
|---|
| 676 | SetWindowPos(hwndLinkAfter, tmpRect.left, tmpRect.top, tmpRect.right-tmpRect.left, tmpRect.bottom-tmpRect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED); | 
|---|
| 677 | fNoSizeMsg = FALSE; | 
|---|
| 678 | if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE | 
|---|
| 679 | if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 ) | 
|---|
| 680 | { | 
|---|
| 681 | if(!(flags & WIN_NEED_SIZE)) | 
|---|
| 682 | { | 
|---|
| 683 | SendInternalMessageA(WM_SIZE, SIZE_RESTORED, | 
|---|
| 684 | MAKELONG(rectClient.right-rectClient.left, | 
|---|
| 685 | rectClient.bottom-rectClient.top)); | 
|---|
| 686 |  | 
|---|
| 687 | SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top)); | 
|---|
| 688 | } | 
|---|
| 689 |  | 
|---|
| 690 | if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) ) | 
|---|
| 691 | { | 
|---|
| 692 | /* Notify the parent window only */ | 
|---|
| 693 | SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle()); | 
|---|
| 694 | if(!::IsWindow(getWindowHandle())) | 
|---|
| 695 | { | 
|---|
| 696 | dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window")); | 
|---|
| 697 | goto end; | 
|---|
| 698 | } | 
|---|
| 699 | } | 
|---|
| 700 |  | 
|---|
| 701 | if (cs->style & WS_VISIBLE) ShowWindow(sw); | 
|---|
| 702 |  | 
|---|
| 703 | /* Call WH_SHELL hook */ | 
|---|
| 704 | if (!(getStyle() & WS_CHILD) && !owner) | 
|---|
| 705 | HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 ); | 
|---|
| 706 |  | 
|---|
| 707 | SetLastError(0); | 
|---|
| 708 | return TRUE; | 
|---|
| 709 | } | 
|---|
| 710 | } | 
|---|
| 711 | dprintf(("Window creation FAILED (NCCREATE cancelled creation)")); | 
|---|
| 712 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error | 
|---|
| 713 | end: | 
|---|
| 714 | return FALSE; | 
|---|
| 715 | } | 
|---|
| 716 | //****************************************************************************** | 
|---|
| 717 | //****************************************************************************** | 
|---|
| 718 | ULONG Win32BaseWindow::MsgQuit() | 
|---|
| 719 | { | 
|---|
| 720 | return SendInternalMessageA(WM_QUIT, 0, 0); | 
|---|
| 721 | } | 
|---|
| 722 | //****************************************************************************** | 
|---|
| 723 | //****************************************************************************** | 
|---|
| 724 | ULONG Win32BaseWindow::MsgClose() | 
|---|
| 725 | { | 
|---|
| 726 | return SendInternalMessageA(WM_CLOSE,0,0); | 
|---|
| 727 | } | 
|---|
| 728 | //****************************************************************************** | 
|---|
| 729 | //****************************************************************************** | 
|---|
| 730 | ULONG Win32BaseWindow::MsgDestroy() | 
|---|
| 731 | { | 
|---|
| 732 | ULONG rc; | 
|---|
| 733 | Win32BaseWindow *child; | 
|---|
| 734 | HWND hwnd = getWindowHandle(); | 
|---|
| 735 |  | 
|---|
| 736 | fIsDestroyed = TRUE; | 
|---|
| 737 |  | 
|---|
| 738 | if(fDestroyWindowCalled == FALSE) | 
|---|
| 739 | {//this window was destroyed because DestroyWindow was called for it's parent | 
|---|
| 740 | //so: send a WM_PARENTNOTIFY now as that hasn't happened yet | 
|---|
| 741 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY)) | 
|---|
| 742 | { | 
|---|
| 743 | if(getParent()) | 
|---|
| 744 | { | 
|---|
| 745 | /* Notify the parent window only */ | 
|---|
| 746 | getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle()); | 
|---|
| 747 | } | 
|---|
| 748 | else    DebugInt3(); | 
|---|
| 749 | } | 
|---|
| 750 | } | 
|---|
| 751 | SendInternalMessageA(WM_DESTROY, 0, 0); | 
|---|
| 752 | if(::IsWindow(hwnd) == FALSE) { | 
|---|
| 753 | //object already destroyed, so return immediately | 
|---|
| 754 | return 1; | 
|---|
| 755 | } | 
|---|
| 756 | SendInternalMessageA(WM_NCDESTROY, 0, 0); | 
|---|
| 757 |  | 
|---|
| 758 | TIMER_KillTimerFromWindow(OS2Hwnd); | 
|---|
| 759 |  | 
|---|
| 760 | if(getFirstChild() == NULL) { | 
|---|
| 761 | delete this; | 
|---|
| 762 | } | 
|---|
| 763 | return 1; | 
|---|
| 764 | } | 
|---|
| 765 | //****************************************************************************** | 
|---|
| 766 | //****************************************************************************** | 
|---|
| 767 | ULONG Win32BaseWindow::MsgEnable(BOOL fEnable) | 
|---|
| 768 | { | 
|---|
| 769 | if(fEnable) { | 
|---|
| 770 | dwStyle &= ~WS_DISABLED; | 
|---|
| 771 | } | 
|---|
| 772 | else dwStyle |= WS_DISABLED; | 
|---|
| 773 |  | 
|---|
| 774 | return SendInternalMessageA(WM_ENABLE, fEnable, 0); | 
|---|
| 775 | } | 
|---|
| 776 | //****************************************************************************** | 
|---|
| 777 | //TODO: SW_PARENTCLOSING/OPENING flag (lParam) | 
|---|
| 778 | //****************************************************************************** | 
|---|
| 779 | ULONG Win32BaseWindow::MsgShow(BOOL fShow) | 
|---|
| 780 | { | 
|---|
| 781 | if(fNoSizeMsg) { | 
|---|
| 782 | return 1; | 
|---|
| 783 | } | 
|---|
| 784 |  | 
|---|
| 785 | if(fShow) { | 
|---|
| 786 | setStyle(getStyle() | WS_VISIBLE); | 
|---|
| 787 | } | 
|---|
| 788 | else    setStyle(getStyle() & ~WS_VISIBLE); | 
|---|
| 789 |  | 
|---|
| 790 | return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0); | 
|---|
| 791 | } | 
|---|
| 792 | //****************************************************************************** | 
|---|
| 793 | //****************************************************************************** | 
|---|
| 794 | ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp) | 
|---|
| 795 | { | 
|---|
| 796 | //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends | 
|---|
| 797 | //     a WM_WINDOWPOSCHANGED msg -> crash) | 
|---|
| 798 | if(fNoSizeMsg || fDestroyWindowCalled) | 
|---|
| 799 | return 0; | 
|---|
| 800 |  | 
|---|
| 801 | return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp); | 
|---|
| 802 | } | 
|---|
| 803 | //****************************************************************************** | 
|---|
| 804 | //****************************************************************************** | 
|---|
| 805 | ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp) | 
|---|
| 806 | { | 
|---|
| 807 | //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends | 
|---|
| 808 | //     a WM_WINDOWPOSCHANGED msg -> crash) | 
|---|
| 809 | if(fNoSizeMsg || fDestroyWindowCalled) | 
|---|
| 810 | return 1; | 
|---|
| 811 |  | 
|---|
| 812 | return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp); | 
|---|
| 813 | } | 
|---|
| 814 | //****************************************************************************** | 
|---|
| 815 | //****************************************************************************** | 
|---|
| 816 | #if 0 | 
|---|
| 817 | ULONG Win32BaseWindow::MsgMinMax() | 
|---|
| 818 | { | 
|---|
| 819 |  | 
|---|
| 820 | } | 
|---|
| 821 | #endif | 
|---|
| 822 | //****************************************************************************** | 
|---|
| 823 | //****************************************************************************** | 
|---|
| 824 | ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos) | 
|---|
| 825 | { | 
|---|
| 826 | //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard | 
|---|
| 827 | //window scrollbars send these messages | 
|---|
| 828 | return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0); | 
|---|
| 829 | } | 
|---|
| 830 | //****************************************************************************** | 
|---|
| 831 | //****************************************************************************** | 
|---|
| 832 | ULONG Win32BaseWindow::MsgHitTest(MSG *msg) | 
|---|
| 833 | { | 
|---|
| 834 | lastHitTestVal = DispatchMessageA(msg); | 
|---|
| 835 |  | 
|---|
| 836 | dprintf2(("MsgHitTest (%d,%d) (%d,%d) (%d,%d) returned %x", LOWORD(msg->lParam), HIWORD(msg->lParam), rectWindow.left, rectWindow.right, rectWindow.top, rectWindow.bottom, lastHitTestVal)); | 
|---|
| 837 |  | 
|---|
| 838 | if (lastHitTestVal == HTTRANSPARENT) | 
|---|
| 839 | return HTOS_TRANSPARENT; | 
|---|
| 840 | else | 
|---|
| 841 | return HTOS_NORMAL; | 
|---|
| 842 | } | 
|---|
| 843 | //****************************************************************************** | 
|---|
| 844 | //****************************************************************************** | 
|---|
| 845 | ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win) | 
|---|
| 846 | { | 
|---|
| 847 | ULONG rc, procidhwnd = -1, threadidhwnd = 0; | 
|---|
| 848 |  | 
|---|
| 849 |  | 
|---|
| 850 | //According to SDK docs, if app returns FALSE & window is being deactivated, | 
|---|
| 851 | //default processing is cancelled | 
|---|
| 852 | //TODO: According to Wine we should proceed anyway if window is sysmodal | 
|---|
| 853 | #if 0 | 
|---|
| 854 | if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate) | 
|---|
| 855 | { | 
|---|
| 856 | return 0; | 
|---|
| 857 | } | 
|---|
| 858 | #endif | 
|---|
| 859 | /* child windows get WM_CHILDACTIVATE message */ | 
|---|
| 860 | if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD ) | 
|---|
| 861 | { | 
|---|
| 862 | SendInternalMessageA(WM_CHILDACTIVATE, 0, 0L); | 
|---|
| 863 | return 0; | 
|---|
| 864 | } | 
|---|
| 865 |  | 
|---|
| 866 | rc = SendInternalMessageA(WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd); | 
|---|
| 867 |  | 
|---|
| 868 | if(hwndOS2Win) { | 
|---|
| 869 | threadidhwnd = O32_GetWindowThreadProcessId(hwndOS2Win, &procidhwnd); | 
|---|
| 870 | } | 
|---|
| 871 |  | 
|---|
| 872 | if(fActivate) { | 
|---|
| 873 | SendInternalMessageA(WM_ACTIVATEAPP, 1, dwThreadId);    //activate; specify window thread id | 
|---|
| 874 | } | 
|---|
| 875 | else    SendInternalMessageA(WM_ACTIVATEAPP, 0, threadidhwnd);  //deactivate; specify thread id of other process | 
|---|
| 876 | return rc; | 
|---|
| 877 | } | 
|---|
| 878 | //****************************************************************************** | 
|---|
| 879 | //****************************************************************************** | 
|---|
| 880 | ULONG Win32BaseWindow::DispatchMsgA(MSG *msg) | 
|---|
| 881 | { | 
|---|
| 882 | return SendInternalMessageA(msg->message, msg->wParam, msg->lParam); | 
|---|
| 883 | } | 
|---|
| 884 | //****************************************************************************** | 
|---|
| 885 | //****************************************************************************** | 
|---|
| 886 | ULONG Win32BaseWindow::DispatchMsgW(MSG *msg) | 
|---|
| 887 | { | 
|---|
| 888 | return SendInternalMessageW(msg->message, msg->wParam, msg->lParam); | 
|---|
| 889 | } | 
|---|
| 890 | //****************************************************************************** | 
|---|
| 891 | //****************************************************************************** | 
|---|
| 892 | ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd) | 
|---|
| 893 | { | 
|---|
| 894 | return  SendInternalMessageA(WM_SETFOCUS, hwnd, 0); | 
|---|
| 895 | } | 
|---|
| 896 | //****************************************************************************** | 
|---|
| 897 | //****************************************************************************** | 
|---|
| 898 | ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd) | 
|---|
| 899 | { | 
|---|
| 900 | return  SendInternalMessageA(WM_KILLFOCUS, hwnd, 0); | 
|---|
| 901 | } | 
|---|
| 902 | //****************************************************************************** | 
|---|
| 903 | //****************************************************************************** | 
|---|
| 904 | ULONG Win32BaseWindow::MsgButton(MSG *msg) | 
|---|
| 905 | { | 
|---|
| 906 | BOOL  fClick = FALSE; | 
|---|
| 907 |  | 
|---|
| 908 | //    dprintf(("MsgButton at (%d,%d)", msg->pt.x, msg->pt.y)); | 
|---|
| 909 | switch(msg->message) { | 
|---|
| 910 | case WM_LBUTTONDBLCLK: | 
|---|
| 911 | case WM_RBUTTONDBLCLK: | 
|---|
| 912 | case WM_MBUTTONDBLCLK: | 
|---|
| 913 | if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) | 
|---|
| 914 | { | 
|---|
| 915 | msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down | 
|---|
| 916 | MsgButton(msg); | 
|---|
| 917 | msg->message++; //button-up | 
|---|
| 918 | return MsgButton(msg); | 
|---|
| 919 | } | 
|---|
| 920 | break; | 
|---|
| 921 | case WM_NCLBUTTONDBLCLK: | 
|---|
| 922 | case WM_NCRBUTTONDBLCLK: | 
|---|
| 923 | case WM_NCMBUTTONDBLCLK: | 
|---|
| 924 | //Docs say CS_DBLCLKS style doesn't matter for non-client double clicks | 
|---|
| 925 | fClick = TRUE; | 
|---|
| 926 | break; | 
|---|
| 927 |  | 
|---|
| 928 | case WM_LBUTTONDOWN: | 
|---|
| 929 | case WM_RBUTTONDOWN: | 
|---|
| 930 | case WM_MBUTTONDOWN: | 
|---|
| 931 | case WM_NCLBUTTONDOWN: | 
|---|
| 932 | case WM_NCRBUTTONDOWN: | 
|---|
| 933 | case WM_NCMBUTTONDOWN: | 
|---|
| 934 | fClick = TRUE; | 
|---|
| 935 | break; | 
|---|
| 936 | } | 
|---|
| 937 |  | 
|---|
| 938 | if(fClick) | 
|---|
| 939 | { | 
|---|
| 940 | HWND hwndTop; | 
|---|
| 941 |  | 
|---|
| 942 | /* Activate the window if needed */ | 
|---|
| 943 | hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0; | 
|---|
| 944 |  | 
|---|
| 945 | HWND hwndActive = GetActiveWindow(); | 
|---|
| 946 | if (hwndTop && (getWindowHandle() != hwndActive)) | 
|---|
| 947 | { | 
|---|
| 948 | LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop, | 
|---|
| 949 | MAKELONG( lastHitTestVal, msg->message) ); | 
|---|
| 950 |  | 
|---|
| 951 | #if 0 | 
|---|
| 952 | if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT)) | 
|---|
| 953 | eatMsg = TRUE; | 
|---|
| 954 | #endif | 
|---|
| 955 | if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT)) | 
|---|
| 956 | && (hwndTop != GetForegroundWindow()) ) | 
|---|
| 957 | { | 
|---|
| 958 | Win32BaseWindow *win32top = Win32BaseWindow::GetWindowFromHandle(hwndTop); | 
|---|
| 959 |  | 
|---|
| 960 | //SvL: Calling OSLibSetActiveWindow(hwndTop); causes focus problems | 
|---|
| 961 | if (win32top) OSLibWinSetFocus(win32top->getOS2FrameWindowHandle()); | 
|---|
| 962 | } | 
|---|
| 963 | } | 
|---|
| 964 | } | 
|---|
| 965 |  | 
|---|
| 966 | SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message)); | 
|---|
| 967 |  | 
|---|
| 968 | return  SendInternalMessageA(msg->message, msg->wParam, msg->lParam); | 
|---|
| 969 | } | 
|---|
| 970 | //****************************************************************************** | 
|---|
| 971 | //****************************************************************************** | 
|---|
| 972 | ULONG Win32BaseWindow::MsgPaint(ULONG tmp1, BOOL select) | 
|---|
| 973 | { | 
|---|
| 974 | if (select && IsWindowIconic()) | 
|---|
| 975 | return SendInternalMessageA(WM_PAINTICON, 1, 0); | 
|---|
| 976 | else | 
|---|
| 977 | return SendInternalMessageA(WM_PAINT, 0, 0); | 
|---|
| 978 | } | 
|---|
| 979 | //****************************************************************************** | 
|---|
| 980 | //TODO: Is the clipper region of the window DC equal to the invalidated rectangle? | 
|---|
| 981 | //      (or are we simply erasing too much here) | 
|---|
| 982 | //****************************************************************************** | 
|---|
| 983 | ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc) | 
|---|
| 984 | { | 
|---|
| 985 | ULONG rc; | 
|---|
| 986 | HDC   hdcErase = hdc; | 
|---|
| 987 |  | 
|---|
| 988 | if (hdcErase == 0) | 
|---|
| 989 | hdcErase = O32_GetDC(OS2Hwnd); | 
|---|
| 990 |  | 
|---|
| 991 | if(IsWindowIconic()) | 
|---|
| 992 | rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0); | 
|---|
| 993 | else | 
|---|
| 994 | rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0); | 
|---|
| 995 | if (hdc == 0) | 
|---|
| 996 | O32_ReleaseDC(OS2Hwnd, hdcErase); | 
|---|
| 997 | return (rc); | 
|---|
| 998 | } | 
|---|
| 999 | //****************************************************************************** | 
|---|
| 1000 | //****************************************************************************** | 
|---|
| 1001 | ULONG Win32BaseWindow::MsgMouseMove(MSG *msg) | 
|---|
| 1002 | { | 
|---|
| 1003 | //TODO: hiword should be 0 if window enters menu mode (SDK docs) | 
|---|
| 1004 | SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message)); | 
|---|
| 1005 |  | 
|---|
| 1006 | //translated message == WM_(NC)MOUSEMOVE | 
|---|
| 1007 | return SendInternalMessageA(msg->message, msg->wParam, msg->lParam); | 
|---|
| 1008 | } | 
|---|
| 1009 | //****************************************************************************** | 
|---|
| 1010 | //****************************************************************************** | 
|---|
| 1011 | ULONG Win32BaseWindow::MsgChar(MSG *msg) | 
|---|
| 1012 | { | 
|---|
| 1013 | return DispatchMsgA(msg); | 
|---|
| 1014 | } | 
|---|
| 1015 | //****************************************************************************** | 
|---|
| 1016 | //****************************************************************************** | 
|---|
| 1017 | ULONG Win32BaseWindow::MsgNCPaint() | 
|---|
| 1018 | { | 
|---|
| 1019 | RECT rect; | 
|---|
| 1020 |  | 
|---|
| 1021 | if (GetOS2UpdateRect(OS2HwndFrame,&rect)) | 
|---|
| 1022 | { | 
|---|
| 1023 | HRGN hrgn; | 
|---|
| 1024 | ULONG rc; | 
|---|
| 1025 | RECT client = rectClient; | 
|---|
| 1026 |  | 
|---|
| 1027 | ////    mapWin32Rect(getParent() ? getParent()->getOS2WindowHandle():OSLIB_HWND_DESKTOP,OS2HwndFrame,&client); | 
|---|
| 1028 | if ((rect.left >= client.left) && (rect.left < client.right) && | 
|---|
| 1029 | (rect.right >= client.left) && (rect.right < client.right) && | 
|---|
| 1030 | (rect.top  >= client.top) && (rect.top < client.bottom) && | 
|---|
| 1031 | (rect.bottom >= client.top) && (rect.bottom < client.bottom)) | 
|---|
| 1032 | { | 
|---|
| 1033 | return 0; | 
|---|
| 1034 | } | 
|---|
| 1035 |  | 
|---|
| 1036 | dprintf(("MsgNCPaint (%d,%d)(%d,%d)", rect.left, rect.top, rect.right, rect.bottom)); | 
|---|
| 1037 | hrgn = CreateRectRgnIndirect(&rect); | 
|---|
| 1038 | if (!hrgn) return 0; | 
|---|
| 1039 |  | 
|---|
| 1040 | rc = SendInternalMessageA(WM_NCPAINT,hrgn,0); | 
|---|
| 1041 |  | 
|---|
| 1042 | DeleteObject(hrgn); | 
|---|
| 1043 |  | 
|---|
| 1044 | return rc; | 
|---|
| 1045 | } | 
|---|
| 1046 | else  return 0; | 
|---|
| 1047 | } | 
|---|
| 1048 | //****************************************************************************** | 
|---|
| 1049 | //Called when either the frame's size or position has changed (lpWndPos != NULL) | 
|---|
| 1050 | //or when the frame layout has changed (i.e. scrollbars added/removed) (lpWndPos == NULL) | 
|---|
| 1051 | //****************************************************************************** | 
|---|
| 1052 | ULONG Win32BaseWindow::MsgFormatFrame(WINDOWPOS *lpWndPos) | 
|---|
| 1053 | { | 
|---|
| 1054 | RECT oldWindowRect = rectWindow, client = rectClient, newWindowRect; | 
|---|
| 1055 | WINDOWPOS wndPos; | 
|---|
| 1056 | ULONG rc; | 
|---|
| 1057 |  | 
|---|
| 1058 | if(lpWndPos) | 
|---|
| 1059 | { | 
|---|
| 1060 | POINT point; | 
|---|
| 1061 |  | 
|---|
| 1062 | //set new window rectangle | 
|---|
| 1063 | point.x = lpWndPos->x; | 
|---|
| 1064 | point.y = lpWndPos->y; | 
|---|
| 1065 | if (getParent()) ClientToScreen(getParent()->getWindowHandle(),&point); | 
|---|
| 1066 |  | 
|---|
| 1067 | setWindowRect(point.x,point.y,point.x+lpWndPos->cx,point.y+lpWndPos->cy); | 
|---|
| 1068 | newWindowRect = rectWindow; | 
|---|
| 1069 | } | 
|---|
| 1070 | else { | 
|---|
| 1071 | wndPos.hwnd  = getWindowHandle(); | 
|---|
| 1072 | wndPos.hwndInsertAfter = 0; | 
|---|
| 1073 | newWindowRect= rectWindow; | 
|---|
| 1074 | if (getParent()) { | 
|---|
| 1075 | mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&newWindowRect); | 
|---|
| 1076 | } | 
|---|
| 1077 | wndPos.x     = newWindowRect.left; | 
|---|
| 1078 | wndPos.y     = newWindowRect.top; | 
|---|
| 1079 | wndPos.cx    = newWindowRect.right - newWindowRect.left; | 
|---|
| 1080 | wndPos.cy    = newWindowRect.bottom - newWindowRect.top; | 
|---|
| 1081 | wndPos.flags = SWP_FRAMECHANGED; | 
|---|
| 1082 | lpWndPos     = &wndPos; | 
|---|
| 1083 |  | 
|---|
| 1084 | if (getParent()) { | 
|---|
| 1085 | newWindowRect= rectWindow; //reset; was modified | 
|---|
| 1086 | } | 
|---|
| 1087 | } | 
|---|
| 1088 |  | 
|---|
| 1089 | rc = SendNCCalcSize(TRUE, &newWindowRect,  &oldWindowRect, &client, lpWndPos, &rectClient); | 
|---|
| 1090 |  | 
|---|
| 1091 | dprintf(("MsgFormatFrame: old client rect (%d,%d)(%d,%d), new client (%d,%d)(%d,%d)", client.left, client.top, client.right, client.bottom, rectClient.left, rectClient.top, rectClient.right, rectClient.bottom)); | 
|---|
| 1092 | return rc; | 
|---|
| 1093 | } | 
|---|
| 1094 | //****************************************************************************** | 
|---|
| 1095 | //****************************************************************************** | 
|---|
| 1096 | ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch) | 
|---|
| 1097 | { | 
|---|
| 1098 | return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz); | 
|---|
| 1099 | } | 
|---|
| 1100 | //****************************************************************************** | 
|---|
| 1101 | //****************************************************************************** | 
|---|
| 1102 | ULONG Win32BaseWindow::MsgGetTextLength() | 
|---|
| 1103 | { | 
|---|
| 1104 | return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0); | 
|---|
| 1105 | } | 
|---|
| 1106 | //****************************************************************************** | 
|---|
| 1107 | //****************************************************************************** | 
|---|
| 1108 | void Win32BaseWindow::MsgGetText(char *wndtext, ULONG textlength) | 
|---|
| 1109 | { | 
|---|
| 1110 | SendInternalMessageA(WM_GETTEXT, textlength, (LPARAM)wndtext); | 
|---|
| 1111 | } | 
|---|
| 1112 | //****************************************************************************** | 
|---|
| 1113 | //****************************************************************************** | 
|---|
| 1114 | BOOL Win32BaseWindow::isMDIClient() | 
|---|
| 1115 | { | 
|---|
| 1116 | return FALSE; | 
|---|
| 1117 | } | 
|---|
| 1118 | //****************************************************************************** | 
|---|
| 1119 | //****************************************************************************** | 
|---|
| 1120 | BOOL Win32BaseWindow::isMDIChild() | 
|---|
| 1121 | { | 
|---|
| 1122 | return FALSE; | 
|---|
| 1123 | } | 
|---|
| 1124 | //****************************************************************************** | 
|---|
| 1125 | //TODO: Not complete | 
|---|
| 1126 | //****************************************************************************** | 
|---|
| 1127 | BOOL Win32BaseWindow::isFrameWindow() | 
|---|
| 1128 | { | 
|---|
| 1129 | //    if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION)) | 
|---|
| 1130 | if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL)) | 
|---|
| 1131 | return TRUE; | 
|---|
| 1132 |  | 
|---|
| 1133 | return FALSE; | 
|---|
| 1134 | } | 
|---|
| 1135 | //****************************************************************************** | 
|---|
| 1136 | //****************************************************************************** | 
|---|
| 1137 | BOOL Win32BaseWindow::IsWindowIconic() | 
|---|
| 1138 | { | 
|---|
| 1139 | return ((getStyle() & WS_MINIMIZE) && windowClass->getIcon()); | 
|---|
| 1140 | } | 
|---|
| 1141 | //****************************************************************************** | 
|---|
| 1142 | //****************************************************************************** | 
|---|
| 1143 | SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar) | 
|---|
| 1144 | { | 
|---|
| 1145 | switch(nBar) | 
|---|
| 1146 | { | 
|---|
| 1147 | case SB_HORZ: | 
|---|
| 1148 | if (!horzScrollInfo) | 
|---|
| 1149 | { | 
|---|
| 1150 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO)); | 
|---|
| 1151 | if (!horzScrollInfo) break; | 
|---|
| 1152 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0; | 
|---|
| 1153 | horzScrollInfo->MaxVal = 100; | 
|---|
| 1154 | horzScrollInfo->flags  = ESB_ENABLE_BOTH; | 
|---|
| 1155 | } | 
|---|
| 1156 | return horzScrollInfo; | 
|---|
| 1157 |  | 
|---|
| 1158 | case SB_VERT: | 
|---|
| 1159 | if (!vertScrollInfo) | 
|---|
| 1160 | { | 
|---|
| 1161 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO)); | 
|---|
| 1162 | if (!vertScrollInfo) break; | 
|---|
| 1163 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0; | 
|---|
| 1164 | vertScrollInfo->MaxVal = 100; | 
|---|
| 1165 | vertScrollInfo->flags  = ESB_ENABLE_BOTH; | 
|---|
| 1166 | } | 
|---|
| 1167 | return vertScrollInfo; | 
|---|
| 1168 | } | 
|---|
| 1169 |  | 
|---|
| 1170 | return NULL; | 
|---|
| 1171 | } | 
|---|
| 1172 | //****************************************************************************** | 
|---|
| 1173 | //****************************************************************************** | 
|---|
| 1174 | LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc) | 
|---|
| 1175 | { | 
|---|
| 1176 | //SvL: Set background color to default button color (not window (white)) | 
|---|
| 1177 | if(ctlType == CTLCOLOR_BTN) | 
|---|
| 1178 | { | 
|---|
| 1179 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE)); | 
|---|
| 1180 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); | 
|---|
| 1181 | return GetSysColorBrush(COLOR_BTNFACE); | 
|---|
| 1182 | } | 
|---|
| 1183 | //SvL: Set background color to default dialog color if window is dialog | 
|---|
| 1184 | if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) { | 
|---|
| 1185 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE)); | 
|---|
| 1186 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); | 
|---|
| 1187 | return GetSysColorBrush(COLOR_BTNFACE); | 
|---|
| 1188 | } | 
|---|
| 1189 |  | 
|---|
| 1190 | if( ctlType == CTLCOLOR_SCROLLBAR) | 
|---|
| 1191 | { | 
|---|
| 1192 | HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR); | 
|---|
| 1193 | COLORREF bk = GetSysColor(COLOR_3DHILIGHT); | 
|---|
| 1194 | SetTextColor( hdc, GetSysColor(COLOR_3DFACE)); | 
|---|
| 1195 | SetBkColor( hdc, bk); | 
|---|
| 1196 |  | 
|---|
| 1197 | /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT | 
|---|
| 1198 | * we better use 0x55aa bitmap brush to make scrollbar's background | 
|---|
| 1199 | * look different from the window background. | 
|---|
| 1200 | */ | 
|---|
| 1201 | if (bk == GetSysColor(COLOR_WINDOW)) { | 
|---|
| 1202 | return GetPattern55AABrush(); | 
|---|
| 1203 | } | 
|---|
| 1204 |  | 
|---|
| 1205 | UnrealizeObject( hb ); | 
|---|
| 1206 | return (LRESULT)hb; | 
|---|
| 1207 | } | 
|---|
| 1208 |  | 
|---|
| 1209 | SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT)); | 
|---|
| 1210 |  | 
|---|
| 1211 | if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX)) | 
|---|
| 1212 | { | 
|---|
| 1213 | SetBkColor( hdc, GetSysColor(COLOR_WINDOW) ); | 
|---|
| 1214 | } | 
|---|
| 1215 | else | 
|---|
| 1216 | { | 
|---|
| 1217 | SetBkColor( hdc, GetSysColor(COLOR_3DFACE) ); | 
|---|
| 1218 | return (LRESULT)GetSysColorBrush(COLOR_3DFACE); | 
|---|
| 1219 | } | 
|---|
| 1220 | return (LRESULT)GetSysColorBrush(COLOR_WINDOW); | 
|---|
| 1221 | } | 
|---|
| 1222 | //****************************************************************************** | 
|---|
| 1223 | //****************************************************************************** | 
|---|
| 1224 | LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags) | 
|---|
| 1225 | { | 
|---|
| 1226 | /* | 
|---|
| 1227 | * Visibility flag. | 
|---|
| 1228 | */ | 
|---|
| 1229 | if ( (uFlags & PRF_CHECKVISIBLE) && | 
|---|
| 1230 | !IsWindowVisible() ) | 
|---|
| 1231 | return 0; | 
|---|
| 1232 |  | 
|---|
| 1233 | /* | 
|---|
| 1234 | * Unimplemented flags. | 
|---|
| 1235 | */ | 
|---|
| 1236 | if ( (uFlags & PRF_CHILDREN) || | 
|---|
| 1237 | (uFlags & PRF_OWNED)    || | 
|---|
| 1238 | (uFlags & PRF_NONCLIENT) ) | 
|---|
| 1239 | { | 
|---|
| 1240 | dprintf(("WM_PRINT message with unsupported flags\n")); | 
|---|
| 1241 | } | 
|---|
| 1242 |  | 
|---|
| 1243 | /* | 
|---|
| 1244 | * Background | 
|---|
| 1245 | */ | 
|---|
| 1246 | if ( uFlags & PRF_ERASEBKGND) | 
|---|
| 1247 | SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0); | 
|---|
| 1248 |  | 
|---|
| 1249 | /* | 
|---|
| 1250 | * Client area | 
|---|
| 1251 | */ | 
|---|
| 1252 | if ( uFlags & PRF_CLIENT) | 
|---|
| 1253 | SendInternalMessageA(WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT); | 
|---|
| 1254 |  | 
|---|
| 1255 |  | 
|---|
| 1256 | return 0; | 
|---|
| 1257 | } | 
|---|
| 1258 | //****************************************************************************** | 
|---|
| 1259 | //****************************************************************************** | 
|---|
| 1260 | LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1261 | { | 
|---|
| 1262 | switch(Msg) | 
|---|
| 1263 | { | 
|---|
| 1264 | case WM_CLOSE: | 
|---|
| 1265 | dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle())); | 
|---|
| 1266 | DestroyWindow(); | 
|---|
| 1267 | return 0; | 
|---|
| 1268 |  | 
|---|
| 1269 | case WM_GETTEXTLENGTH: | 
|---|
| 1270 | return wndNameLength; | 
|---|
| 1271 |  | 
|---|
| 1272 | case WM_GETTEXT: | 
|---|
| 1273 | if (!lParam || !wParam) return 0; | 
|---|
| 1274 | if (!windowNameA) ((LPSTR)lParam)[0] = 0; | 
|---|
| 1275 | else lstrcpynA((LPSTR)lParam, windowNameA, wParam); | 
|---|
| 1276 | return min(wndNameLength, wParam); | 
|---|
| 1277 |  | 
|---|
| 1278 | case WM_SETTEXT: | 
|---|
| 1279 | { | 
|---|
| 1280 | LPCSTR lpsz = (LPCSTR)lParam; | 
|---|
| 1281 |  | 
|---|
| 1282 | if(windowNameA) free(windowNameA); | 
|---|
| 1283 | if(windowNameW) free(windowNameW); | 
|---|
| 1284 | if (lParam) | 
|---|
| 1285 | { | 
|---|
| 1286 | wndNameLength = strlen(lpsz); | 
|---|
| 1287 | windowNameA = (LPSTR)_smalloc(wndNameLength+1); | 
|---|
| 1288 | strcpy(windowNameA, lpsz); | 
|---|
| 1289 | windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); | 
|---|
| 1290 | lstrcpyAtoW(windowNameW, windowNameA); | 
|---|
| 1291 | } | 
|---|
| 1292 | else | 
|---|
| 1293 | { | 
|---|
| 1294 | windowNameA = NULL; | 
|---|
| 1295 | windowNameW = NULL; | 
|---|
| 1296 | wndNameLength = 0; | 
|---|
| 1297 | } | 
|---|
| 1298 | dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam)); | 
|---|
| 1299 | if ((dwStyle & WS_CAPTION) == WS_CAPTION) | 
|---|
| 1300 | { | 
|---|
| 1301 | //          HandleNCPaint((HRGN)1); | 
|---|
| 1302 | OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA); | 
|---|
| 1303 | } | 
|---|
| 1304 |  | 
|---|
| 1305 | return TRUE; | 
|---|
| 1306 | } | 
|---|
| 1307 |  | 
|---|
| 1308 | case WM_SETREDRAW: | 
|---|
| 1309 | { | 
|---|
| 1310 | if (wParam) | 
|---|
| 1311 | { | 
|---|
| 1312 | setStyle(getStyle() | WS_VISIBLE); | 
|---|
| 1313 | OSLibWinEnableWindowUpdate(OS2HwndFrame,TRUE); | 
|---|
| 1314 | } | 
|---|
| 1315 | else | 
|---|
| 1316 | { | 
|---|
| 1317 | if (getStyle() & WS_VISIBLE) | 
|---|
| 1318 | { | 
|---|
| 1319 | setStyle(getStyle() & ~WS_VISIBLE); | 
|---|
| 1320 | OSLibWinEnableWindowUpdate(OS2HwndFrame,FALSE); | 
|---|
| 1321 | } | 
|---|
| 1322 | } | 
|---|
| 1323 | return 0; | 
|---|
| 1324 | } | 
|---|
| 1325 |  | 
|---|
| 1326 | case WM_CTLCOLORMSGBOX: | 
|---|
| 1327 | case WM_CTLCOLOREDIT: | 
|---|
| 1328 | case WM_CTLCOLORLISTBOX: | 
|---|
| 1329 | case WM_CTLCOLORBTN: | 
|---|
| 1330 | case WM_CTLCOLORDLG: | 
|---|
| 1331 | case WM_CTLCOLORSTATIC: | 
|---|
| 1332 | case WM_CTLCOLORSCROLLBAR: | 
|---|
| 1333 | return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam); | 
|---|
| 1334 |  | 
|---|
| 1335 | case WM_CTLCOLOR: | 
|---|
| 1336 | return DefWndControlColor(HIWORD(lParam), (HDC)wParam); | 
|---|
| 1337 |  | 
|---|
| 1338 | case WM_VKEYTOITEM: | 
|---|
| 1339 | case WM_CHARTOITEM: | 
|---|
| 1340 | return -1; | 
|---|
| 1341 |  | 
|---|
| 1342 | case WM_PARENTNOTIFY: | 
|---|
| 1343 | return 0; | 
|---|
| 1344 |  | 
|---|
| 1345 | case WM_MOUSEACTIVATE: | 
|---|
| 1346 | { | 
|---|
| 1347 | dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam)))); | 
|---|
| 1348 | if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) ) | 
|---|
| 1349 | { | 
|---|
| 1350 | if(getParent()) { | 
|---|
| 1351 | LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam ); | 
|---|
| 1352 | if(rc)  return rc; | 
|---|
| 1353 | } | 
|---|
| 1354 | } | 
|---|
| 1355 | return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE; | 
|---|
| 1356 | } | 
|---|
| 1357 |  | 
|---|
| 1358 | case WM_ACTIVATE: | 
|---|
| 1359 | return 0; | 
|---|
| 1360 |  | 
|---|
| 1361 | case WM_SETCURSOR: | 
|---|
| 1362 | { | 
|---|
| 1363 | dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam)))); | 
|---|
| 1364 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY)) | 
|---|
| 1365 | { | 
|---|
| 1366 | if(getParent()) { | 
|---|
| 1367 | LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam); | 
|---|
| 1368 | if(rc)  return rc; | 
|---|
| 1369 | } | 
|---|
| 1370 | } | 
|---|
| 1371 | if (wParam == Win32Hwnd) | 
|---|
| 1372 | { | 
|---|
| 1373 | HCURSOR hCursor; | 
|---|
| 1374 |  | 
|---|
| 1375 | switch(LOWORD(lParam)) | 
|---|
| 1376 | { | 
|---|
| 1377 | case HTCLIENT: | 
|---|
| 1378 | hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA); | 
|---|
| 1379 | break; | 
|---|
| 1380 |  | 
|---|
| 1381 | case HTLEFT: | 
|---|
| 1382 | case HTRIGHT: | 
|---|
| 1383 | hCursor = LoadCursorA(0,IDC_SIZEWEA); | 
|---|
| 1384 | break; | 
|---|
| 1385 |  | 
|---|
| 1386 | case HTTOP: | 
|---|
| 1387 | case HTBOTTOM: | 
|---|
| 1388 | hCursor = LoadCursorA(0,IDC_SIZENSA); | 
|---|
| 1389 | break; | 
|---|
| 1390 |  | 
|---|
| 1391 | case HTTOPLEFT: | 
|---|
| 1392 | case HTBOTTOMRIGHT: | 
|---|
| 1393 | hCursor = LoadCursorA(0,IDC_SIZENWSEA); | 
|---|
| 1394 | break; | 
|---|
| 1395 |  | 
|---|
| 1396 | case HTTOPRIGHT: | 
|---|
| 1397 | case HTBOTTOMLEFT: | 
|---|
| 1398 | hCursor = LoadCursorA(0,IDC_SIZENESWA); | 
|---|
| 1399 | break; | 
|---|
| 1400 |  | 
|---|
| 1401 | default: | 
|---|
| 1402 | hCursor = LoadCursorA(0,IDC_ARROWA); | 
|---|
| 1403 | break; | 
|---|
| 1404 | } | 
|---|
| 1405 |  | 
|---|
| 1406 | if (hCursor) | 
|---|
| 1407 | { | 
|---|
| 1408 | SetCursor(hCursor); | 
|---|
| 1409 | return 1; | 
|---|
| 1410 | } | 
|---|
| 1411 | else return 0; | 
|---|
| 1412 | } | 
|---|
| 1413 | else return 0; | 
|---|
| 1414 | } | 
|---|
| 1415 |  | 
|---|
| 1416 | case WM_MOUSEMOVE: | 
|---|
| 1417 | return 0; | 
|---|
| 1418 |  | 
|---|
| 1419 | case WM_WINDOWPOSCHANGED: | 
|---|
| 1420 | { | 
|---|
| 1421 | PWINDOWPOS wpos = (PWINDOWPOS)lParam; | 
|---|
| 1422 | WPARAM     wp   = SIZE_RESTORED; | 
|---|
| 1423 |  | 
|---|
| 1424 | if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE)) | 
|---|
| 1425 | { | 
|---|
| 1426 | SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left,rectClient.top)); | 
|---|
| 1427 | } | 
|---|
| 1428 | if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE)) | 
|---|
| 1429 | { | 
|---|
| 1430 | if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED; | 
|---|
| 1431 | else | 
|---|
| 1432 | if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED; | 
|---|
| 1433 |  | 
|---|
| 1434 | SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right  - rectClient.left, | 
|---|
| 1435 | rectClient.bottom - rectClient.top)); | 
|---|
| 1436 | } | 
|---|
| 1437 | return 0; | 
|---|
| 1438 | } | 
|---|
| 1439 | case WM_WINDOWPOSCHANGING: | 
|---|
| 1440 | return HandleWindowPosChanging((WINDOWPOS *)lParam); | 
|---|
| 1441 |  | 
|---|
| 1442 | case WM_ERASEBKGND: | 
|---|
| 1443 | case WM_ICONERASEBKGND: | 
|---|
| 1444 | { | 
|---|
| 1445 | RECT rect; | 
|---|
| 1446 | int rc; | 
|---|
| 1447 |  | 
|---|
| 1448 | if (!windowClass || !windowClass->getBackgroundBrush()) return 0; | 
|---|
| 1449 |  | 
|---|
| 1450 | rc = GetClipBox( (HDC)wParam, &rect ); | 
|---|
| 1451 | if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION)) | 
|---|
| 1452 | { | 
|---|
| 1453 | HBRUSH hBrush = windowClass->getBackgroundBrush(); | 
|---|
| 1454 |  | 
|---|
| 1455 | if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1)) | 
|---|
| 1456 | hBrush = GetSysColorBrush(hBrush-1); | 
|---|
| 1457 |  | 
|---|
| 1458 | FillRect( (HDC)wParam, &rect, hBrush); | 
|---|
| 1459 | } | 
|---|
| 1460 | return 1; | 
|---|
| 1461 | } | 
|---|
| 1462 |  | 
|---|
| 1463 | case WM_PRINT: | 
|---|
| 1464 | return DefWndPrint(wParam,lParam); | 
|---|
| 1465 |  | 
|---|
| 1466 | case WM_PAINTICON: | 
|---|
| 1467 | case WM_PAINT: | 
|---|
| 1468 | { | 
|---|
| 1469 | PAINTSTRUCT ps; | 
|---|
| 1470 | HDC hdc = BeginPaint(getWindowHandle(), &ps ); | 
|---|
| 1471 | if( hdc ) | 
|---|
| 1472 | { | 
|---|
| 1473 | if( (getStyle() & WS_MINIMIZE) && (getWindowClass()->getIcon() && hIcon)) | 
|---|
| 1474 | { | 
|---|
| 1475 | int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2; | 
|---|
| 1476 | int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2; | 
|---|
| 1477 | dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom )); | 
|---|
| 1478 | DrawIcon(hdc, x, y, hIcon ? hIcon:getWindowClass()->getIcon() ); | 
|---|
| 1479 | } | 
|---|
| 1480 | EndPaint(getWindowHandle(), &ps ); | 
|---|
| 1481 | } | 
|---|
| 1482 | return 0; | 
|---|
| 1483 | } | 
|---|
| 1484 |  | 
|---|
| 1485 | case WM_GETDLGCODE: | 
|---|
| 1486 | return 0; | 
|---|
| 1487 |  | 
|---|
| 1488 | case WM_NCPAINT: | 
|---|
| 1489 | return HandleNCPaint((HRGN)wParam); | 
|---|
| 1490 |  | 
|---|
| 1491 | case WM_NCACTIVATE: | 
|---|
| 1492 | return HandleNCActivate(wParam); | 
|---|
| 1493 |  | 
|---|
| 1494 | case WM_NCCREATE: | 
|---|
| 1495 | return(TRUE); | 
|---|
| 1496 |  | 
|---|
| 1497 | case WM_NCDESTROY: | 
|---|
| 1498 | return 0; | 
|---|
| 1499 |  | 
|---|
| 1500 | case WM_NCCALCSIZE: | 
|---|
| 1501 | return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam); | 
|---|
| 1502 |  | 
|---|
| 1503 | case WM_NCLBUTTONDOWN: | 
|---|
| 1504 | return HandleNCLButtonDown(wParam,lParam); | 
|---|
| 1505 |  | 
|---|
| 1506 | case WM_LBUTTONDBLCLK: | 
|---|
| 1507 | case WM_NCLBUTTONDBLCLK: | 
|---|
| 1508 | return HandleNCLButtonDblClk(wParam,lParam); | 
|---|
| 1509 |  | 
|---|
| 1510 | case WM_NCRBUTTONDOWN: | 
|---|
| 1511 | case WM_NCRBUTTONDBLCLK: | 
|---|
| 1512 | case WM_NCMBUTTONDOWN: | 
|---|
| 1513 | case WM_NCMBUTTONDBLCLK: | 
|---|
| 1514 | if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION); | 
|---|
| 1515 | return 0; | 
|---|
| 1516 |  | 
|---|
| 1517 | case WM_NCRBUTTONUP: | 
|---|
| 1518 | return HandleNCRButtonUp(wParam,lParam); | 
|---|
| 1519 |  | 
|---|
| 1520 | case WM_NCMBUTTONUP: | 
|---|
| 1521 | return 0; | 
|---|
| 1522 |  | 
|---|
| 1523 | case WM_NCHITTEST: | 
|---|
| 1524 | { | 
|---|
| 1525 | POINT point; | 
|---|
| 1526 | LRESULT retvalue; | 
|---|
| 1527 |  | 
|---|
| 1528 | point.x = (SHORT)LOWORD(lParam); | 
|---|
| 1529 | point.y = (SHORT)HIWORD(lParam); | 
|---|
| 1530 |  | 
|---|
| 1531 | retvalue = HandleNCHitTest(point); | 
|---|
| 1532 | #if 0 //CB: let the Corel people fix the bugs first | 
|---|
| 1533 | if(retvalue == HTMENU) | 
|---|
| 1534 | MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,TRUE); | 
|---|
| 1535 | else | 
|---|
| 1536 | MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,FALSE); | 
|---|
| 1537 | #endif | 
|---|
| 1538 | return retvalue; | 
|---|
| 1539 | } | 
|---|
| 1540 |  | 
|---|
| 1541 | case WM_SYSCOMMAND: | 
|---|
| 1542 | { | 
|---|
| 1543 | POINT point; | 
|---|
| 1544 |  | 
|---|
| 1545 | point.x = LOWORD(lParam); | 
|---|
| 1546 | point.y = HIWORD(lParam); | 
|---|
| 1547 | return HandleSysCommand(wParam,&point); | 
|---|
| 1548 | } | 
|---|
| 1549 |  | 
|---|
| 1550 | case WM_SYSKEYDOWN: | 
|---|
| 1551 | if(wParam == VK_F4) /* try to close the window */ | 
|---|
| 1552 | { | 
|---|
| 1553 | Win32BaseWindow *window = GetTopParent(); | 
|---|
| 1554 | if(window && !(window->getClass()->getStyle() & CS_NOCLOSE)) | 
|---|
| 1555 | PostMessageA(getWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0); | 
|---|
| 1556 | } | 
|---|
| 1557 |  | 
|---|
| 1558 | Win32BaseWindow *siblingWindow; | 
|---|
| 1559 | HWND sibling; | 
|---|
| 1560 | char nameBuffer [40], mnemonic; | 
|---|
| 1561 | int nameLength; | 
|---|
| 1562 |  | 
|---|
| 1563 | GetWindowTextA (nameBuffer, 40); | 
|---|
| 1564 |  | 
|---|
| 1565 | // search all sibling to see it this key is their mnemonic | 
|---|
| 1566 | sibling = GetWindow (GW_HWNDFIRST); | 
|---|
| 1567 | while (sibling != 0) { | 
|---|
| 1568 | siblingWindow = GetWindowFromHandle (sibling); | 
|---|
| 1569 | nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40); | 
|---|
| 1570 |  | 
|---|
| 1571 | // find the siblings mnemonic | 
|---|
| 1572 | mnemonic = '\0'; | 
|---|
| 1573 | for (int i=0 ; i<nameLength ; i++) { | 
|---|
| 1574 | if (nameBuffer [i] == '&') { | 
|---|
| 1575 | mnemonic = nameBuffer [i+1]; | 
|---|
| 1576 | if ((mnemonic >= 'a') && (mnemonic <= 'z')) | 
|---|
| 1577 | mnemonic -= 32; // make it uppercase | 
|---|
| 1578 | break;  // stop searching | 
|---|
| 1579 | } | 
|---|
| 1580 | } | 
|---|
| 1581 |  | 
|---|
| 1582 | // key matches siblings mnemonic, send mouseclick | 
|---|
| 1583 | if (mnemonic == (char) wParam) { | 
|---|
| 1584 | siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0); | 
|---|
| 1585 | } | 
|---|
| 1586 |  | 
|---|
| 1587 | sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT); | 
|---|
| 1588 | } | 
|---|
| 1589 |  | 
|---|
| 1590 | return 0; | 
|---|
| 1591 |  | 
|---|
| 1592 | #if 0 //CB: todo: MSDN docu: Windown handles these messages and not WM_SYSCHAR (the code below doesn't work) | 
|---|
| 1593 | case WM_KEYDOWN: | 
|---|
| 1594 | case WM_KEYUP: | 
|---|
| 1595 | case WM_SYSKEYDOWN: | 
|---|
| 1596 | case WM_SYSKEYUP: | 
|---|
| 1597 | #endif | 
|---|
| 1598 |  | 
|---|
| 1599 | case WM_SYSCHAR: | 
|---|
| 1600 | { | 
|---|
| 1601 | int iMenuSysKey = 0; | 
|---|
| 1602 | if (wParam == VK_RETURN && (getStyle() & WS_MINIMIZE)) | 
|---|
| 1603 | { | 
|---|
| 1604 | PostMessageA(getWindowHandle(), WM_SYSCOMMAND, | 
|---|
| 1605 | (WPARAM)SC_RESTORE, 0L ); | 
|---|
| 1606 | break; | 
|---|
| 1607 | } | 
|---|
| 1608 | if ((HIWORD(lParam) & KEYDATA_ALT) && wParam) | 
|---|
| 1609 | { | 
|---|
| 1610 | if (wParam == VK_TAB || wParam == VK_ESCAPE) break; | 
|---|
| 1611 | if (wParam == VK_SPACE && (getStyle() & WS_CHILD)) | 
|---|
| 1612 | getParent()->SendMessageA(Msg, wParam, lParam ); | 
|---|
| 1613 | else | 
|---|
| 1614 | SendMessageA(WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam ); | 
|---|
| 1615 | } | 
|---|
| 1616 | else /* check for Ctrl-Esc */ | 
|---|
| 1617 | if (wParam != VK_ESCAPE) MessageBeep(0); | 
|---|
| 1618 | break; | 
|---|
| 1619 | } | 
|---|
| 1620 |  | 
|---|
| 1621 | case WM_SETHOTKEY: | 
|---|
| 1622 | hotkey = wParam; | 
|---|
| 1623 | return 1; //CB: always successful | 
|---|
| 1624 |  | 
|---|
| 1625 | case WM_GETHOTKEY: | 
|---|
| 1626 | return hotkey; | 
|---|
| 1627 |  | 
|---|
| 1628 | case WM_CONTEXTMENU: | 
|---|
| 1629 | if ((dwStyle & WS_CHILD) && getParent()) | 
|---|
| 1630 | getParent()->SendInternalMessageA(WM_CONTEXTMENU,wParam,lParam); | 
|---|
| 1631 | return 0; | 
|---|
| 1632 |  | 
|---|
| 1633 | case WM_SHOWWINDOW: | 
|---|
| 1634 | if (!lParam) return 0; /* sent from ShowWindow */ | 
|---|
| 1635 | if (!(dwStyle & WS_POPUP) || !owner) return 0; | 
|---|
| 1636 | if ((dwStyle & WS_VISIBLE) && wParam) return 0; | 
|---|
| 1637 | else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0; | 
|---|
| 1638 | ShowWindow(wParam ? SW_SHOW:SW_HIDE); | 
|---|
| 1639 | return 0; | 
|---|
| 1640 |  | 
|---|
| 1641 | case WM_CANCELMODE: | 
|---|
| 1642 | if (getParent() == windowDesktop) EndMenu(); | 
|---|
| 1643 | if (GetCapture() == Win32Hwnd) ReleaseCapture(); | 
|---|
| 1644 | return 0; | 
|---|
| 1645 |  | 
|---|
| 1646 | case WM_DROPOBJECT: | 
|---|
| 1647 | return DRAG_FILE; | 
|---|
| 1648 |  | 
|---|
| 1649 | case WM_QUERYDROPOBJECT: | 
|---|
| 1650 | return (dwExStyle & WS_EX_ACCEPTFILES) ? 1:0; | 
|---|
| 1651 |  | 
|---|
| 1652 | case WM_QUERYDRAGICON: | 
|---|
| 1653 | { | 
|---|
| 1654 | HICON hDragIcon = windowClass->getCursor(); | 
|---|
| 1655 | UINT len; | 
|---|
| 1656 |  | 
|---|
| 1657 | if(hDragIcon) return (LRESULT)hDragIcon; | 
|---|
| 1658 | for(len = 1; len < 64; len++) | 
|---|
| 1659 | { | 
|---|
| 1660 | hDragIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len)); | 
|---|
| 1661 | if(hDragIcon) | 
|---|
| 1662 | return (LRESULT)hDragIcon; | 
|---|
| 1663 | } | 
|---|
| 1664 | return (LRESULT)LoadIconA(0,IDI_APPLICATIONA); | 
|---|
| 1665 | } | 
|---|
| 1666 |  | 
|---|
| 1667 | case WM_QUERYOPEN: | 
|---|
| 1668 | case WM_QUERYENDSESSION: | 
|---|
| 1669 | return 1; | 
|---|
| 1670 |  | 
|---|
| 1671 | case WM_NOTIFYFORMAT: | 
|---|
| 1672 | return IsWindowUnicode() ? NFR_UNICODE:NFR_ANSI; | 
|---|
| 1673 |  | 
|---|
| 1674 | case WM_SETICON: | 
|---|
| 1675 | case WM_GETICON: | 
|---|
| 1676 | { | 
|---|
| 1677 | LRESULT result = 0; | 
|---|
| 1678 |  | 
|---|
| 1679 | /* Set the appropriate icon members in the window structure. */ | 
|---|
| 1680 | if (wParam == ICON_SMALL) | 
|---|
| 1681 | { | 
|---|
| 1682 | result = hIconSm; | 
|---|
| 1683 | if (Msg == WM_SETICON) | 
|---|
| 1684 | hIconSm = (HICON)lParam; | 
|---|
| 1685 | } | 
|---|
| 1686 | else | 
|---|
| 1687 | { | 
|---|
| 1688 | result = hIcon; | 
|---|
| 1689 | if (Msg == WM_SETICON) | 
|---|
| 1690 | { | 
|---|
| 1691 | hIcon = (HICON)lParam; | 
|---|
| 1692 | if ((dwStyle & WS_CAPTION) == WS_CAPTION) | 
|---|
| 1693 | OSLibWinSetIcon(OS2HwndFrame,hIcon); | 
|---|
| 1694 | } | 
|---|
| 1695 | } | 
|---|
| 1696 | if ((Msg == WM_SETICON) && ((dwStyle & WS_CAPTION) == WS_CAPTION)) | 
|---|
| 1697 | HandleNCPaint((HRGN)1); | 
|---|
| 1698 |  | 
|---|
| 1699 | return result; | 
|---|
| 1700 | } | 
|---|
| 1701 |  | 
|---|
| 1702 | case WM_HELP: | 
|---|
| 1703 | if (getParent()) getParent()->SendInternalMessageA(Msg,wParam,lParam); | 
|---|
| 1704 | break; | 
|---|
| 1705 |  | 
|---|
| 1706 | case WM_NOTIFY: | 
|---|
| 1707 | return 0; //comctl32 controls expect this | 
|---|
| 1708 |  | 
|---|
| 1709 | default: | 
|---|
| 1710 | return 0; | 
|---|
| 1711 | } | 
|---|
| 1712 | return 0; | 
|---|
| 1713 | } | 
|---|
| 1714 | //****************************************************************************** | 
|---|
| 1715 | //****************************************************************************** | 
|---|
| 1716 | LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1717 | { | 
|---|
| 1718 | switch(Msg) | 
|---|
| 1719 | { | 
|---|
| 1720 | case WM_GETTEXTLENGTH: | 
|---|
| 1721 | return wndNameLength; | 
|---|
| 1722 |  | 
|---|
| 1723 | case WM_GETTEXT: | 
|---|
| 1724 | if (!lParam || !wParam) return 0; | 
|---|
| 1725 | if (!windowNameW) ((LPWSTR)lParam)[0] = 0; | 
|---|
| 1726 | else lstrcpynW((LPWSTR)lParam,windowNameW,wParam); | 
|---|
| 1727 | return min(wndNameLength,wParam); | 
|---|
| 1728 |  | 
|---|
| 1729 | case WM_SETTEXT: | 
|---|
| 1730 | { | 
|---|
| 1731 | LPWSTR lpsz = (LPWSTR)lParam; | 
|---|
| 1732 |  | 
|---|
| 1733 | if(windowNameA) free(windowNameA); | 
|---|
| 1734 | if(windowNameW) free(windowNameW); | 
|---|
| 1735 | if (lParam) | 
|---|
| 1736 | { | 
|---|
| 1737 | wndNameLength = lstrlenW(lpsz); | 
|---|
| 1738 | windowNameA = (LPSTR)_smalloc(wndNameLength+1); | 
|---|
| 1739 | lstrcpyWtoA(windowNameA,lpsz); | 
|---|
| 1740 | windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); | 
|---|
| 1741 | lstrcpyW(windowNameW,lpsz); | 
|---|
| 1742 | } | 
|---|
| 1743 | else | 
|---|
| 1744 | { | 
|---|
| 1745 | windowNameA = NULL; | 
|---|
| 1746 | windowNameW = NULL; | 
|---|
| 1747 | wndNameLength = 0; | 
|---|
| 1748 | } | 
|---|
| 1749 | dprintf(("WM_SETTEXT of %x\n",Win32Hwnd)); | 
|---|
| 1750 | if ((dwStyle & WS_CAPTION) == WS_CAPTION) | 
|---|
| 1751 | { | 
|---|
| 1752 | HandleNCPaint((HRGN)1); | 
|---|
| 1753 | OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA); | 
|---|
| 1754 | } | 
|---|
| 1755 |  | 
|---|
| 1756 | return TRUE; | 
|---|
| 1757 | } | 
|---|
| 1758 |  | 
|---|
| 1759 | default: | 
|---|
| 1760 | return DefWindowProcA(Msg, wParam, lParam); | 
|---|
| 1761 | } | 
|---|
| 1762 | } | 
|---|
| 1763 | //****************************************************************************** | 
|---|
| 1764 | //****************************************************************************** | 
|---|
| 1765 | LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1766 | { | 
|---|
| 1767 | //if the destination window is created by this process & thread, call window proc directly | 
|---|
| 1768 | if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) { | 
|---|
| 1769 | return SendInternalMessageA(Msg, wParam, lParam); | 
|---|
| 1770 | } | 
|---|
| 1771 | //otherwise use WinSendMsg to send it to the right process/thread | 
|---|
| 1772 | dprintf(("SendMessages (inter-process) %x %x %x %x", getWindowHandle(), Msg, wParam, lParam)); | 
|---|
| 1773 | return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE); | 
|---|
| 1774 | } | 
|---|
| 1775 | //****************************************************************************** | 
|---|
| 1776 | //****************************************************************************** | 
|---|
| 1777 | LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1778 | { | 
|---|
| 1779 | //if the destination window is created by this process & thread, call window proc directly | 
|---|
| 1780 | if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) { | 
|---|
| 1781 | return SendInternalMessageW(Msg, wParam, lParam); | 
|---|
| 1782 | } | 
|---|
| 1783 | //otherwise use WinSendMsg to send it to the right process/thread | 
|---|
| 1784 | return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, TRUE); | 
|---|
| 1785 | } | 
|---|
| 1786 | //****************************************************************************** | 
|---|
| 1787 | //Called as a result of an OS/2 message or called from a class method | 
|---|
| 1788 | //****************************************************************************** | 
|---|
| 1789 | LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1790 | { | 
|---|
| 1791 | LRESULT rc; | 
|---|
| 1792 | BOOL    fInternalMsgBackup = fInternalMsg; | 
|---|
| 1793 |  | 
|---|
| 1794 | DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE); | 
|---|
| 1795 |  | 
|---|
| 1796 | CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE); | 
|---|
| 1797 |  | 
|---|
| 1798 | fInternalMsg = TRUE; | 
|---|
| 1799 | switch(Msg) | 
|---|
| 1800 | { | 
|---|
| 1801 | case WM_CREATE: | 
|---|
| 1802 | { | 
|---|
| 1803 | if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) { | 
|---|
| 1804 | dprintf(("WM_CREATE returned -1\n")); | 
|---|
| 1805 | rc = -1; //don't create window | 
|---|
| 1806 | break; | 
|---|
| 1807 | } | 
|---|
| 1808 | rc = 0; | 
|---|
| 1809 | break; | 
|---|
| 1810 | } | 
|---|
| 1811 | case WM_LBUTTONDOWN: | 
|---|
| 1812 | case WM_MBUTTONDOWN: | 
|---|
| 1813 | case WM_RBUTTONDOWN: | 
|---|
| 1814 | { | 
|---|
| 1815 | if (getParent()) | 
|---|
| 1816 | { | 
|---|
| 1817 | POINTS pt = MAKEPOINTS(lParam); | 
|---|
| 1818 | POINT point; | 
|---|
| 1819 |  | 
|---|
| 1820 | point.x = pt.x; | 
|---|
| 1821 | point.y = pt.y; | 
|---|
| 1822 | mapWin32Point(OS2Hwnd,getParent()->getOS2WindowHandle(),(OSLIBPOINT*)&point); | 
|---|
| 1823 | NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y)); | 
|---|
| 1824 | } | 
|---|
| 1825 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam); | 
|---|
| 1826 | break; | 
|---|
| 1827 | } | 
|---|
| 1828 |  | 
|---|
| 1829 | case WM_DESTROY: | 
|---|
| 1830 | rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); | 
|---|
| 1831 | break; | 
|---|
| 1832 |  | 
|---|
| 1833 | default: | 
|---|
| 1834 | rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam); | 
|---|
| 1835 | break; | 
|---|
| 1836 | } | 
|---|
| 1837 | fInternalMsg = fInternalMsgBackup; | 
|---|
| 1838 | return rc; | 
|---|
| 1839 | } | 
|---|
| 1840 | //****************************************************************************** | 
|---|
| 1841 | //Called as a result of an OS/2 message or called from a class method | 
|---|
| 1842 | //****************************************************************************** | 
|---|
| 1843 | LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1844 | { | 
|---|
| 1845 | LRESULT rc; | 
|---|
| 1846 | BOOL    fInternalMsgBackup = fInternalMsg; | 
|---|
| 1847 |  | 
|---|
| 1848 | DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE); | 
|---|
| 1849 |  | 
|---|
| 1850 | CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE); | 
|---|
| 1851 |  | 
|---|
| 1852 | fInternalMsg = TRUE; | 
|---|
| 1853 | switch(Msg) | 
|---|
| 1854 | { | 
|---|
| 1855 | case WM_CREATE: | 
|---|
| 1856 | { | 
|---|
| 1857 | if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) { | 
|---|
| 1858 | dprintf(("WM_CREATE returned -1\n")); | 
|---|
| 1859 | rc = -1; //don't create window | 
|---|
| 1860 | break; | 
|---|
| 1861 | } | 
|---|
| 1862 | rc = 0; | 
|---|
| 1863 | break; | 
|---|
| 1864 | } | 
|---|
| 1865 | case WM_LBUTTONDOWN: | 
|---|
| 1866 | case WM_MBUTTONDOWN: | 
|---|
| 1867 | case WM_RBUTTONDOWN: | 
|---|
| 1868 | NotifyParent(Msg, wParam, lParam); | 
|---|
| 1869 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam); | 
|---|
| 1870 | break; | 
|---|
| 1871 |  | 
|---|
| 1872 | case WM_DESTROY: | 
|---|
| 1873 | rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); | 
|---|
| 1874 | break; | 
|---|
| 1875 | default: | 
|---|
| 1876 | rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam); | 
|---|
| 1877 | break; | 
|---|
| 1878 | } | 
|---|
| 1879 | fInternalMsg = fInternalMsgBackup; | 
|---|
| 1880 | return rc; | 
|---|
| 1881 | } | 
|---|
| 1882 | //****************************************************************************** | 
|---|
| 1883 | //****************************************************************************** | 
|---|
| 1884 | void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode) | 
|---|
| 1885 | { | 
|---|
| 1886 | CWPSTRUCT cwp; | 
|---|
| 1887 |  | 
|---|
| 1888 | cwp.lParam  = lParam; | 
|---|
| 1889 | cwp.wParam  = wParam; | 
|---|
| 1890 | cwp.message = Msg; | 
|---|
| 1891 | cwp.hwnd    = getWindowHandle(); | 
|---|
| 1892 |  | 
|---|
| 1893 | switch(hooktype) { | 
|---|
| 1894 | case WH_CALLWNDPROC: | 
|---|
| 1895 | if(fUnicode) { | 
|---|
| 1896 | HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp); | 
|---|
| 1897 | } | 
|---|
| 1898 | else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp); | 
|---|
| 1899 | break; | 
|---|
| 1900 | } | 
|---|
| 1901 | } | 
|---|
| 1902 | //****************************************************************************** | 
|---|
| 1903 | //TODO: Do this more efficiently | 
|---|
| 1904 | //****************************************************************************** | 
|---|
| 1905 | LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1906 | { | 
|---|
| 1907 | Win32BaseWindow *window; | 
|---|
| 1908 | HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD; | 
|---|
| 1909 |  | 
|---|
| 1910 | dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS())); | 
|---|
| 1911 |  | 
|---|
| 1912 | for(int i=0;i<MAX_WINDOW_HANDLES;i++) { | 
|---|
| 1913 | window = GetWindowFromHandle(hwnd++); | 
|---|
| 1914 | if(window) { | 
|---|
| 1915 | if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION)) | 
|---|
| 1916 | { | 
|---|
| 1917 |  | 
|---|
| 1918 | if(type == BROADCAST_SEND) { | 
|---|
| 1919 | window->SendInternalMessageA(msg, wParam, lParam); | 
|---|
| 1920 | } | 
|---|
| 1921 | else    PostMessageA(window->getWindowHandle(), msg, wParam, lParam); | 
|---|
| 1922 | } | 
|---|
| 1923 | } | 
|---|
| 1924 | } | 
|---|
| 1925 | return 0; | 
|---|
| 1926 | } | 
|---|
| 1927 | //****************************************************************************** | 
|---|
| 1928 | //TODO: Do this more efficiently | 
|---|
| 1929 | //****************************************************************************** | 
|---|
| 1930 | LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1931 | { | 
|---|
| 1932 | Win32BaseWindow *window; | 
|---|
| 1933 | HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD; | 
|---|
| 1934 |  | 
|---|
| 1935 | dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam)); | 
|---|
| 1936 |  | 
|---|
| 1937 | for(int i=0;i<MAX_WINDOW_HANDLES;i++) { | 
|---|
| 1938 | window = GetWindowFromHandle(hwnd++); | 
|---|
| 1939 | if(window) { | 
|---|
| 1940 | if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION)) | 
|---|
| 1941 | { | 
|---|
| 1942 |  | 
|---|
| 1943 | if(type == BROADCAST_SEND) { | 
|---|
| 1944 | window->SendInternalMessageW(msg, wParam, lParam); | 
|---|
| 1945 | } | 
|---|
| 1946 | else    PostMessageW(window->getWindowHandle(), msg, wParam, lParam); | 
|---|
| 1947 | } | 
|---|
| 1948 | } | 
|---|
| 1949 | } | 
|---|
| 1950 | return 0; | 
|---|
| 1951 | } | 
|---|
| 1952 | //****************************************************************************** | 
|---|
| 1953 | //****************************************************************************** | 
|---|
| 1954 | void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1955 | { | 
|---|
| 1956 | Win32BaseWindow *window = this; | 
|---|
| 1957 | Win32BaseWindow *parentwindow; | 
|---|
| 1958 |  | 
|---|
| 1959 | while(window) | 
|---|
| 1960 | { | 
|---|
| 1961 | if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) ) | 
|---|
| 1962 | { | 
|---|
| 1963 | /* Notify the parent window only */ | 
|---|
| 1964 | parentwindow = window->getParent(); | 
|---|
| 1965 | if(parentwindow) { | 
|---|
| 1966 | parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam ); | 
|---|
| 1967 | } | 
|---|
| 1968 | } | 
|---|
| 1969 | else    break; | 
|---|
| 1970 |  | 
|---|
| 1971 | window = parentwindow; | 
|---|
| 1972 | } | 
|---|
| 1973 | } | 
|---|
| 1974 | //****************************************************************************** | 
|---|
| 1975 | // Returns the big or small icon for the window, falling back to the | 
|---|
| 1976 | // class as windows does. | 
|---|
| 1977 | //****************************************************************************** | 
|---|
| 1978 | HICON Win32BaseWindow::IconForWindow(WPARAM fType) | 
|---|
| 1979 | { | 
|---|
| 1980 | HICON hWndIcon; | 
|---|
| 1981 |  | 
|---|
| 1982 | if (fType == ICON_BIG) | 
|---|
| 1983 | { | 
|---|
| 1984 | if (hIcon) hWndIcon = hIcon; | 
|---|
| 1985 | else if (windowClass && windowClass->getIcon()) hWndIcon = windowClass->getIcon(); | 
|---|
| 1986 | else if (!(dwStyle & DS_MODALFRAME)) | 
|---|
| 1987 | hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR); | 
|---|
| 1988 | else hWndIcon = 0; | 
|---|
| 1989 | } else | 
|---|
| 1990 | { | 
|---|
| 1991 | if (hIconSm) hWndIcon = hIconSm; | 
|---|
| 1992 | else if (hIcon) hWndIcon = hIcon; | 
|---|
| 1993 | else if (windowClass && windowClass->getIconSm()) hWndIcon = windowClass->getIconSm(); | 
|---|
| 1994 | else if (windowClass && windowClass->getIcon()) hWndIcon = windowClass->getIcon(); | 
|---|
| 1995 | else if (!(dwStyle & DS_MODALFRAME)) | 
|---|
| 1996 | hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR); | 
|---|
| 1997 | else hWndIcon = 0; | 
|---|
| 1998 | } | 
|---|
| 1999 |  | 
|---|
| 2000 | return hWndIcon; | 
|---|
| 2001 | } | 
|---|
| 2002 | //****************************************************************************** | 
|---|
| 2003 | //****************************************************************************** | 
|---|
| 2004 | BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow) | 
|---|
| 2005 | { | 
|---|
| 2006 | ULONG showstate = 0; | 
|---|
| 2007 | HWND hWinAfter; | 
|---|
| 2008 |  | 
|---|
| 2009 | dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow)); | 
|---|
| 2010 |  | 
|---|
| 2011 | if (flags & WIN_NEED_SIZE) | 
|---|
| 2012 | { | 
|---|
| 2013 | /* should happen only in CreateWindowEx() */ | 
|---|
| 2014 | int wParam = SIZE_RESTORED; | 
|---|
| 2015 |  | 
|---|
| 2016 | flags &= ~WIN_NEED_SIZE; | 
|---|
| 2017 | if (dwStyle & WS_MAXIMIZE) | 
|---|
| 2018 | wParam = SIZE_MAXIMIZED; | 
|---|
| 2019 | else | 
|---|
| 2020 | if (dwStyle & WS_MINIMIZE) | 
|---|
| 2021 | wParam = SIZE_MINIMIZED; | 
|---|
| 2022 |  | 
|---|
| 2023 | SendInternalMessageA(WM_SIZE, wParam, | 
|---|
| 2024 | MAKELONG(rectClient.right-rectClient.left, | 
|---|
| 2025 | rectClient.bottom-rectClient.top)); | 
|---|
| 2026 | SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top)); | 
|---|
| 2027 | } | 
|---|
| 2028 | switch(nCmdShow) | 
|---|
| 2029 | { | 
|---|
| 2030 | case SW_SHOW: | 
|---|
| 2031 | case SW_SHOWDEFAULT: //todo | 
|---|
| 2032 | showstate = SWPOS_SHOW | SWPOS_ACTIVATE; | 
|---|
| 2033 | break; | 
|---|
| 2034 | case SW_HIDE: | 
|---|
| 2035 | showstate = SWPOS_HIDE; | 
|---|
| 2036 | break; | 
|---|
| 2037 | case SW_RESTORE: | 
|---|
| 2038 | showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE; | 
|---|
| 2039 | break; | 
|---|
| 2040 | case SW_MINIMIZE: | 
|---|
| 2041 | showstate = SWPOS_MINIMIZE; | 
|---|
| 2042 | break; | 
|---|
| 2043 | case SW_SHOWMAXIMIZED: | 
|---|
| 2044 | showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE; | 
|---|
| 2045 | break; | 
|---|
| 2046 | case SW_SHOWMINIMIZED: | 
|---|
| 2047 | showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE; | 
|---|
| 2048 | break; | 
|---|
| 2049 | case SW_SHOWMINNOACTIVE: | 
|---|
| 2050 | showstate = SWPOS_MINIMIZE | SWPOS_SHOW; | 
|---|
| 2051 | break; | 
|---|
| 2052 | case SW_SHOWNA: | 
|---|
| 2053 | showstate = SWPOS_SHOW; | 
|---|
| 2054 | break; | 
|---|
| 2055 | case SW_SHOWNOACTIVATE: | 
|---|
| 2056 | showstate = SWPOS_SHOW; | 
|---|
| 2057 | break; | 
|---|
| 2058 | case SW_SHOWNORMAL: | 
|---|
| 2059 | showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW; | 
|---|
| 2060 | break; | 
|---|
| 2061 | } | 
|---|
| 2062 |  | 
|---|
| 2063 | /* We can't activate a child window (WINE) */ | 
|---|
| 2064 | if(getStyle() & WS_CHILD) | 
|---|
| 2065 | showstate &= ~SWPOS_ACTIVATE; | 
|---|
| 2066 |  | 
|---|
| 2067 | if(showstate & SWPOS_SHOW) { | 
|---|
| 2068 | setStyle(getStyle() | WS_VISIBLE); | 
|---|
| 2069 | } | 
|---|
| 2070 | else    setStyle(getStyle() & ~WS_VISIBLE); | 
|---|
| 2071 |  | 
|---|
| 2072 | BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate); | 
|---|
| 2073 |  | 
|---|
| 2074 | return rc; | 
|---|
| 2075 | } | 
|---|
| 2076 | //****************************************************************************** | 
|---|
| 2077 | //****************************************************************************** | 
|---|
| 2078 | BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags) | 
|---|
| 2079 | { | 
|---|
| 2080 | BOOL rc = FALSE; | 
|---|
| 2081 | Win32BaseWindow *window; | 
|---|
| 2082 | HWND hParent = 0; | 
|---|
| 2083 | BOOL fShow = FALSE, fHide = FALSE; | 
|---|
| 2084 |  | 
|---|
| 2085 | if (fuFlags & | 
|---|
| 2086 | ~(SWP_NOSIZE     | SWP_NOMOVE     | SWP_NOZORDER     | | 
|---|
| 2087 | SWP_NOREDRAW   | SWP_NOACTIVATE | SWP_FRAMECHANGED | | 
|---|
| 2088 | SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS   | | 
|---|
| 2089 | SWP_NOOWNERZORDER)) | 
|---|
| 2090 | { | 
|---|
| 2091 | return FALSE; | 
|---|
| 2092 | } | 
|---|
| 2093 |  | 
|---|
| 2094 | if(IsWindowDestroyed()) { | 
|---|
| 2095 | //changing the position of a window that's being destroyed can cause crashes in PMMERGE | 
|---|
| 2096 | dprintf(("SetWindowPos; window already destroyed")); | 
|---|
| 2097 | return TRUE; | 
|---|
| 2098 | } | 
|---|
| 2099 | WINDOWPOS wpos; | 
|---|
| 2100 | SWP swp, swpOld; | 
|---|
| 2101 | #if 0 //CB: breaks trackbar tooltip: must call SetWindowPos twice to change the size | 
|---|
| 2102 | if(fuFlags & SWP_SHOWWINDOW) { | 
|---|
| 2103 | fShow = TRUE; | 
|---|
| 2104 | fuFlags &= ~SWP_SHOWWINDOW; | 
|---|
| 2105 | } | 
|---|
| 2106 | else | 
|---|
| 2107 | #endif | 
|---|
| 2108 | if(fuFlags & SWP_HIDEWINDOW) { | 
|---|
| 2109 | fHide = TRUE; | 
|---|
| 2110 | fuFlags &= ~SWP_HIDEWINDOW; | 
|---|
| 2111 | } | 
|---|
| 2112 | wpos.flags            = fuFlags; | 
|---|
| 2113 | wpos.cy               = cy; | 
|---|
| 2114 | wpos.cx               = cx; | 
|---|
| 2115 | wpos.x                = x; | 
|---|
| 2116 | wpos.y                = y; | 
|---|
| 2117 | wpos.hwndInsertAfter  = hwndInsertAfter; | 
|---|
| 2118 | wpos.hwnd             = getWindowHandle(); | 
|---|
| 2119 |  | 
|---|
| 2120 | if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE)) | 
|---|
| 2121 | { | 
|---|
| 2122 | if (isChild()) | 
|---|
| 2123 | { | 
|---|
| 2124 | Win32BaseWindow *windowParent = getParent(); | 
|---|
| 2125 | if(windowParent) { | 
|---|
| 2126 | hParent = getParent()->getOS2WindowHandle(); | 
|---|
| 2127 | } | 
|---|
| 2128 | else    dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle())); | 
|---|
| 2129 | } | 
|---|
| 2130 | OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld); | 
|---|
| 2131 | } | 
|---|
| 2132 |  | 
|---|
| 2133 | OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame); | 
|---|
| 2134 | if (swp.fl == 0) { | 
|---|
| 2135 | if (fuFlags & SWP_FRAMECHANGED) | 
|---|
| 2136 | { | 
|---|
| 2137 | FrameUpdateClient(this); | 
|---|
| 2138 | } | 
|---|
| 2139 | if(fHide) { | 
|---|
| 2140 | ShowWindow(SW_HIDE); | 
|---|
| 2141 | } | 
|---|
| 2142 | if(fShow) { | 
|---|
| 2143 | ShowWindow(SW_SHOWNA); | 
|---|
| 2144 | } | 
|---|
| 2145 | return TRUE; | 
|---|
| 2146 | } | 
|---|
| 2147 |  | 
|---|
| 2148 | //   if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM)) | 
|---|
| 2149 | if ((swp.hwndInsertBehind > HWNDOS_BOTTOM)) | 
|---|
| 2150 | { | 
|---|
| 2151 | Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind); | 
|---|
| 2152 | if(wndBehind) { | 
|---|
| 2153 | swp.hwndInsertBehind   = wndBehind->getOS2FrameWindowHandle(); | 
|---|
| 2154 | } | 
|---|
| 2155 | else { | 
|---|
| 2156 | dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind)); | 
|---|
| 2157 | swp.hwndInsertBehind = 0; | 
|---|
| 2158 | } | 
|---|
| 2159 | } | 
|---|
| 2160 | swp.hwnd = OS2HwndFrame; | 
|---|
| 2161 |  | 
|---|
| 2162 | dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl)); | 
|---|
| 2163 |  | 
|---|
| 2164 | //SvL: For some reason WinSetMultWindowPos doesn't work for showing windows when they are hidden.. | 
|---|
| 2165 | if(fHide) { | 
|---|
| 2166 | ShowWindow(SW_HIDE); | 
|---|
| 2167 | } | 
|---|
| 2168 | rc = OSLibWinSetMultWindowPos(&swp, 1); | 
|---|
| 2169 | if(fShow) { | 
|---|
| 2170 | ShowWindow(SW_SHOWNA); | 
|---|
| 2171 | } | 
|---|
| 2172 |  | 
|---|
| 2173 | if (rc == FALSE) | 
|---|
| 2174 | { | 
|---|
| 2175 | dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError())); | 
|---|
| 2176 | } | 
|---|
| 2177 |  | 
|---|
| 2178 | if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE))) | 
|---|
| 2179 | { | 
|---|
| 2180 | FrameUpdateClient(this); | 
|---|
| 2181 | } | 
|---|
| 2182 |  | 
|---|
| 2183 | return (rc); | 
|---|
| 2184 | } | 
|---|
| 2185 | //****************************************************************************** | 
|---|
| 2186 | //TODO: WPF_RESTOREMAXIMIZED | 
|---|
| 2187 | //****************************************************************************** | 
|---|
| 2188 | BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos) | 
|---|
| 2189 | { | 
|---|
| 2190 | if(isFrameWindow()) | 
|---|
| 2191 | { | 
|---|
| 2192 | // Set the minimized position | 
|---|
| 2193 | if (winpos->flags & WPF_SETMINPOSITION) | 
|---|
| 2194 | { | 
|---|
| 2195 | OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y); | 
|---|
| 2196 | } | 
|---|
| 2197 |  | 
|---|
| 2198 | //TODO: Max position | 
|---|
| 2199 |  | 
|---|
| 2200 | // Set the new restore position. | 
|---|
| 2201 | OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition); | 
|---|
| 2202 | } | 
|---|
| 2203 |  | 
|---|
| 2204 | return ShowWindow(winpos->showCmd); | 
|---|
| 2205 | } | 
|---|
| 2206 | //****************************************************************************** | 
|---|
| 2207 | //Also destroys all the child windows (destroy children first, parent last) | 
|---|
| 2208 | //****************************************************************************** | 
|---|
| 2209 | BOOL Win32BaseWindow::DestroyWindow() | 
|---|
| 2210 | { | 
|---|
| 2211 | /* Call hooks */ | 
|---|
| 2212 | if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L)) | 
|---|
| 2213 | { | 
|---|
| 2214 | return FALSE; | 
|---|
| 2215 | } | 
|---|
| 2216 |  | 
|---|
| 2217 | if(!(getStyle() & WS_CHILD) && getOwner() == NULL) | 
|---|
| 2218 | { | 
|---|
| 2219 | HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L); | 
|---|
| 2220 | /* FIXME: clean up palette - see "Internals" p.352 */ | 
|---|
| 2221 | } | 
|---|
| 2222 |  | 
|---|
| 2223 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY)) | 
|---|
| 2224 | { | 
|---|
| 2225 | if(getParent()) | 
|---|
| 2226 | { | 
|---|
| 2227 | /* Notify the parent window only */ | 
|---|
| 2228 | getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle()); | 
|---|
| 2229 | if( !::IsWindow(getWindowHandle()) ) | 
|---|
| 2230 | { | 
|---|
| 2231 | return TRUE; | 
|---|
| 2232 | } | 
|---|
| 2233 | } | 
|---|
| 2234 | else DebugInt3(); | 
|---|
| 2235 | } | 
|---|
| 2236 | fDestroyWindowCalled = TRUE; | 
|---|
| 2237 | return OSLibWinDestroyWindow(OS2HwndFrame); | 
|---|
| 2238 | } | 
|---|
| 2239 | //****************************************************************************** | 
|---|
| 2240 | //****************************************************************************** | 
|---|
| 2241 | Win32BaseWindow *Win32BaseWindow::getParent() | 
|---|
| 2242 | { | 
|---|
| 2243 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent(); | 
|---|
| 2244 | return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent; | 
|---|
| 2245 | } | 
|---|
| 2246 | //****************************************************************************** | 
|---|
| 2247 | //****************************************************************************** | 
|---|
| 2248 | HWND Win32BaseWindow::GetParent() | 
|---|
| 2249 | { | 
|---|
| 2250 | Win32BaseWindow *wndparent; | 
|---|
| 2251 |  | 
|---|
| 2252 | if ((!(getStyle() & (WS_POPUP|WS_CHILD)))) | 
|---|
| 2253 | { | 
|---|
| 2254 | return 0; | 
|---|
| 2255 | } | 
|---|
| 2256 | wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner()); | 
|---|
| 2257 |  | 
|---|
| 2258 | return (wndparent) ? wndparent->getWindowHandle() : 0; | 
|---|
| 2259 | } | 
|---|
| 2260 | //****************************************************************************** | 
|---|
| 2261 | //****************************************************************************** | 
|---|
| 2262 | HWND Win32BaseWindow::SetParent(HWND hwndNewParent) | 
|---|
| 2263 | { | 
|---|
| 2264 | HWND oldhwnd; | 
|---|
| 2265 | Win32BaseWindow *newparent; | 
|---|
| 2266 | Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::GetParent(); | 
|---|
| 2267 |  | 
|---|
| 2268 | if(oldparent) { | 
|---|
| 2269 | oldhwnd = oldparent->getWindowHandle(); | 
|---|
| 2270 | oldparent->RemoveChild(this); | 
|---|
| 2271 | } | 
|---|
| 2272 | else oldhwnd = 0; | 
|---|
| 2273 |  | 
|---|
| 2274 | newparent = GetWindowFromHandle(hwndNewParent); | 
|---|
| 2275 | if(newparent) | 
|---|
| 2276 | { | 
|---|
| 2277 | setParent(newparent); | 
|---|
| 2278 | getParent()->AddChild(this); | 
|---|
| 2279 | OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle()); | 
|---|
| 2280 | return oldhwnd; | 
|---|
| 2281 | } | 
|---|
| 2282 | else { | 
|---|
| 2283 | setParent(windowDesktop); | 
|---|
| 2284 | windowDesktop->AddChild(this); | 
|---|
| 2285 | OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP); | 
|---|
| 2286 | return oldhwnd; | 
|---|
| 2287 | } | 
|---|
| 2288 | } | 
|---|
| 2289 | //****************************************************************************** | 
|---|
| 2290 | //****************************************************************************** | 
|---|
| 2291 | BOOL Win32BaseWindow::IsChild(HWND hwndParent) | 
|---|
| 2292 | { | 
|---|
| 2293 | if(getParent()) { | 
|---|
| 2294 | return getParent()->getWindowHandle() == hwndParent; | 
|---|
| 2295 | } | 
|---|
| 2296 | else  return 0; | 
|---|
| 2297 | } | 
|---|
| 2298 | //****************************************************************************** | 
|---|
| 2299 | //****************************************************************************** | 
|---|
| 2300 | HWND Win32BaseWindow::GetTopWindow() | 
|---|
| 2301 | { | 
|---|
| 2302 | return GetWindow(GW_CHILD); | 
|---|
| 2303 | } | 
|---|
| 2304 | //****************************************************************************** | 
|---|
| 2305 | // Get the top-level parent for a child window. | 
|---|
| 2306 | //****************************************************************************** | 
|---|
| 2307 | Win32BaseWindow *Win32BaseWindow::GetTopParent() | 
|---|
| 2308 | { | 
|---|
| 2309 | Win32BaseWindow *window = this; | 
|---|
| 2310 |  | 
|---|
| 2311 | while(window && (window->getStyle() & WS_CHILD)) | 
|---|
| 2312 | { | 
|---|
| 2313 | window = window->getParent(); | 
|---|
| 2314 | } | 
|---|
| 2315 | return window; | 
|---|
| 2316 | } | 
|---|
| 2317 | //****************************************************************************** | 
|---|
| 2318 | //TODO: Should not enumerate children that are created during the enumeration! | 
|---|
| 2319 | //****************************************************************************** | 
|---|
| 2320 | BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam) | 
|---|
| 2321 | { | 
|---|
| 2322 | BOOL rc = TRUE; | 
|---|
| 2323 | HWND hwnd; | 
|---|
| 2324 | Win32BaseWindow *prevchild = 0, *child = 0; | 
|---|
| 2325 |  | 
|---|
| 2326 | dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild())); | 
|---|
| 2327 | for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild()) | 
|---|
| 2328 | { | 
|---|
| 2329 | dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle())); | 
|---|
| 2330 | hwnd = child->getWindowHandle(); | 
|---|
| 2331 | if(child->getOwner()) { | 
|---|
| 2332 | continue; //shouldn't have an owner (Wine) | 
|---|
| 2333 | } | 
|---|
| 2334 | if(lpfn(hwnd, lParam) == FALSE) | 
|---|
| 2335 | { | 
|---|
| 2336 | rc = FALSE; | 
|---|
| 2337 | break; | 
|---|
| 2338 | } | 
|---|
| 2339 | //check if the window still exists | 
|---|
| 2340 | if(!::IsWindow(hwnd)) | 
|---|
| 2341 | { | 
|---|
| 2342 | child = prevchild; | 
|---|
| 2343 | continue; | 
|---|
| 2344 | } | 
|---|
| 2345 | if(child->getFirstChild() != NULL) | 
|---|
| 2346 | { | 
|---|
| 2347 | dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle())); | 
|---|
| 2348 | if(child->EnumChildWindows(lpfn, lParam) == FALSE) | 
|---|
| 2349 | { | 
|---|
| 2350 | rc = FALSE; | 
|---|
| 2351 | break; | 
|---|
| 2352 | } | 
|---|
| 2353 | } | 
|---|
| 2354 | prevchild = child; | 
|---|
| 2355 | } | 
|---|
| 2356 | return rc; | 
|---|
| 2357 | } | 
|---|
| 2358 | //****************************************************************************** | 
|---|
| 2359 | //Enumerate first-level children only and check thread id | 
|---|
| 2360 | //****************************************************************************** | 
|---|
| 2361 | BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam) | 
|---|
| 2362 | { | 
|---|
| 2363 | Win32BaseWindow *child = 0; | 
|---|
| 2364 | ULONG  tid, pid; | 
|---|
| 2365 | BOOL   rc; | 
|---|
| 2366 | HWND   hwnd; | 
|---|
| 2367 |  | 
|---|
| 2368 | dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam)); | 
|---|
| 2369 |  | 
|---|
| 2370 | for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild()) | 
|---|
| 2371 | { | 
|---|
| 2372 | OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid); | 
|---|
| 2373 |  | 
|---|
| 2374 | if(dwThreadId == tid) { | 
|---|
| 2375 | dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle())); | 
|---|
| 2376 | if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) { | 
|---|
| 2377 | break; | 
|---|
| 2378 | } | 
|---|
| 2379 | } | 
|---|
| 2380 | } | 
|---|
| 2381 | return TRUE; | 
|---|
| 2382 | } | 
|---|
| 2383 | //****************************************************************************** | 
|---|
| 2384 | //Enumerate first-level children only | 
|---|
| 2385 | //****************************************************************************** | 
|---|
| 2386 | BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam) | 
|---|
| 2387 | { | 
|---|
| 2388 | Win32BaseWindow *child = 0; | 
|---|
| 2389 | BOOL   rc; | 
|---|
| 2390 | HWND   hwnd; | 
|---|
| 2391 |  | 
|---|
| 2392 | dprintf(("EnumWindows %x %x", lpfn, lParam)); | 
|---|
| 2393 |  | 
|---|
| 2394 | for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild()) | 
|---|
| 2395 | { | 
|---|
| 2396 | hwnd = child->getWindowHandle(); | 
|---|
| 2397 |  | 
|---|
| 2398 | dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle())); | 
|---|
| 2399 | if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) { | 
|---|
| 2400 | break; | 
|---|
| 2401 | } | 
|---|
| 2402 | } | 
|---|
| 2403 | return TRUE; | 
|---|
| 2404 | } | 
|---|
| 2405 | //****************************************************************************** | 
|---|
| 2406 | //****************************************************************************** | 
|---|
| 2407 | Win32BaseWindow *Win32BaseWindow::FindWindowById(int id) | 
|---|
| 2408 | { | 
|---|
| 2409 | for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild()) | 
|---|
| 2410 | { | 
|---|
| 2411 | if (child->getWindowId() == id) | 
|---|
| 2412 | { | 
|---|
| 2413 | return child; | 
|---|
| 2414 | } | 
|---|
| 2415 | } | 
|---|
| 2416 | return 0; | 
|---|
| 2417 | } | 
|---|
| 2418 | //****************************************************************************** | 
|---|
| 2419 | //TODO: | 
|---|
| 2420 | //We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that | 
|---|
| 2421 | //the current process owns them. | 
|---|
| 2422 | //****************************************************************************** | 
|---|
| 2423 | HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow) | 
|---|
| 2424 | { | 
|---|
| 2425 | Win32BaseWindow *parent = GetWindowFromHandle(hwndParent); | 
|---|
| 2426 | Win32BaseWindow *child  = GetWindowFromHandle(hwndChildAfter); | 
|---|
| 2427 |  | 
|---|
| 2428 | dprintf(("FindWindowEx %x %x %x %s", hwndParent, hwndChildAfter, atom, lpszWindow)); | 
|---|
| 2429 | if((hwndParent != 0 && !parent) || | 
|---|
| 2430 | (hwndChildAfter != 0 && !child) || | 
|---|
| 2431 | (hwndParent == 0 && hwndChildAfter != 0)) | 
|---|
| 2432 | { | 
|---|
| 2433 | dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter)); | 
|---|
| 2434 | SetLastError(ERROR_INVALID_WINDOW_HANDLE); | 
|---|
| 2435 | return 0; | 
|---|
| 2436 | } | 
|---|
| 2437 | SetLastError(0); | 
|---|
| 2438 | if(hwndParent != 0) | 
|---|
| 2439 | {//if the current process owns the window, just do a quick search | 
|---|
| 2440 | child = (Win32BaseWindow *)parent->getFirstChild(); | 
|---|
| 2441 | if(hwndChildAfter != 0) | 
|---|
| 2442 | { | 
|---|
| 2443 | while(child) | 
|---|
| 2444 | { | 
|---|
| 2445 | if(child->getWindowHandle() == hwndChildAfter) | 
|---|
| 2446 | { | 
|---|
| 2447 | child = (Win32BaseWindow *)child->getNextChild(); | 
|---|
| 2448 | break; | 
|---|
| 2449 | } | 
|---|
| 2450 | child = (Win32BaseWindow *)child->getNextChild(); | 
|---|
| 2451 | } | 
|---|
| 2452 | } | 
|---|
| 2453 | while(child) | 
|---|
| 2454 | { | 
|---|
| 2455 | //According to Wine, the class doesn't need to be specified | 
|---|
| 2456 | if((!atom || child->getWindowClass()->getAtom() == atom) && | 
|---|
| 2457 | (!lpszWindow || child->hasWindowName(lpszWindow))) | 
|---|
| 2458 | { | 
|---|
| 2459 | dprintf(("FindWindowEx: Found window %x", child->getWindowHandle())); | 
|---|
| 2460 | return child->getWindowHandle(); | 
|---|
| 2461 | } | 
|---|
| 2462 | child = (Win32BaseWindow *)child->getNextChild(); | 
|---|
| 2463 | } | 
|---|
| 2464 | } | 
|---|
| 2465 | else { | 
|---|
| 2466 | Win32BaseWindow *wnd; | 
|---|
| 2467 | HWND henum, hwnd; | 
|---|
| 2468 |  | 
|---|
| 2469 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP); | 
|---|
| 2470 | hwnd = OSLibWinGetNextWindow(henum); | 
|---|
| 2471 |  | 
|---|
| 2472 | while(hwnd) | 
|---|
| 2473 | { | 
|---|
| 2474 | wnd = GetWindowFromOS2Handle(hwnd); | 
|---|
| 2475 | if(wnd == NULL) { | 
|---|
| 2476 | hwnd = OSLibWinQueryClientWindow(hwnd); | 
|---|
| 2477 | if(hwnd)  wnd = GetWindowFromOS2Handle(hwnd); | 
|---|
| 2478 | if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd); | 
|---|
| 2479 | } | 
|---|
| 2480 |  | 
|---|
| 2481 | if(wnd) { | 
|---|
| 2482 | //According to Wine, the class doesn't need to be specified | 
|---|
| 2483 | if((!atom || wnd->getWindowClass()->getAtom() == atom) && | 
|---|
| 2484 | (!lpszWindow || wnd->hasWindowName(lpszWindow))) | 
|---|
| 2485 | { | 
|---|
| 2486 | OSLibWinEndEnumWindows(henum); | 
|---|
| 2487 | dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle())); | 
|---|
| 2488 | return wnd->getWindowHandle(); | 
|---|
| 2489 | } | 
|---|
| 2490 | } | 
|---|
| 2491 | hwnd = OSLibWinGetNextWindow(henum); | 
|---|
| 2492 | } | 
|---|
| 2493 | OSLibWinEndEnumWindows(henum); | 
|---|
| 2494 | } | 
|---|
| 2495 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct | 
|---|
| 2496 | return 0; | 
|---|
| 2497 | } | 
|---|
| 2498 | //****************************************************************************** | 
|---|
| 2499 | //****************************************************************************** | 
|---|
| 2500 | HWND Win32BaseWindow::GetWindow(UINT uCmd) | 
|---|
| 2501 | { | 
|---|
| 2502 | HWND hwndRelated = 0; | 
|---|
| 2503 | Win32BaseWindow *window; | 
|---|
| 2504 |  | 
|---|
| 2505 | switch(uCmd) | 
|---|
| 2506 | { | 
|---|
| 2507 | case GW_HWNDFIRST: | 
|---|
| 2508 | if(getParent()) { | 
|---|
| 2509 | window = (Win32BaseWindow *)getParent()->getFirstChild(); | 
|---|
| 2510 | hwndRelated = window->getWindowHandle(); | 
|---|
| 2511 | } | 
|---|
| 2512 | break; | 
|---|
| 2513 |  | 
|---|
| 2514 | case GW_HWNDLAST: | 
|---|
| 2515 | if(!getParent()) | 
|---|
| 2516 | { | 
|---|
| 2517 | goto end; | 
|---|
| 2518 | } | 
|---|
| 2519 |  | 
|---|
| 2520 | window = this; | 
|---|
| 2521 | while(window->getNextChild()) | 
|---|
| 2522 | { | 
|---|
| 2523 | window = (Win32BaseWindow *)window->getNextChild(); | 
|---|
| 2524 | } | 
|---|
| 2525 | hwndRelated = window->getWindowHandle(); | 
|---|
| 2526 | break; | 
|---|
| 2527 |  | 
|---|
| 2528 | case GW_HWNDNEXT: | 
|---|
| 2529 | window = (Win32BaseWindow *)getNextChild(); | 
|---|
| 2530 | if(window) { | 
|---|
| 2531 | hwndRelated = window->getWindowHandle(); | 
|---|
| 2532 | } | 
|---|
| 2533 | break; | 
|---|
| 2534 |  | 
|---|
| 2535 | case GW_HWNDPREV: | 
|---|
| 2536 | if(!getParent()) | 
|---|
| 2537 | { | 
|---|
| 2538 | goto end; | 
|---|
| 2539 | } | 
|---|
| 2540 | window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */ | 
|---|
| 2541 | if(window == this) | 
|---|
| 2542 | { | 
|---|
| 2543 | hwndRelated = 0;  /* First in list */ | 
|---|
| 2544 | goto end; | 
|---|
| 2545 | } | 
|---|
| 2546 | while(window->getNextChild()) | 
|---|
| 2547 | { | 
|---|
| 2548 | if (window->getNextChild() == this) | 
|---|
| 2549 | { | 
|---|
| 2550 | hwndRelated = window->getWindowHandle(); | 
|---|
| 2551 | goto end; | 
|---|
| 2552 | } | 
|---|
| 2553 | window = (Win32BaseWindow *)window->getNextChild(); | 
|---|
| 2554 | } | 
|---|
| 2555 | break; | 
|---|
| 2556 |  | 
|---|
| 2557 | case GW_OWNER: | 
|---|
| 2558 | if(getOwner()) { | 
|---|
| 2559 | hwndRelated = getOwner()->getWindowHandle(); | 
|---|
| 2560 | } | 
|---|
| 2561 | break; | 
|---|
| 2562 |  | 
|---|
| 2563 | case GW_CHILD: | 
|---|
| 2564 | if(getFirstChild()) { | 
|---|
| 2565 | hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle(); | 
|---|
| 2566 | } | 
|---|
| 2567 | break; | 
|---|
| 2568 | } | 
|---|
| 2569 | end: | 
|---|
| 2570 | dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated)); | 
|---|
| 2571 | return hwndRelated; | 
|---|
| 2572 | } | 
|---|
| 2573 | //****************************************************************************** | 
|---|
| 2574 | //****************************************************************************** | 
|---|
| 2575 | HWND Win32BaseWindow::SetActiveWindow() | 
|---|
| 2576 | { | 
|---|
| 2577 | HWND hwndActive; | 
|---|
| 2578 |  | 
|---|
| 2579 | dprintf(("SetActiveWindow %x", getWindowHandle())); | 
|---|
| 2580 | if(OSLibWinSetActiveWindow(OS2HwndFrame) == FALSE) { | 
|---|
| 2581 | dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2HwndFrame)); | 
|---|
| 2582 | } | 
|---|
| 2583 | hwndActive = GetActiveWindow(); | 
|---|
| 2584 | return (hwndActive) ? hwndActive : windowDesktop->getWindowHandle(); //pretend the desktop was active | 
|---|
| 2585 | } | 
|---|
| 2586 | //****************************************************************************** | 
|---|
| 2587 | //WM_ENABLE is sent to hwnd, but not to it's children (as it should be) | 
|---|
| 2588 | //****************************************************************************** | 
|---|
| 2589 | BOOL Win32BaseWindow::EnableWindow(BOOL fEnable) | 
|---|
| 2590 | { | 
|---|
| 2591 | return OSLibWinEnableWindow(OS2HwndFrame, fEnable); | 
|---|
| 2592 | } | 
|---|
| 2593 | //****************************************************************************** | 
|---|
| 2594 | //****************************************************************************** | 
|---|
| 2595 | BOOL Win32BaseWindow::CloseWindow() | 
|---|
| 2596 | { | 
|---|
| 2597 | return OSLibWinMinimizeWindow(OS2HwndFrame); | 
|---|
| 2598 | } | 
|---|
| 2599 | //****************************************************************************** | 
|---|
| 2600 | //****************************************************************************** | 
|---|
| 2601 | HWND Win32BaseWindow::GetActiveWindow() | 
|---|
| 2602 | { | 
|---|
| 2603 | HWND          hwndActive; | 
|---|
| 2604 | Win32BaseWindow  *win32wnd; | 
|---|
| 2605 | ULONG         magic; | 
|---|
| 2606 |  | 
|---|
| 2607 | hwndActive = OSLibWinQueryActiveWindow(); | 
|---|
| 2608 |  | 
|---|
| 2609 | return OS2ToWin32Handle(hwndActive); | 
|---|
| 2610 | } | 
|---|
| 2611 | //****************************************************************************** | 
|---|
| 2612 | //****************************************************************************** | 
|---|
| 2613 | BOOL Win32BaseWindow::IsWindowEnabled() | 
|---|
| 2614 | { | 
|---|
| 2615 | return OSLibWinIsWindowEnabled(OS2HwndFrame); | 
|---|
| 2616 | } | 
|---|
| 2617 | //****************************************************************************** | 
|---|
| 2618 | //****************************************************************************** | 
|---|
| 2619 | BOOL Win32BaseWindow::IsWindowVisible() | 
|---|
| 2620 | { | 
|---|
| 2621 | #if 1 | 
|---|
| 2622 | return (dwStyle & WS_VISIBLE) == WS_VISIBLE; | 
|---|
| 2623 | #else | 
|---|
| 2624 | return OSLibWinIsWindowVisible(OS2HwndFrame); | 
|---|
| 2625 | #endif | 
|---|
| 2626 | } | 
|---|
| 2627 | //****************************************************************************** | 
|---|
| 2628 | //****************************************************************************** | 
|---|
| 2629 | BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode) | 
|---|
| 2630 | { | 
|---|
| 2631 | INT len = GetWindowTextLength(); | 
|---|
| 2632 | BOOL res; | 
|---|
| 2633 |  | 
|---|
| 2634 | if (wndname == NULL) | 
|---|
| 2635 | return (len == 0); | 
|---|
| 2636 |  | 
|---|
| 2637 | len++; | 
|---|
| 2638 | if (fUnicode) | 
|---|
| 2639 | { | 
|---|
| 2640 | WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR)); | 
|---|
| 2641 |  | 
|---|
| 2642 | GetWindowTextW(text,len); | 
|---|
| 2643 | res = (lstrcmpW(text,(LPWSTR)wndname) == 0); | 
|---|
| 2644 | free(text); | 
|---|
| 2645 | } else | 
|---|
| 2646 | { | 
|---|
| 2647 | CHAR *text = (CHAR*)malloc(len*sizeof(CHAR)); | 
|---|
| 2648 |  | 
|---|
| 2649 | GetWindowTextA(text,len); | 
|---|
| 2650 | res = (strcmp(text,wndname) == 0); | 
|---|
| 2651 | free(text); | 
|---|
| 2652 | } | 
|---|
| 2653 |  | 
|---|
| 2654 | return res; | 
|---|
| 2655 | } | 
|---|
| 2656 | //****************************************************************************** | 
|---|
| 2657 | //****************************************************************************** | 
|---|
| 2658 | CHAR *Win32BaseWindow::getWindowNamePtrA() | 
|---|
| 2659 | { | 
|---|
| 2660 | INT len = GetWindowTextLength(); | 
|---|
| 2661 | CHAR *text; | 
|---|
| 2662 |  | 
|---|
| 2663 | if (len == 0) return NULL; | 
|---|
| 2664 | len++; | 
|---|
| 2665 | text = (CHAR*)malloc(len*sizeof(CHAR)); | 
|---|
| 2666 | GetWindowTextA(text,len); | 
|---|
| 2667 |  | 
|---|
| 2668 | return text; | 
|---|
| 2669 | } | 
|---|
| 2670 | //****************************************************************************** | 
|---|
| 2671 | //****************************************************************************** | 
|---|
| 2672 | WCHAR *Win32BaseWindow::getWindowNamePtrW() | 
|---|
| 2673 | { | 
|---|
| 2674 | INT len = GetWindowTextLength(); | 
|---|
| 2675 | WCHAR *text; | 
|---|
| 2676 |  | 
|---|
| 2677 | if (len == 0) return NULL; | 
|---|
| 2678 | len++; | 
|---|
| 2679 | text = (WCHAR*)malloc(len*sizeof(WCHAR)); | 
|---|
| 2680 | GetWindowTextW(text,len); | 
|---|
| 2681 |  | 
|---|
| 2682 | return text; | 
|---|
| 2683 | } | 
|---|
| 2684 | //****************************************************************************** | 
|---|
| 2685 | //****************************************************************************** | 
|---|
| 2686 | VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr) | 
|---|
| 2687 | { | 
|---|
| 2688 | if (namePtr) free(namePtr); | 
|---|
| 2689 | } | 
|---|
| 2690 | //****************************************************************************** | 
|---|
| 2691 | //****************************************************************************** | 
|---|
| 2692 | int Win32BaseWindow::GetWindowTextLength() | 
|---|
| 2693 | { | 
|---|
| 2694 | return SendInternalMessageA(WM_GETTEXTLENGTH,0,0); | 
|---|
| 2695 | } | 
|---|
| 2696 | //****************************************************************************** | 
|---|
| 2697 | //****************************************************************************** | 
|---|
| 2698 | int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch) | 
|---|
| 2699 | { | 
|---|
| 2700 | return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz); | 
|---|
| 2701 | } | 
|---|
| 2702 | //****************************************************************************** | 
|---|
| 2703 | //****************************************************************************** | 
|---|
| 2704 | int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch) | 
|---|
| 2705 | { | 
|---|
| 2706 | return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz); | 
|---|
| 2707 | } | 
|---|
| 2708 | //****************************************************************************** | 
|---|
| 2709 | //****************************************************************************** | 
|---|
| 2710 | BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz) | 
|---|
| 2711 | { | 
|---|
| 2712 | return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz); | 
|---|
| 2713 | } | 
|---|
| 2714 | //****************************************************************************** | 
|---|
| 2715 | //****************************************************************************** | 
|---|
| 2716 | BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz) | 
|---|
| 2717 | { | 
|---|
| 2718 | return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz); | 
|---|
| 2719 | } | 
|---|
| 2720 | //****************************************************************************** | 
|---|
| 2721 | //****************************************************************************** | 
|---|
| 2722 | LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode) | 
|---|
| 2723 | { | 
|---|
| 2724 | LONG oldval; | 
|---|
| 2725 |  | 
|---|
| 2726 | dprintf2(("SetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value)); | 
|---|
| 2727 | switch(index) { | 
|---|
| 2728 | case GWL_EXSTYLE: | 
|---|
| 2729 | { | 
|---|
| 2730 | STYLESTRUCT ss; | 
|---|
| 2731 |  | 
|---|
| 2732 | if(dwExStyle == value) | 
|---|
| 2733 | return value; | 
|---|
| 2734 |  | 
|---|
| 2735 | ss.styleOld = dwExStyle; | 
|---|
| 2736 | ss.styleNew = value; | 
|---|
| 2737 | dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value)); | 
|---|
| 2738 | SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss); | 
|---|
| 2739 | setExStyle(ss.styleNew); | 
|---|
| 2740 | SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss); | 
|---|
| 2741 | return ss.styleOld; | 
|---|
| 2742 | } | 
|---|
| 2743 | case GWL_STYLE: | 
|---|
| 2744 | { | 
|---|
| 2745 | STYLESTRUCT ss; | 
|---|
| 2746 |  | 
|---|
| 2747 | //SvL: TODO: Can you change minimize or maximize status here too? | 
|---|
| 2748 |  | 
|---|
| 2749 | if(dwStyle == value) | 
|---|
| 2750 | return value; | 
|---|
| 2751 |  | 
|---|
| 2752 | value &= ~(WS_CHILD|WS_VISIBLE);      /* Some bits can't be changed this way (WINE) */ | 
|---|
| 2753 | ss.styleOld = getStyle(); | 
|---|
| 2754 | ss.styleNew = value | (ss.styleOld & (WS_CHILD|WS_VISIBLE)); | 
|---|
| 2755 | dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew)); | 
|---|
| 2756 | SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss); | 
|---|
| 2757 | setStyle(ss.styleNew); | 
|---|
| 2758 | SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss); | 
|---|
| 2759 | ////                OSLibSetWindowStyle(getOS2FrameWindowHandle(), getStyle(), getExStyle(), | 
|---|
| 2760 | ////                                    windowClass->getStyle() & CS_SAVEBITS); | 
|---|
| 2761 | #ifdef DEBUG | 
|---|
| 2762 | PrintWindowStyle(ss.styleNew, 0); | 
|---|
| 2763 | #endif | 
|---|
| 2764 | return ss.styleOld; | 
|---|
| 2765 | } | 
|---|
| 2766 | case GWL_WNDPROC: | 
|---|
| 2767 | oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A); | 
|---|
| 2768 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW); | 
|---|
| 2769 | return oldval; | 
|---|
| 2770 |  | 
|---|
| 2771 | case GWL_HINSTANCE: | 
|---|
| 2772 | oldval = hInstance; | 
|---|
| 2773 | hInstance = value; | 
|---|
| 2774 | return oldval; | 
|---|
| 2775 |  | 
|---|
| 2776 | case GWL_HWNDPARENT: | 
|---|
| 2777 | return SetParent((HWND)value); | 
|---|
| 2778 |  | 
|---|
| 2779 | case GWL_ID: | 
|---|
| 2780 | oldval = getWindowId(); | 
|---|
| 2781 | setWindowId(value); | 
|---|
| 2782 | return oldval; | 
|---|
| 2783 |  | 
|---|
| 2784 | case GWL_USERDATA: | 
|---|
| 2785 | oldval = userData; | 
|---|
| 2786 | userData = value; | 
|---|
| 2787 | return oldval; | 
|---|
| 2788 |  | 
|---|
| 2789 | default: | 
|---|
| 2790 | if(index >= 0 && index/4 < nrUserWindowLong) | 
|---|
| 2791 | { | 
|---|
| 2792 | oldval = userWindowLong[index/4]; | 
|---|
| 2793 | userWindowLong[index/4] = value; | 
|---|
| 2794 | return oldval; | 
|---|
| 2795 | } | 
|---|
| 2796 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 2797 | return 0; | 
|---|
| 2798 | } | 
|---|
| 2799 | } | 
|---|
| 2800 | //****************************************************************************** | 
|---|
| 2801 | //****************************************************************************** | 
|---|
| 2802 | ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode) | 
|---|
| 2803 | { | 
|---|
| 2804 | ULONG value; | 
|---|
| 2805 |  | 
|---|
| 2806 | switch(index) { | 
|---|
| 2807 | case GWL_EXSTYLE: | 
|---|
| 2808 | value = dwExStyle; | 
|---|
| 2809 | break; | 
|---|
| 2810 | case GWL_STYLE: | 
|---|
| 2811 | value = dwStyle; | 
|---|
| 2812 | break; | 
|---|
| 2813 | case GWL_WNDPROC: | 
|---|
| 2814 | value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A); | 
|---|
| 2815 | break; | 
|---|
| 2816 | case GWL_HINSTANCE: | 
|---|
| 2817 | value = hInstance; | 
|---|
| 2818 | break; | 
|---|
| 2819 | case GWL_HWNDPARENT: | 
|---|
| 2820 | if(getParent()) { | 
|---|
| 2821 | value = getParent()->getWindowHandle(); | 
|---|
| 2822 | } | 
|---|
| 2823 | else value = 0; | 
|---|
| 2824 | break; | 
|---|
| 2825 | case GWL_ID: | 
|---|
| 2826 | value = getWindowId(); | 
|---|
| 2827 | break; | 
|---|
| 2828 | case GWL_USERDATA: | 
|---|
| 2829 | value = userData; | 
|---|
| 2830 | break; | 
|---|
| 2831 | default: | 
|---|
| 2832 | if(index >= 0 && index/4 < nrUserWindowLong) | 
|---|
| 2833 | { | 
|---|
| 2834 | value = userWindowLong[index/4]; | 
|---|
| 2835 | break; | 
|---|
| 2836 | } | 
|---|
| 2837 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 2838 | return 0; | 
|---|
| 2839 | } | 
|---|
| 2840 | dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value)); | 
|---|
| 2841 | return value; | 
|---|
| 2842 | } | 
|---|
| 2843 | //****************************************************************************** | 
|---|
| 2844 | //****************************************************************************** | 
|---|
| 2845 | WORD Win32BaseWindow::SetWindowWord(int index, WORD value) | 
|---|
| 2846 | { | 
|---|
| 2847 | WORD oldval; | 
|---|
| 2848 |  | 
|---|
| 2849 | if(index >= 0 && index/4 < nrUserWindowLong) | 
|---|
| 2850 | { | 
|---|
| 2851 | oldval = ((WORD *)userWindowLong)[index/2]; | 
|---|
| 2852 | ((WORD *)userWindowLong)[index/2] = value; | 
|---|
| 2853 | return oldval; | 
|---|
| 2854 | } | 
|---|
| 2855 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 2856 | return 0; | 
|---|
| 2857 | } | 
|---|
| 2858 | //****************************************************************************** | 
|---|
| 2859 | //****************************************************************************** | 
|---|
| 2860 | WORD Win32BaseWindow::GetWindowWord(int index) | 
|---|
| 2861 | { | 
|---|
| 2862 | if(index >= 0 && index/4 < nrUserWindowLong) | 
|---|
| 2863 | { | 
|---|
| 2864 | return ((WORD *)userWindowLong)[index/2]; | 
|---|
| 2865 | } | 
|---|
| 2866 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 2867 | return 0; | 
|---|
| 2868 | } | 
|---|
| 2869 | //****************************************************************************** | 
|---|
| 2870 | //****************************************************************************** | 
|---|
| 2871 | void Win32BaseWindow::setWindowId(DWORD id) | 
|---|
| 2872 | { | 
|---|
| 2873 | dwIDMenu = id; | 
|---|
| 2874 | } | 
|---|
| 2875 | //****************************************************************************** | 
|---|
| 2876 | //****************************************************************************** | 
|---|
| 2877 | Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd) | 
|---|
| 2878 | { | 
|---|
| 2879 | Win32BaseWindow *window; | 
|---|
| 2880 |  | 
|---|
| 2881 | if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) { | 
|---|
| 2882 | return window; | 
|---|
| 2883 | } | 
|---|
| 2884 | //    dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd)); | 
|---|
| 2885 | return NULL; | 
|---|
| 2886 | } | 
|---|
| 2887 | //****************************************************************************** | 
|---|
| 2888 | //****************************************************************************** | 
|---|
| 2889 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd) | 
|---|
| 2890 | { | 
|---|
| 2891 | Win32BaseWindow *win32wnd; | 
|---|
| 2892 | DWORD        magic; | 
|---|
| 2893 |  | 
|---|
| 2894 | if(hwnd == OSLIB_HWND_DESKTOP) | 
|---|
| 2895 | { | 
|---|
| 2896 | return windowDesktop; | 
|---|
| 2897 | } | 
|---|
| 2898 |  | 
|---|
| 2899 | win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR); | 
|---|
| 2900 | magic    = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC); | 
|---|
| 2901 |  | 
|---|
| 2902 | if(win32wnd && CheckMagicDword(magic)) { | 
|---|
| 2903 | return win32wnd; | 
|---|
| 2904 | } | 
|---|
| 2905 | //  dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd)); | 
|---|
| 2906 | return 0; | 
|---|
| 2907 | } | 
|---|
| 2908 | //****************************************************************************** | 
|---|
| 2909 | //****************************************************************************** | 
|---|
| 2910 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd) | 
|---|
| 2911 | { | 
|---|
| 2912 | return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT)); | 
|---|
| 2913 | } | 
|---|
| 2914 | //****************************************************************************** | 
|---|
| 2915 | //****************************************************************************** | 
|---|
| 2916 | HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd) | 
|---|
| 2917 | { | 
|---|
| 2918 | Win32BaseWindow *window = GetWindowFromHandle(hwnd); | 
|---|
| 2919 |  | 
|---|
| 2920 | if(window) { | 
|---|
| 2921 | return window->getOS2WindowHandle(); | 
|---|
| 2922 | } | 
|---|
| 2923 | //    dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd)); | 
|---|
| 2924 | return hwnd; | 
|---|
| 2925 | } | 
|---|
| 2926 | //****************************************************************************** | 
|---|
| 2927 | //****************************************************************************** | 
|---|
| 2928 | HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd) | 
|---|
| 2929 | { | 
|---|
| 2930 | Win32BaseWindow *window = GetWindowFromHandle(hwnd); | 
|---|
| 2931 |  | 
|---|
| 2932 | if(window) { | 
|---|
| 2933 | return window->getOS2FrameWindowHandle(); | 
|---|
| 2934 | } | 
|---|
| 2935 | //    dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd)); | 
|---|
| 2936 | return hwnd; | 
|---|
| 2937 | } | 
|---|
| 2938 | //****************************************************************************** | 
|---|
| 2939 | //****************************************************************************** | 
|---|
| 2940 | HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd) | 
|---|
| 2941 | { | 
|---|
| 2942 | Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd); | 
|---|
| 2943 |  | 
|---|
| 2944 | if(window) { | 
|---|
| 2945 | return window->getWindowHandle(); | 
|---|
| 2946 | } | 
|---|
| 2947 | window = GetWindowFromOS2FrameHandle(hwnd); | 
|---|
| 2948 | if(window) { | 
|---|
| 2949 | return window->getWindowHandle(); | 
|---|
| 2950 | } | 
|---|
| 2951 | //    dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd)); | 
|---|
| 2952 | return 0; | 
|---|
| 2953 | //    else    return hwnd;    //OS/2 window handle | 
|---|
| 2954 | } | 
|---|
| 2955 | //****************************************************************************** | 
|---|
| 2956 | // GetNextDlgTabItem32   (USER32.276) | 
|---|
| 2957 | //****************************************************************************** | 
|---|
| 2958 | HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious) | 
|---|
| 2959 | { | 
|---|
| 2960 | Win32BaseWindow *child, *nextchild, *lastchild; | 
|---|
| 2961 | HWND retvalue; | 
|---|
| 2962 |  | 
|---|
| 2963 | if (hwndCtrl) | 
|---|
| 2964 | { | 
|---|
| 2965 | child = GetWindowFromHandle(hwndCtrl); | 
|---|
| 2966 | if (!child) | 
|---|
| 2967 | { | 
|---|
| 2968 | retvalue = 0; | 
|---|
| 2969 | goto END; | 
|---|
| 2970 | } | 
|---|
| 2971 | /* Make sure hwndCtrl is a top-level child */ | 
|---|
| 2972 | while ((child->getStyle() & WS_CHILD) && (child->getParent() != this)) | 
|---|
| 2973 | { | 
|---|
| 2974 | child = child->getParent(); | 
|---|
| 2975 | if(child == NULL) break; | 
|---|
| 2976 | } | 
|---|
| 2977 |  | 
|---|
| 2978 | if (!child || (child->getParent() != this)) | 
|---|
| 2979 | { | 
|---|
| 2980 | retvalue = 0; | 
|---|
| 2981 | goto END; | 
|---|
| 2982 | } | 
|---|
| 2983 | } | 
|---|
| 2984 | else | 
|---|
| 2985 | { | 
|---|
| 2986 | /* No ctrl specified -> start from the beginning */ | 
|---|
| 2987 | child = (Win32BaseWindow *)getFirstChild(); | 
|---|
| 2988 | if (!child) | 
|---|
| 2989 | { | 
|---|
| 2990 | retvalue = 0; | 
|---|
| 2991 | goto END; | 
|---|
| 2992 | } | 
|---|
| 2993 |  | 
|---|
| 2994 | if (!fPrevious) | 
|---|
| 2995 | { | 
|---|
| 2996 | while (child->getNextChild()) | 
|---|
| 2997 | { | 
|---|
| 2998 | child = (Win32BaseWindow *)child->getNextChild(); | 
|---|
| 2999 | } | 
|---|
| 3000 | } | 
|---|
| 3001 | } | 
|---|
| 3002 |  | 
|---|
| 3003 | lastchild = child; | 
|---|
| 3004 | nextchild = (Win32BaseWindow *)child->getNextChild(); | 
|---|
| 3005 | while (TRUE) | 
|---|
| 3006 | { | 
|---|
| 3007 | if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild(); | 
|---|
| 3008 |  | 
|---|
| 3009 | if (child == nextchild) break; | 
|---|
| 3010 |  | 
|---|
| 3011 | if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) && | 
|---|
| 3012 | !(nextchild->getStyle() & WS_DISABLED)) | 
|---|
| 3013 | { | 
|---|
| 3014 | lastchild = nextchild; | 
|---|
| 3015 | if (!fPrevious) break; | 
|---|
| 3016 | } | 
|---|
| 3017 | nextchild = (Win32BaseWindow *)nextchild->getNextChild(); | 
|---|
| 3018 | } | 
|---|
| 3019 | retvalue = lastchild->getWindowHandle(); | 
|---|
| 3020 |  | 
|---|
| 3021 | END: | 
|---|
| 3022 | return retvalue; | 
|---|
| 3023 | } | 
|---|
| 3024 | //****************************************************************************** | 
|---|
| 3025 | //****************************************************************************** | 
|---|
| 3026 | HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious) | 
|---|
| 3027 | { | 
|---|
| 3028 | Win32BaseWindow *child, *nextchild, *lastchild; | 
|---|
| 3029 | HWND retvalue; | 
|---|
| 3030 |  | 
|---|
| 3031 | if (hwndCtrl) | 
|---|
| 3032 | { | 
|---|
| 3033 | child = GetWindowFromHandle(hwndCtrl); | 
|---|
| 3034 | if (!child) | 
|---|
| 3035 | { | 
|---|
| 3036 | retvalue = 0; | 
|---|
| 3037 | goto END; | 
|---|
| 3038 | } | 
|---|
| 3039 | /* Make sure hwndCtrl is a top-level child */ | 
|---|
| 3040 | while ((child->getStyle() & WS_CHILD) && (child->getParent() != this)) | 
|---|
| 3041 | { | 
|---|
| 3042 | child = child->getParent(); | 
|---|
| 3043 | if(child == NULL) break; | 
|---|
| 3044 | } | 
|---|
| 3045 |  | 
|---|
| 3046 | if (!child || (child->getParent() != this)) | 
|---|
| 3047 | { | 
|---|
| 3048 | retvalue = 0; | 
|---|
| 3049 | goto END; | 
|---|
| 3050 | } | 
|---|
| 3051 | } | 
|---|
| 3052 | else | 
|---|
| 3053 | { | 
|---|
| 3054 | /* No ctrl specified -> start from the beginning */ | 
|---|
| 3055 | child = (Win32BaseWindow *)getFirstChild(); | 
|---|
| 3056 | if (!child) | 
|---|
| 3057 | { | 
|---|
| 3058 | retvalue = 0; | 
|---|
| 3059 | goto END; | 
|---|
| 3060 | } | 
|---|
| 3061 |  | 
|---|
| 3062 | if (fPrevious) | 
|---|
| 3063 | { | 
|---|
| 3064 | while (child->getNextChild()) | 
|---|
| 3065 | { | 
|---|
| 3066 | child = (Win32BaseWindow *)child->getNextChild(); | 
|---|
| 3067 | } | 
|---|
| 3068 | } | 
|---|
| 3069 | } | 
|---|
| 3070 |  | 
|---|
| 3071 | lastchild = child; | 
|---|
| 3072 | nextchild = (Win32BaseWindow *)child->getNextChild(); | 
|---|
| 3073 | while (TRUE) | 
|---|
| 3074 | { | 
|---|
| 3075 | if (!nextchild || (nextchild->getStyle() & WS_GROUP)) | 
|---|
| 3076 | { | 
|---|
| 3077 | /* Wrap-around to the beginning of the group */ | 
|---|
| 3078 | Win32BaseWindow *pWndTemp; | 
|---|
| 3079 |  | 
|---|
| 3080 | nextchild = (Win32BaseWindow *)getFirstChild(); | 
|---|
| 3081 |  | 
|---|
| 3082 | for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild()) | 
|---|
| 3083 | { | 
|---|
| 3084 | if (pWndTemp->getStyle() & WS_GROUP) | 
|---|
| 3085 | nextchild = pWndTemp; | 
|---|
| 3086 |  | 
|---|
| 3087 | if (pWndTemp == child) | 
|---|
| 3088 | break; | 
|---|
| 3089 | } | 
|---|
| 3090 |  | 
|---|
| 3091 | } | 
|---|
| 3092 | if (nextchild == child) | 
|---|
| 3093 | break; | 
|---|
| 3094 |  | 
|---|
| 3095 | if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED)) | 
|---|
| 3096 | { | 
|---|
| 3097 | lastchild = nextchild; | 
|---|
| 3098 |  | 
|---|
| 3099 | if (!fPrevious) | 
|---|
| 3100 | break; | 
|---|
| 3101 | } | 
|---|
| 3102 |  | 
|---|
| 3103 | nextchild = (Win32BaseWindow *)nextchild->getNextChild(); | 
|---|
| 3104 | } | 
|---|
| 3105 | retvalue = lastchild->getWindowHandle(); | 
|---|
| 3106 | END: | 
|---|
| 3107 | return retvalue; | 
|---|
| 3108 | } | 
|---|
| 3109 | //****************************************************************************** | 
|---|
| 3110 | //****************************************************************************** | 
|---|
| 3111 | #ifdef DEBUG | 
|---|
| 3112 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle) | 
|---|
| 3113 | { | 
|---|
| 3114 | char style[256] = ""; | 
|---|
| 3115 | char exstyle[256] = ""; | 
|---|
| 3116 |  | 
|---|
| 3117 | /* Window styles */ | 
|---|
| 3118 | if(dwStyle & WS_CHILD) | 
|---|
| 3119 | strcat(style, "WS_CHILD "); | 
|---|
| 3120 | if(dwStyle & WS_POPUP) | 
|---|
| 3121 | strcat(style, "WS_POPUP "); | 
|---|
| 3122 | if(dwStyle & WS_VISIBLE) | 
|---|
| 3123 | strcat(style, "WS_VISIBLE "); | 
|---|
| 3124 | if(dwStyle & WS_DISABLED) | 
|---|
| 3125 | strcat(style, "WS_DISABLED "); | 
|---|
| 3126 | if(dwStyle & WS_CLIPSIBLINGS) | 
|---|
| 3127 | strcat(style, "WS_CLIPSIBLINGS "); | 
|---|
| 3128 | if(dwStyle & WS_CLIPCHILDREN) | 
|---|
| 3129 | strcat(style, "WS_CLIPCHILDREN "); | 
|---|
| 3130 | if(dwStyle & WS_MAXIMIZE) | 
|---|
| 3131 | strcat(style, "WS_MAXIMIZE "); | 
|---|
| 3132 | if(dwStyle & WS_MINIMIZE) | 
|---|
| 3133 | strcat(style, "WS_MINIMIZE "); | 
|---|
| 3134 | if(dwStyle & WS_GROUP) | 
|---|
| 3135 | strcat(style, "WS_GROUP "); | 
|---|
| 3136 | if(dwStyle & WS_TABSTOP) | 
|---|
| 3137 | strcat(style, "WS_TABSTOP "); | 
|---|
| 3138 |  | 
|---|
| 3139 | if((dwStyle & WS_CAPTION) == WS_CAPTION) | 
|---|
| 3140 | strcat(style, "WS_CAPTION "); | 
|---|
| 3141 | if(dwStyle & WS_DLGFRAME) | 
|---|
| 3142 | strcat(style, "WS_DLGFRAME "); | 
|---|
| 3143 | if(dwStyle & WS_BORDER) | 
|---|
| 3144 | strcat(style, "WS_BORDER "); | 
|---|
| 3145 |  | 
|---|
| 3146 | if(dwStyle & WS_VSCROLL) | 
|---|
| 3147 | strcat(style, "WS_VSCROLL "); | 
|---|
| 3148 | if(dwStyle & WS_HSCROLL) | 
|---|
| 3149 | strcat(style, "WS_HSCROLL "); | 
|---|
| 3150 | if(dwStyle & WS_SYSMENU) | 
|---|
| 3151 | strcat(style, "WS_SYSMENU "); | 
|---|
| 3152 | if(dwStyle & WS_THICKFRAME) | 
|---|
| 3153 | strcat(style, "WS_THICKFRAME "); | 
|---|
| 3154 | if(dwStyle & WS_MINIMIZEBOX) | 
|---|
| 3155 | strcat(style, "WS_MINIMIZEBOX "); | 
|---|
| 3156 | if(dwStyle & WS_MAXIMIZEBOX) | 
|---|
| 3157 | strcat(style, "WS_MAXIMIZEBOX "); | 
|---|
| 3158 |  | 
|---|
| 3159 | if(dwExStyle & WS_EX_DLGMODALFRAME) | 
|---|
| 3160 | strcat(exstyle, "WS_EX_DLGMODALFRAME "); | 
|---|
| 3161 | if(dwExStyle & WS_EX_ACCEPTFILES) | 
|---|
| 3162 | strcat(exstyle, "WS_EX_ACCEPTFILES "); | 
|---|
| 3163 | if(dwExStyle & WS_EX_NOPARENTNOTIFY) | 
|---|
| 3164 | strcat(exstyle, "WS_EX_NOPARENTNOTIFY "); | 
|---|
| 3165 | if(dwExStyle & WS_EX_TOPMOST) | 
|---|
| 3166 | strcat(exstyle, "WS_EX_TOPMOST "); | 
|---|
| 3167 | if(dwExStyle & WS_EX_TRANSPARENT) | 
|---|
| 3168 | strcat(exstyle, "WS_EX_TRANSPARENT "); | 
|---|
| 3169 |  | 
|---|
| 3170 | if(dwExStyle & WS_EX_MDICHILD) | 
|---|
| 3171 | strcat(exstyle, "WS_EX_MDICHILD "); | 
|---|
| 3172 | if(dwExStyle & WS_EX_TOOLWINDOW) | 
|---|
| 3173 | strcat(exstyle, "WS_EX_TOOLWINDOW "); | 
|---|
| 3174 | if(dwExStyle & WS_EX_WINDOWEDGE) | 
|---|
| 3175 | strcat(exstyle, "WS_EX_WINDOWEDGE "); | 
|---|
| 3176 | if(dwExStyle & WS_EX_CLIENTEDGE) | 
|---|
| 3177 | strcat(exstyle, "WS_EX_CLIENTEDGE "); | 
|---|
| 3178 | if(dwExStyle & WS_EX_CONTEXTHELP) | 
|---|
| 3179 | strcat(exstyle, "WS_EX_CONTEXTHELP "); | 
|---|
| 3180 | if(dwExStyle & WS_EX_RIGHT) | 
|---|
| 3181 | strcat(exstyle, "WS_EX_RIGHT "); | 
|---|
| 3182 | if(dwExStyle & WS_EX_LEFT) | 
|---|
| 3183 | strcat(exstyle, "WS_EX_LEFT "); | 
|---|
| 3184 | if(dwExStyle & WS_EX_RTLREADING) | 
|---|
| 3185 | strcat(exstyle, "WS_EX_RTLREADING "); | 
|---|
| 3186 | if(dwExStyle & WS_EX_LTRREADING) | 
|---|
| 3187 | strcat(exstyle, "WS_EX_LTRREADING "); | 
|---|
| 3188 | if(dwExStyle & WS_EX_LEFTSCROLLBAR) | 
|---|
| 3189 | strcat(exstyle, "WS_EX_LEFTSCROLLBAR "); | 
|---|
| 3190 | if(dwExStyle & WS_EX_RIGHTSCROLLBAR) | 
|---|
| 3191 | strcat(exstyle, "WS_EX_RIGHTSCROLLBAR "); | 
|---|
| 3192 | if(dwExStyle & WS_EX_CONTROLPARENT) | 
|---|
| 3193 | strcat(exstyle, "WS_EX_CONTROLPARENT "); | 
|---|
| 3194 | if(dwExStyle & WS_EX_STATICEDGE) | 
|---|
| 3195 | strcat(exstyle, "WS_EX_STATICEDGE "); | 
|---|
| 3196 | if(dwExStyle & WS_EX_APPWINDOW) | 
|---|
| 3197 | strcat(exstyle, "WS_EX_APPWINDOW "); | 
|---|
| 3198 |  | 
|---|
| 3199 | dprintf(("Window style:   %x %s", dwStyle, style)); | 
|---|
| 3200 | dprintf(("Window exStyle: %x %s (FS = %x)", dwExStyle, exstyle, GetFS())); | 
|---|
| 3201 | } | 
|---|
| 3202 | #endif | 
|---|
| 3203 | //****************************************************************************** | 
|---|
| 3204 | //****************************************************************************** | 
|---|
| 3205 |  | 
|---|
| 3206 | GenericObject *Win32BaseWindow::windows  = NULL; | 
|---|