| 1 | /* $Id: win32wbase.cpp,v 1.321 2002-03-28 16:20:06 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 Window Base Class for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998-2002 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: To access a window object, you must call GetWindowFromOS2Handle or
|
|---|
| 18 | * GetWindowFromHandle. Both these methods increase the reference count
|
|---|
| 19 | * of the object. When you're done with the object, you MUST call
|
|---|
| 20 | * the release method!
|
|---|
| 21 | * This mechanism prevents premature destruction of objects when there
|
|---|
| 22 | * are still clients using it.
|
|---|
| 23 | *
|
|---|
| 24 | * NOTE: Client rectangle always relative to frame window
|
|---|
| 25 | * Window rectangle in parent coordinates (relative to parent's client window)
|
|---|
| 26 | * (screen coord. if no parent)
|
|---|
| 27 | *
|
|---|
| 28 | * NOTE: Status of window:
|
|---|
| 29 | * Before a window has processed WM_NCCREATE:
|
|---|
| 30 | * - GetTopWindow can't return that window handle
|
|---|
| 31 | * - GetWindow(parent, GW_CHILD) can't return that window handle
|
|---|
| 32 | * - IsChild works
|
|---|
| 33 | * TODO: Does this affect more functions?? (other GetWindow ops)
|
|---|
| 34 | * (verified in NT4, SP6)
|
|---|
| 35 | *
|
|---|
| 36 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 37 | *
|
|---|
| 38 | */
|
|---|
| 39 | #include <os2win.h>
|
|---|
| 40 | #include <win.h>
|
|---|
| 41 | #include <stdlib.h>
|
|---|
| 42 | #include <string.h>
|
|---|
| 43 | #include <stdarg.h>
|
|---|
| 44 | #include <assert.h>
|
|---|
| 45 | #include <misc.h>
|
|---|
| 46 | #include <heapstring.h>
|
|---|
| 47 | #include <winuser32.h>
|
|---|
| 48 | #include <custombuild.h>
|
|---|
| 49 | #include "win32wbase.h"
|
|---|
| 50 | #include "wndmsg.h"
|
|---|
| 51 | #include "oslibwin.h"
|
|---|
| 52 | #include "oslibmsg.h"
|
|---|
| 53 | #include "oslibutil.h"
|
|---|
| 54 | #include "oslibgdi.h"
|
|---|
| 55 | #include "oslibres.h"
|
|---|
| 56 | #include "oslibdos.h"
|
|---|
| 57 | #include "syscolor.h"
|
|---|
| 58 | #include "win32wndhandle.h"
|
|---|
| 59 | #include "dc.h"
|
|---|
| 60 | #include "win32wdesktop.h"
|
|---|
| 61 | #include "pmwindow.h"
|
|---|
| 62 | #include "controls.h"
|
|---|
| 63 | #include <wprocess.h>
|
|---|
| 64 | #include <win\hook.h>
|
|---|
| 65 | #include <menu.h>
|
|---|
| 66 | #define INCL_TIMERWIN32
|
|---|
| 67 | #include "timer.h"
|
|---|
| 68 |
|
|---|
| 69 | #define DBG_LOCALLOG DBG_win32wbase
|
|---|
| 70 | #include "dbglocal.h"
|
|---|
| 71 |
|
|---|
| 72 | /* bits in the dwKeyData */
|
|---|
| 73 | #define KEYDATA_ALT 0x2000
|
|---|
| 74 | #define KEYDATA_PREVSTATE 0x4000
|
|---|
| 75 |
|
|---|
| 76 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
|
|---|
| 77 |
|
|---|
| 78 | static fDestroyAll = FALSE;
|
|---|
| 79 | //For quick lookup of current process id
|
|---|
| 80 | static ULONG currentProcessId = -1;
|
|---|
| 81 | static int iF10Key = 0;
|
|---|
| 82 | static int iMenuSysKey = 0;
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 | /***
|
|---|
| 87 | * Performance Optimization:
|
|---|
| 88 | * we're directly inlining this micro function from win32wndhandle.cpp.
|
|---|
| 89 | * Changes there must be reflected here.
|
|---|
| 90 | ***/
|
|---|
| 91 | extern ULONG WindowHandleTable[MAX_WINDOW_HANDLES];
|
|---|
| 92 |
|
|---|
| 93 | BOOL INLINE i_HwGetWindowHandleData(HWND hwnd, DWORD *pdwUserData)
|
|---|
| 94 | {
|
|---|
| 95 | if((hwnd & 0xFFFF0000) != WNDHANDLE_MAGIC_HIGHWORD) {
|
|---|
| 96 | return FALSE; //unknown window (PM?)
|
|---|
| 97 | }
|
|---|
| 98 | hwnd &= WNDHANDLE_MAGIC_MASK;
|
|---|
| 99 | if(hwnd < MAX_WINDOW_HANDLES) {
|
|---|
| 100 | *pdwUserData = WindowHandleTable[hwnd];
|
|---|
| 101 | return TRUE;
|
|---|
| 102 | }
|
|---|
| 103 | *pdwUserData = 0;
|
|---|
| 104 | return FALSE;
|
|---|
| 105 | }
|
|---|
| 106 | #define HwGetWindowHandleData(a,b) i_HwGetWindowHandleData(a,b)
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 | //******************************************************************************
|
|---|
| 110 | //******************************************************************************
|
|---|
| 111 | Win32BaseWindow::Win32BaseWindow()
|
|---|
| 112 | : GenericObject(&windows, &critsect), ChildWindow(&critsect)
|
|---|
| 113 | {
|
|---|
| 114 | Init();
|
|---|
| 115 | }
|
|---|
| 116 | //******************************************************************************
|
|---|
| 117 | //******************************************************************************
|
|---|
| 118 | Win32BaseWindow::Win32BaseWindow(HWND hwndOS2, ATOM classAtom)
|
|---|
| 119 | : GenericObject(&windows, &critsect), ChildWindow(&critsect)
|
|---|
| 120 | {
|
|---|
| 121 | Init();
|
|---|
| 122 | OS2Hwnd = OS2HwndFrame = hwndOS2;
|
|---|
| 123 |
|
|---|
| 124 | /* Find the window class */
|
|---|
| 125 | windowClass = Win32WndClass::FindClass(NULL, (LPSTR)classAtom);
|
|---|
| 126 | if (!windowClass)
|
|---|
| 127 | {
|
|---|
| 128 | char buffer[32];
|
|---|
| 129 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
|---|
| 130 | dprintf(("Bad class '%s'", buffer ));
|
|---|
| 131 | DebugInt3();
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | //Allocate window words
|
|---|
| 135 | nrUserWindowBytes = windowClass->getExtraWndBytes();
|
|---|
| 136 | if(nrUserWindowBytes) {
|
|---|
| 137 | userWindowBytes = (char *)_smalloc(nrUserWindowBytes);
|
|---|
| 138 | memset(userWindowBytes, 0, nrUserWindowBytes);
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
|
|---|
| 142 | hInstance = NULL;
|
|---|
| 143 | dwStyle = WS_VISIBLE;
|
|---|
| 144 | dwOldStyle = dwStyle;
|
|---|
| 145 | dwExStyle = 0;
|
|---|
| 146 |
|
|---|
| 147 | //We pretend this window has no parent and won't change size
|
|---|
| 148 | //(dangerous assumption!!)
|
|---|
| 149 | OSLibWinQueryWindowClientRect(OS2Hwnd, &rectClient);
|
|---|
| 150 | OSLibQueryWindowRectAbsolute (OS2Hwnd, &rectWindow);
|
|---|
| 151 |
|
|---|
| 152 | fFakeWindow = TRUE;
|
|---|
| 153 | }
|
|---|
| 154 | //******************************************************************************
|
|---|
| 155 | //******************************************************************************
|
|---|
| 156 | Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
|
|---|
| 157 | : GenericObject(&windows, &critsect), ChildWindow(&critsect)
|
|---|
| 158 | {
|
|---|
| 159 | Init();
|
|---|
| 160 | this->isUnicode = isUnicode;
|
|---|
| 161 | CreateWindowExA(lpCreateStructA, classAtom);
|
|---|
| 162 | }
|
|---|
| 163 | //******************************************************************************
|
|---|
| 164 | //******************************************************************************
|
|---|
| 165 | void Win32BaseWindow::Init()
|
|---|
| 166 | {
|
|---|
| 167 | isUnicode = FALSE;
|
|---|
| 168 | fFirstShow = TRUE;
|
|---|
| 169 | fIsDialog = FALSE;
|
|---|
| 170 | fIsModalDialogOwner = FALSE;
|
|---|
| 171 | OS2HwndModalDialog = 0;
|
|---|
| 172 | fParentChange = FALSE;
|
|---|
| 173 | fDestroyWindowCalled = FALSE;
|
|---|
| 174 | fTaskList = FALSE;
|
|---|
| 175 | fParentDC = FALSE;
|
|---|
| 176 | fComingToTop = FALSE;
|
|---|
| 177 | fMinMaxChange = FALSE;
|
|---|
| 178 | fVisibleRegionChanged = FALSE;
|
|---|
| 179 | fEraseBkgndFlag = TRUE;
|
|---|
| 180 | fFakeWindow = FALSE;
|
|---|
| 181 |
|
|---|
| 182 | state = STATE_INIT;
|
|---|
| 183 | windowNameA = NULL;
|
|---|
| 184 | windowNameW = NULL;
|
|---|
| 185 | windowNameLength = 0;
|
|---|
| 186 |
|
|---|
| 187 | userWindowBytes = NULL;;
|
|---|
| 188 | nrUserWindowBytes= 0;
|
|---|
| 189 |
|
|---|
| 190 | OS2Hwnd = 0;
|
|---|
| 191 | OS2HwndFrame = 0;
|
|---|
| 192 | hSysMenu = 0;
|
|---|
| 193 | Win32Hwnd = 0;
|
|---|
| 194 |
|
|---|
| 195 | if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
|
|---|
| 196 | {
|
|---|
| 197 | dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
|
|---|
| 198 | DebugInt3();
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | posx = posy = 0;
|
|---|
| 202 | width = height = 0;
|
|---|
| 203 |
|
|---|
| 204 | dwExStyle = 0;
|
|---|
| 205 | dwStyle = 0;
|
|---|
| 206 | dwOldStyle = 0;
|
|---|
| 207 | win32wndproc = 0;
|
|---|
| 208 | hInstance = 0;
|
|---|
| 209 | dwIDMenu = 0; //0xFFFFFFFF; //default -1
|
|---|
| 210 | userData = 0;
|
|---|
| 211 | contextHelpId = 0;
|
|---|
| 212 | hotkey = 0;
|
|---|
| 213 |
|
|---|
| 214 | hwndLinkAfter = HWND_BOTTOM;
|
|---|
| 215 | flags = 0;
|
|---|
| 216 | lastHitTestVal = HTCLIENT;
|
|---|
| 217 | owner = NULL;
|
|---|
| 218 | windowClass = 0;
|
|---|
| 219 |
|
|---|
| 220 | hIcon = 0;
|
|---|
| 221 | hIconSm = 0;
|
|---|
| 222 |
|
|---|
| 223 | horzScrollInfo = NULL;
|
|---|
| 224 | vertScrollInfo = NULL;
|
|---|
| 225 |
|
|---|
| 226 | propertyList = NULL;
|
|---|
| 227 |
|
|---|
| 228 | cbExtra = 0;
|
|---|
| 229 | pExtra = NULL;
|
|---|
| 230 |
|
|---|
| 231 | ownDC = 0;
|
|---|
| 232 | hWindowRegion = 0;
|
|---|
| 233 | hClipRegion = 0;
|
|---|
| 234 |
|
|---|
| 235 | hTaskList = 0;
|
|---|
| 236 |
|
|---|
| 237 | if(currentProcessId == -1)
|
|---|
| 238 | {
|
|---|
| 239 | currentProcessId = GetCurrentProcessId();
|
|---|
| 240 | }
|
|---|
| 241 | dwThreadId = GetCurrentThreadId();
|
|---|
| 242 | dwProcessId = currentProcessId;
|
|---|
| 243 |
|
|---|
| 244 | memset(&windowpos, 0, sizeof(windowpos));
|
|---|
| 245 | //min and max position are initially -1 (verified in NT4, SP6)
|
|---|
| 246 | windowpos.ptMinPosition.x = -1;
|
|---|
| 247 | windowpos.ptMinPosition.y = -1;
|
|---|
| 248 | windowpos.ptMaxPosition.x = -1;
|
|---|
| 249 | windowpos.ptMaxPosition.y = -1;
|
|---|
| 250 |
|
|---|
| 251 | lpVisRgnNotifyProc = NULL;
|
|---|
| 252 | dwVisRgnNotifyParam = NULL;
|
|---|
| 253 | }
|
|---|
| 254 | //******************************************************************************
|
|---|
| 255 | //todo get rid of resources (menu, icon etc)
|
|---|
| 256 | //******************************************************************************
|
|---|
| 257 | Win32BaseWindow::~Win32BaseWindow()
|
|---|
| 258 | {
|
|---|
| 259 | if(getRefCount() < 0) {
|
|---|
| 260 | DebugInt3();
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | if(hTaskList) {
|
|---|
| 264 | OSLibWinRemoveFromTasklist(hTaskList);
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | OSLibWinSetVisibleRegionNotify(OS2Hwnd, FALSE);
|
|---|
| 268 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
|
|---|
| 269 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
|
|---|
| 270 |
|
|---|
| 271 | if(fDestroyAll) {
|
|---|
| 272 | dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
|
|---|
| 273 | setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
|
|---|
| 274 | }
|
|---|
| 275 | else
|
|---|
| 276 | if(getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
|
|---|
| 277 | {
|
|---|
| 278 | //if we're the last child that's being destroyed and our
|
|---|
| 279 | //parent window was also destroyed, then we
|
|---|
| 280 | if(getParent()->IsWindowDestroyed())
|
|---|
| 281 | {
|
|---|
| 282 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
|---|
| 283 | RELEASE_WNDOBJ(wndparent);
|
|---|
| 284 | setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
|
|---|
| 285 | }
|
|---|
| 286 | }
|
|---|
| 287 | else
|
|---|
| 288 | {
|
|---|
| 289 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
|---|
| 290 | if(wndparent && !fDestroyAll) {
|
|---|
| 291 | RELEASE_WNDOBJ(wndparent);
|
|---|
| 292 | }
|
|---|
| 293 | }
|
|---|
| 294 | if(owner && !fDestroyAll) {
|
|---|
| 295 | RELEASE_WNDOBJ(owner);
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | /* Decrement class window counter */
|
|---|
| 299 | if(windowClass) {
|
|---|
| 300 | RELEASE_CLASSOBJ(windowClass);
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| 303 | if(isOwnDC())
|
|---|
| 304 | releaseOwnDC(ownDC);
|
|---|
| 305 |
|
|---|
| 306 | if(Win32Hwnd)
|
|---|
| 307 | HwFreeWindowHandle(Win32Hwnd);
|
|---|
| 308 |
|
|---|
| 309 | if(userWindowBytes)
|
|---|
| 310 | free(userWindowBytes);
|
|---|
| 311 |
|
|---|
| 312 | if(windowNameA) {
|
|---|
| 313 | free(windowNameA);
|
|---|
| 314 | windowNameA = NULL;
|
|---|
| 315 | }
|
|---|
| 316 | if(windowNameW) {
|
|---|
| 317 | free(windowNameW);
|
|---|
| 318 | windowNameW = NULL;
|
|---|
| 319 | }
|
|---|
| 320 | if(vertScrollInfo) {
|
|---|
| 321 | free(vertScrollInfo);
|
|---|
| 322 | vertScrollInfo = NULL;
|
|---|
| 323 | }
|
|---|
| 324 | if(horzScrollInfo) {
|
|---|
| 325 | free(horzScrollInfo);
|
|---|
| 326 | horzScrollInfo = NULL;
|
|---|
| 327 | }
|
|---|
| 328 | if(propertyList) {
|
|---|
| 329 | removeWindowProps();
|
|---|
| 330 | }
|
|---|
| 331 | }
|
|---|
| 332 | //******************************************************************************
|
|---|
| 333 | //******************************************************************************
|
|---|
| 334 | void Win32BaseWindow::DestroyAll()
|
|---|
| 335 | {
|
|---|
| 336 | fDestroyAll = TRUE;
|
|---|
| 337 | GenericObject::DestroyAll(windows);
|
|---|
| 338 | }
|
|---|
| 339 | //******************************************************************************
|
|---|
| 340 | //******************************************************************************
|
|---|
| 341 | BOOL Win32BaseWindow::isChild()
|
|---|
| 342 | {
|
|---|
| 343 | return ((dwStyle & WS_CHILD) != 0);
|
|---|
| 344 | }
|
|---|
| 345 | //******************************************************************************
|
|---|
| 346 | //******************************************************************************
|
|---|
| 347 | BOOL Win32BaseWindow::IsWindowUnicode()
|
|---|
| 348 | {
|
|---|
| 349 | dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
|
|---|
| 350 | return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
|
|---|
| 351 | }
|
|---|
| 352 | //******************************************************************************
|
|---|
| 353 | //******************************************************************************
|
|---|
| 354 | BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
|
|---|
| 355 | {
|
|---|
| 356 | char buffer[256];
|
|---|
| 357 |
|
|---|
| 358 | #ifdef DEBUG
|
|---|
| 359 | PrintWindowStyle(cs->style, cs->dwExStyle);
|
|---|
| 360 | #endif
|
|---|
| 361 |
|
|---|
| 362 | //If window has no owner/parent window, then it will be added to the tasklist
|
|---|
| 363 | //(depending on visibility state)
|
|---|
| 364 | if (!cs->hwndParent) fTaskList = TRUE;
|
|---|
| 365 |
|
|---|
| 366 | sw = SW_SHOW;
|
|---|
| 367 | SetLastError(0);
|
|---|
| 368 |
|
|---|
| 369 | /* Find the parent window */
|
|---|
| 370 | if (cs->hwndParent)
|
|---|
| 371 | {
|
|---|
| 372 | Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
|
|---|
| 373 | if(!window) {
|
|---|
| 374 | dprintf(("Bad parent %04x\n", cs->hwndParent ));
|
|---|
| 375 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 376 | return FALSE;
|
|---|
| 377 | }
|
|---|
| 378 | /* Make sure parent is valid */
|
|---|
| 379 | if (!window->IsWindow() )
|
|---|
| 380 | {
|
|---|
| 381 | RELEASE_WNDOBJ(window);
|
|---|
| 382 | dprintf(("Bad parent %04x\n", cs->hwndParent ));
|
|---|
| 383 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 384 | return FALSE;
|
|---|
| 385 | }
|
|---|
| 386 | RELEASE_WNDOBJ(window);
|
|---|
| 387 | /* Windows does this for overlapped windows
|
|---|
| 388 | * (I don't know about other styles.) */
|
|---|
| 389 | if (cs->hwndParent == GetDesktopWindow() && (!(cs->style & WS_CHILD) || (cs->style & WS_POPUP)))
|
|---|
| 390 | {
|
|---|
| 391 | cs->hwndParent = 0;
|
|---|
| 392 | }
|
|---|
| 393 | }
|
|---|
| 394 | else
|
|---|
| 395 | if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
|
|---|
| 396 | dprintf(("No parent for child window" ));
|
|---|
| 397 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 398 | return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | /* Find the window class */
|
|---|
| 402 | windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
|
|---|
| 403 | if (!windowClass)
|
|---|
| 404 | {
|
|---|
| 405 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
|---|
| 406 | dprintf(("Bad class '%s'", buffer ));
|
|---|
| 407 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 408 | return 0;
|
|---|
| 409 | }
|
|---|
| 410 |
|
|---|
| 411 | #ifdef DEBUG
|
|---|
| 412 | if(HIWORD(cs->lpszClass))
|
|---|
| 413 | {
|
|---|
| 414 | if(isUnicode) dprintf(("Window class %ls", cs->lpszClass));
|
|---|
| 415 | else dprintf(("Window class %s", cs->lpszClass));
|
|---|
| 416 | }
|
|---|
| 417 | else dprintf(("Window class %x", cs->lpszClass));
|
|---|
| 418 | #endif
|
|---|
| 419 |
|
|---|
| 420 | /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
|
|---|
| 421 | * with an atom as the class name, put some programs expect to have a *REAL* string in
|
|---|
| 422 | * lpszClass when the CREATESTRUCT is sent with WM_CREATE
|
|---|
| 423 | */
|
|---|
| 424 | if (!HIWORD(cs->lpszClass) ) {
|
|---|
| 425 | if (isUnicode) {
|
|---|
| 426 | GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
|
|---|
| 427 | }
|
|---|
| 428 | else {
|
|---|
| 429 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
|---|
| 430 | }
|
|---|
| 431 | cs->lpszClass = buffer;
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 | /* Fix the coordinates */
|
|---|
| 435 | fXDefault = FALSE;
|
|---|
| 436 | fCXDefault = FALSE;
|
|---|
| 437 | if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16))
|
|---|
| 438 | {
|
|---|
| 439 | /* Never believe Microsoft's documentation... CreateWindowEx doc says
|
|---|
| 440 | * that if an overlapped window is created with WS_VISIBLE style bit
|
|---|
| 441 | * set and the x parameter is set to CW_USEDEFAULT, the system ignores
|
|---|
| 442 | * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
|
|---|
| 443 | * reveals that
|
|---|
| 444 | *
|
|---|
| 445 | * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
|
|---|
| 446 | * 2) it does not ignore the y parameter as the docs claim; instead, it
|
|---|
| 447 | * uses it as second parameter to ShowWindow() unless y is either
|
|---|
| 448 | * CW_USEDEFAULT or CW_USEDEFAULT16.
|
|---|
| 449 | *
|
|---|
| 450 | * The fact that we didn't do 2) caused bogus windows pop up when wine
|
|---|
| 451 | * was running apps that were using this obscure feature. Example -
|
|---|
| 452 | * calc.exe that comes with Win98 (only Win98, it's different from
|
|---|
| 453 | * the one that comes with Win95 and NT)
|
|---|
| 454 | */
|
|---|
| 455 | if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y;
|
|---|
| 456 |
|
|---|
| 457 | /* We have saved cs->y, now we can trash it */
|
|---|
| 458 | cs->x = 0;
|
|---|
| 459 | cs->y = 0;
|
|---|
| 460 | fXDefault = TRUE;
|
|---|
| 461 | }
|
|---|
| 462 | if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16))
|
|---|
| 463 | {
|
|---|
| 464 | cs->cx = 600; /* FIXME */
|
|---|
| 465 | cs->cy = 400;
|
|---|
| 466 | fCXDefault = TRUE;
|
|---|
| 467 | }
|
|---|
| 468 | if (cs->style & (WS_POPUP | WS_CHILD))
|
|---|
| 469 | {
|
|---|
| 470 | fXDefault = FALSE;
|
|---|
| 471 | if (fCXDefault)
|
|---|
| 472 | {
|
|---|
| 473 | fCXDefault = FALSE;
|
|---|
| 474 | cs->cx = cs->cy = 0;
|
|---|
| 475 | }
|
|---|
| 476 | }
|
|---|
| 477 | if (fXDefault && !fCXDefault) fXDefault = FALSE; //CB: only x positioning doesn't work (calc.exe,cdrlabel.exe)
|
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 | /* Correct the window style - stage 1
|
|---|
| 481 | *
|
|---|
| 482 | * These are patches that appear to affect both the style loaded into the
|
|---|
| 483 | * WIN structure and passed in the CreateStruct to the WM_CREATE etc.
|
|---|
| 484 | *
|
|---|
| 485 | * WS_EX_WINDOWEDGE appears to be enforced based on the other styles, so
|
|---|
| 486 | * why does the user get to set it?
|
|---|
| 487 | */
|
|---|
| 488 |
|
|---|
| 489 | /* This has been tested for WS_CHILD | WS_VISIBLE. It has not been
|
|---|
| 490 | * tested for WS_POPUP
|
|---|
| 491 | */
|
|---|
| 492 | if ((cs->dwExStyle & WS_EX_DLGMODALFRAME) ||
|
|---|
| 493 | ((!(cs->dwExStyle & WS_EX_STATICEDGE)) &&
|
|---|
| 494 | (cs->style & (WS_DLGFRAME | WS_THICKFRAME))))
|
|---|
| 495 | cs->dwExStyle |= WS_EX_WINDOWEDGE;
|
|---|
| 496 | else
|
|---|
| 497 | cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
|
|---|
| 498 |
|
|---|
| 499 | //Allocate window words
|
|---|
| 500 | nrUserWindowBytes = windowClass->getExtraWndBytes();
|
|---|
| 501 | if(nrUserWindowBytes) {
|
|---|
| 502 | userWindowBytes = (char *)_smalloc(nrUserWindowBytes);
|
|---|
| 503 | memset(userWindowBytes, 0, nrUserWindowBytes);
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | if ((cs->style & WS_CHILD) && cs->hwndParent)
|
|---|
| 507 | {
|
|---|
| 508 | SetParent(cs->hwndParent);
|
|---|
| 509 | // owner = GetWindowFromHandle(cs->hwndParent);
|
|---|
| 510 | owner = 0;
|
|---|
| 511 | /* if(owner == NULL)
|
|---|
| 512 | {
|
|---|
| 513 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
|
|---|
| 514 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 515 | return FALSE;
|
|---|
| 516 | }*/
|
|---|
| 517 | //SvL: Shell positioning shouldn't be done for child windows! (breaks Notes)
|
|---|
| 518 | fXDefault = fCXDefault = FALSE;
|
|---|
| 519 | }
|
|---|
| 520 | else
|
|---|
| 521 | {
|
|---|
| 522 | SetParent(0);
|
|---|
| 523 | if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
|
|---|
| 524 | owner = NULL;
|
|---|
| 525 | }
|
|---|
| 526 | else
|
|---|
| 527 | {
|
|---|
| 528 | Win32BaseWindow *wndparent = GetWindowFromHandle(cs->hwndParent);
|
|---|
| 529 | if(wndparent) {
|
|---|
| 530 | owner = GetWindowFromHandle(wndparent->GetTopParent());
|
|---|
| 531 | RELEASE_WNDOBJ(wndparent);
|
|---|
| 532 | }
|
|---|
| 533 | else owner = NULL;
|
|---|
| 534 |
|
|---|
| 535 | if(owner == NULL)
|
|---|
| 536 | {
|
|---|
| 537 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
|
|---|
| 538 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 539 | return FALSE;
|
|---|
| 540 | }
|
|---|
| 541 | }
|
|---|
| 542 | }
|
|---|
| 543 |
|
|---|
| 544 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
|
|---|
| 545 | hInstance = cs->hInstance;
|
|---|
| 546 | dwStyle = cs->style & ~WS_VISIBLE;
|
|---|
| 547 | dwOldStyle = dwStyle;
|
|---|
| 548 | dwExStyle = cs->dwExStyle;
|
|---|
| 549 |
|
|---|
| 550 | hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
|
|---|
| 551 |
|
|---|
| 552 | /* Correct the window style phase 2 */
|
|---|
| 553 | if (!(cs->style & WS_CHILD))
|
|---|
| 554 | {
|
|---|
| 555 | dwStyle |= WS_CLIPSIBLINGS;
|
|---|
| 556 | if (!(cs->style & WS_POPUP))
|
|---|
| 557 | {
|
|---|
| 558 | dwStyle |= WS_CAPTION;
|
|---|
| 559 | flags |= WIN_NEED_SIZE;
|
|---|
| 560 | }
|
|---|
| 561 | }
|
|---|
| 562 | if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
|
|---|
| 563 |
|
|---|
| 564 | //WinZip 8.0 crashes when a dialog created after opening a zipfile receives
|
|---|
| 565 | //the WM_SIZE message (before WM_INITDIALOG)
|
|---|
| 566 | //Opera doesn't like this either.
|
|---|
| 567 | if(IsDialog()) {
|
|---|
| 568 | flags |= WIN_NEED_SIZE;
|
|---|
| 569 | }
|
|---|
| 570 |
|
|---|
| 571 | //copy pointer of CREATESTRUCT for usage in MsgCreate method
|
|---|
| 572 | tmpcs = cs;
|
|---|
| 573 |
|
|---|
| 574 | //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
|
|---|
| 575 | TEB *teb = GetThreadTEB();
|
|---|
| 576 | if(teb == NULL) {
|
|---|
| 577 | dprintf(("Window creation failed - teb == NULL")); //this is VERY bad
|
|---|
| 578 | ExitProcess(666);
|
|---|
| 579 | return FALSE;
|
|---|
| 580 | }
|
|---|
| 581 |
|
|---|
| 582 | teb->o.odin.newWindow = (ULONG)this;
|
|---|
| 583 |
|
|---|
| 584 | DWORD dwOSWinStyle, dwOSFrameStyle;
|
|---|
| 585 |
|
|---|
| 586 | OSLibWinConvertStyle(dwStyle,dwExStyle,&dwOSWinStyle, &dwOSFrameStyle);
|
|---|
| 587 |
|
|---|
| 588 | OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
|
|---|
| 589 | dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
|
|---|
| 590 | (owner) ? owner->getOS2WindowHandle() : ((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP),
|
|---|
| 591 | (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
|
|---|
| 592 | 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle(), &OS2HwndFrame);
|
|---|
| 593 | if(OS2Hwnd == 0) {
|
|---|
| 594 | dprintf(("Window creation failed!! OS LastError %0x", OSLibWinGetLastError()));
|
|---|
| 595 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 596 | return FALSE;
|
|---|
| 597 | }
|
|---|
| 598 | OSLibWinSetVisibleRegionNotify(OS2Hwnd, TRUE);
|
|---|
| 599 | state = STATE_CREATED;
|
|---|
| 600 | SetLastError(0);
|
|---|
| 601 | return TRUE;
|
|---|
| 602 | }
|
|---|
| 603 | //******************************************************************************
|
|---|
| 604 | //******************************************************************************
|
|---|
| 605 | BOOL Win32BaseWindow::MsgCreate(HWND hwndOS2)
|
|---|
| 606 | {
|
|---|
| 607 | CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
|
|---|
| 608 | POINT maxSize, maxPos, minTrack, maxTrack;
|
|---|
| 609 | HWND hwnd = getWindowHandle();
|
|---|
| 610 | LRESULT (* CALLBACK localSend32)(HWND, UINT, WPARAM, LPARAM);
|
|---|
| 611 |
|
|---|
| 612 | OS2Hwnd = hwndOS2;
|
|---|
| 613 |
|
|---|
| 614 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, getWindowHandle()) == FALSE) {
|
|---|
| 615 | dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
|
|---|
| 616 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 617 | return FALSE;
|
|---|
| 618 | }
|
|---|
| 619 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
|
|---|
| 620 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
|
|---|
| 621 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 622 | return FALSE;
|
|---|
| 623 | }
|
|---|
| 624 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32FLAGS, 0) == FALSE) {
|
|---|
| 625 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
|
|---|
| 626 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 627 | return FALSE;
|
|---|
| 628 | }
|
|---|
| 629 |
|
|---|
| 630 | if (HOOK_IsHooked( WH_CBT ))
|
|---|
| 631 | {
|
|---|
| 632 | CBT_CREATEWNDA cbtc;
|
|---|
| 633 | LRESULT ret;
|
|---|
| 634 |
|
|---|
| 635 | cbtc.lpcs = cs;
|
|---|
| 636 | cbtc.hwndInsertAfter = hwndLinkAfter;
|
|---|
| 637 | ret = (isUnicode) ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc)
|
|---|
| 638 | : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
|
|---|
| 639 | if(ret)
|
|---|
| 640 | {
|
|---|
| 641 | dprintf(("CBT-hook returned non-0 !!"));
|
|---|
| 642 | SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
|
|---|
| 643 | return FALSE;
|
|---|
| 644 | }
|
|---|
| 645 | //todo: if hook changes parent, we need to do so too!!!!!!!!!!
|
|---|
| 646 | }
|
|---|
| 647 |
|
|---|
| 648 | if (cs->style & WS_HSCROLL)
|
|---|
| 649 | {
|
|---|
| 650 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
|---|
| 651 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
|
|---|
| 652 | horzScrollInfo->MaxVal = 100;
|
|---|
| 653 | horzScrollInfo->flags = ESB_ENABLE_BOTH;
|
|---|
| 654 | }
|
|---|
| 655 |
|
|---|
| 656 | if (cs->style & WS_VSCROLL)
|
|---|
| 657 | {
|
|---|
| 658 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
|---|
| 659 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
|
|---|
| 660 | vertScrollInfo->MaxVal = 100;
|
|---|
| 661 | vertScrollInfo->flags = ESB_ENABLE_BOTH;
|
|---|
| 662 | }
|
|---|
| 663 |
|
|---|
| 664 | // initially allocate the window name fields
|
|---|
| 665 | if(HIWORD(cs->lpszName))
|
|---|
| 666 | {
|
|---|
| 667 | if (!isUnicode)
|
|---|
| 668 | {
|
|---|
| 669 | windowNameLength = strlen(cs->lpszName);
|
|---|
| 670 | windowNameA = (LPSTR)_smalloc(windowNameLength+1);
|
|---|
| 671 | memcpy(windowNameA,cs->lpszName,windowNameLength+1);
|
|---|
| 672 | windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
|
|---|
| 673 | lstrcpynAtoW(windowNameW,windowNameA,windowNameLength+1);
|
|---|
| 674 | windowNameA[windowNameLength] = 0;
|
|---|
| 675 | windowNameW[windowNameLength] = 0;
|
|---|
| 676 | }
|
|---|
| 677 | else
|
|---|
| 678 | {
|
|---|
| 679 | // Wide
|
|---|
| 680 | windowNameLength = lstrlenW((LPWSTR)cs->lpszName);
|
|---|
| 681 | windowNameW = (LPWSTR)_smalloc( (windowNameLength+1)*sizeof(WCHAR) );
|
|---|
| 682 | memcpy(windowNameW,(LPWSTR)cs->lpszName, (windowNameLength+1)*sizeof(WCHAR) );
|
|---|
| 683 |
|
|---|
| 684 | // windowNameW[lstrlenW((LPWSTR)cs->lpszName)] = 0; // need ?
|
|---|
| 685 |
|
|---|
| 686 | // Ascii
|
|---|
| 687 | windowNameA = (LPSTR)_smalloc(windowNameLength+1);
|
|---|
| 688 | WideCharToMultiByte(CP_ACP,
|
|---|
| 689 | 0,
|
|---|
| 690 | windowNameW,
|
|---|
| 691 | windowNameLength,
|
|---|
| 692 | windowNameA,
|
|---|
| 693 | windowNameLength + 1,
|
|---|
| 694 | 0,
|
|---|
| 695 | NULL);
|
|---|
| 696 | windowNameA[windowNameLength] = 0;
|
|---|
| 697 | }
|
|---|
| 698 |
|
|---|
| 699 | if(fOS2Look) {
|
|---|
| 700 | OSLibWinSetTitleBarText(OS2HwndFrame, windowNameA);
|
|---|
| 701 | }
|
|---|
| 702 | }
|
|---|
| 703 |
|
|---|
| 704 | //SvL: This completely messes up MS Word 97 (no button bar, no menu)
|
|---|
| 705 | #if 0
|
|---|
| 706 | //adjust CW_USEDEFAULT position
|
|---|
| 707 | if (fXDefault | fCXDefault)
|
|---|
| 708 | {
|
|---|
| 709 | RECT rect;
|
|---|
| 710 |
|
|---|
| 711 | //SvL: Returns invalid rectangle (not the expected shell default size)
|
|---|
| 712 | OSLibWinQueryWindowRect(OS2Hwnd,&rect,RELATIVE_TO_SCREEN);
|
|---|
| 713 | if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
|
|---|
| 714 | if (fXDefault)
|
|---|
| 715 | {
|
|---|
| 716 | cs->x = rect.left;
|
|---|
| 717 | cs->y = rect.top;
|
|---|
| 718 | if (!fCXDefault)
|
|---|
| 719 | {
|
|---|
| 720 | //CB: todo: adjust pos to screen rect
|
|---|
| 721 | }
|
|---|
| 722 | }
|
|---|
| 723 | if (fCXDefault)
|
|---|
| 724 | {
|
|---|
| 725 | cs->cx = rect.right-rect.left;
|
|---|
| 726 | cs->cy = rect.bottom-rect.top;
|
|---|
| 727 | }
|
|---|
| 728 | }
|
|---|
| 729 | #endif
|
|---|
| 730 |
|
|---|
| 731 | fakeWinBase.hwndThis = OS2Hwnd;
|
|---|
| 732 | fakeWinBase.pWindowClass = windowClass;
|
|---|
| 733 |
|
|---|
| 734 | //Set icon from window or class
|
|---|
| 735 | if (hIcon)
|
|---|
| 736 | OSLibWinSetIcon(OS2HwndFrame,hIcon);
|
|---|
| 737 | else
|
|---|
| 738 | if (windowClass->getIcon())
|
|---|
| 739 | OSLibWinSetIcon(OS2HwndFrame,windowClass->getIcon());
|
|---|
| 740 |
|
|---|
| 741 | /* Get class or window DC if needed */
|
|---|
| 742 | if(windowClass->getStyle() & CS_OWNDC) {
|
|---|
| 743 | dprintf(("Class with CS_OWNDC style"));
|
|---|
| 744 | ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE);
|
|---|
| 745 | }
|
|---|
| 746 | else
|
|---|
| 747 | if (windowClass->getStyle() & CS_PARENTDC) {
|
|---|
| 748 | fParentDC = TRUE;
|
|---|
| 749 | ownDC = 0;
|
|---|
| 750 | }
|
|---|
| 751 | else
|
|---|
| 752 | if (windowClass->getStyle() & CS_CLASSDC) {
|
|---|
| 753 | dprintf(("WARNING: Class with CS_CLASSDC style!"));
|
|---|
| 754 | //not a good solution, but it's a bit difficult to share a single
|
|---|
| 755 | //DC among different windows... DevOpenDC apparently can't be used
|
|---|
| 756 | //for window DCs and WinOpenWindowDC must be associated with a window
|
|---|
| 757 | ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE);
|
|---|
| 758 | }
|
|---|
| 759 | /* Set the window menu */
|
|---|
| 760 | if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
|
|---|
| 761 | {
|
|---|
| 762 | if (cs->hMenu) {
|
|---|
| 763 | ::SetMenu(getWindowHandle(), cs->hMenu);
|
|---|
| 764 | }
|
|---|
| 765 | else {
|
|---|
| 766 | if (windowClass->getMenuNameA()) {
|
|---|
| 767 | cs->hMenu = LoadMenuA(windowClass->getInstance(),windowClass->getMenuNameA());
|
|---|
| 768 | #if 0 //CB: hack for treeview test cases bug
|
|---|
| 769 | if (!cs->hMenu) cs->hMenu = LoadMenuA(windowClass->getInstance(),"MYAPP");
|
|---|
| 770 | #endif
|
|---|
| 771 | if (cs->hMenu) ::SetMenu(getWindowHandle(), cs->hMenu );
|
|---|
| 772 | }
|
|---|
| 773 | }
|
|---|
| 774 | }
|
|---|
| 775 | else
|
|---|
| 776 | {
|
|---|
| 777 | setWindowId((DWORD)cs->hMenu);
|
|---|
| 778 | }
|
|---|
| 779 | hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0;
|
|---|
| 780 |
|
|---|
| 781 | /* Send the WM_GETMINMAXINFO message and fix the size if needed */
|
|---|
| 782 | if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
|
|---|
| 783 | {
|
|---|
| 784 | GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
|
|---|
| 785 | if (maxSize.x < cs->cx) cs->cx = maxSize.x;
|
|---|
| 786 | if (maxSize.y < cs->cy) cs->cy = maxSize.y;
|
|---|
| 787 | if (cs->cx < minTrack.x) cs->cx = minTrack.x;
|
|---|
| 788 | if (cs->cy < minTrack.y) cs->cy = minTrack.y;
|
|---|
| 789 | }
|
|---|
| 790 |
|
|---|
| 791 | if(cs->style & WS_CHILD)
|
|---|
| 792 | {
|
|---|
| 793 | if(cs->cx < 0) cs->cx = 0;
|
|---|
| 794 | if(cs->cy < 0) cs->cy = 0;
|
|---|
| 795 | }
|
|---|
| 796 | else
|
|---|
| 797 | {
|
|---|
| 798 | if (cs->cx <= 0) cs->cx = 1;
|
|---|
| 799 | if (cs->cy <= 0) cs->cy = 1;
|
|---|
| 800 | }
|
|---|
| 801 |
|
|---|
| 802 | //set client & window rectangles from CreateWindowEx CREATESTRUCT
|
|---|
| 803 | rectWindow.left = cs->x;
|
|---|
| 804 | rectWindow.right = cs->x+cs->cx;
|
|---|
| 805 | rectWindow.top = cs->y;
|
|---|
| 806 | rectWindow.bottom = cs->y+cs->cy;
|
|---|
| 807 | rectClient = rectWindow;
|
|---|
| 808 | OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
|
|---|
| 809 |
|
|---|
| 810 | /* Send the WM_CREATE message
|
|---|
| 811 | * Perhaps we shouldn't allow width/height changes as well.
|
|---|
| 812 | * See p327 in "Internals".
|
|---|
| 813 | */
|
|---|
| 814 | maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
|
|---|
| 815 |
|
|---|
| 816 | if(fTaskList) {
|
|---|
| 817 | hTaskList = OSLibWinAddToTaskList(OS2HwndFrame, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
|
|---|
| 818 | }
|
|---|
| 819 |
|
|---|
| 820 | localSend32 = (isUnicode) ? ::SendMessageW : ::SendMessageA;
|
|---|
| 821 |
|
|---|
| 822 | state = STATE_PRE_WMNCCREATE;
|
|---|
| 823 | if(localSend32(getWindowHandle(), WM_NCCREATE,0,(LPARAM)cs))
|
|---|
| 824 | {
|
|---|
| 825 | RECT tmpRect;
|
|---|
| 826 |
|
|---|
| 827 | //CB: recheck flags
|
|---|
| 828 | if (cs->style & (WS_POPUP | WS_CHILD))
|
|---|
| 829 | {
|
|---|
| 830 | fXDefault = FALSE;
|
|---|
| 831 | if (fCXDefault)
|
|---|
| 832 | {
|
|---|
| 833 | fCXDefault = FALSE;
|
|---|
| 834 | cs->cx = cs->cy = 0;
|
|---|
| 835 | rectWindow.right = rectWindow.left;
|
|---|
| 836 | rectWindow.bottom = rectWindow.top;
|
|---|
| 837 | }
|
|---|
| 838 | }
|
|---|
| 839 | tmpRect = rectWindow;
|
|---|
| 840 | state = STATE_POST_WMNCCREATE;
|
|---|
| 841 |
|
|---|
| 842 | //set the window size and update the client
|
|---|
| 843 | SetWindowPos(hwndLinkAfter, tmpRect.left, tmpRect.top, tmpRect.right-tmpRect.left, tmpRect.bottom-tmpRect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
|
|---|
| 844 |
|
|---|
| 845 | state = STATE_PRE_WMCREATE;
|
|---|
| 846 | if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE
|
|---|
| 847 | if( (localSend32(getWindowHandle(), WM_CREATE, 0, (LPARAM)cs )) != -1 )
|
|---|
| 848 | {
|
|---|
| 849 | state = STATE_POST_WMCREATE;
|
|---|
| 850 |
|
|---|
| 851 | if(!(flags & WIN_NEED_SIZE))
|
|---|
| 852 | {
|
|---|
| 853 | SendMessageA(getWindowHandle(), WM_SIZE, SIZE_RESTORED,
|
|---|
| 854 | MAKELONG(rectClient.right-rectClient.left,
|
|---|
| 855 | rectClient.bottom-rectClient.top));
|
|---|
| 856 |
|
|---|
| 857 | if(!::IsWindow(hwnd))
|
|---|
| 858 | {
|
|---|
| 859 | dprintf(("Createwindow: WM_SIZE destroyed window"));
|
|---|
| 860 | goto end;
|
|---|
| 861 | }
|
|---|
| 862 | SendMessageA(getWindowHandle(), WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
|
|---|
| 863 | if(!::IsWindow(hwnd))
|
|---|
| 864 | {
|
|---|
| 865 | dprintf(("Createwindow: WM_MOVE destroyed window"));
|
|---|
| 866 | goto end;
|
|---|
| 867 | }
|
|---|
| 868 | }
|
|---|
| 869 | if (getStyle() & (WS_MINIMIZE | WS_MAXIMIZE))
|
|---|
| 870 | {
|
|---|
| 871 | RECT newPos;
|
|---|
| 872 | UINT swFlag = (getStyle() & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
|
|---|
| 873 | setStyle(getStyle() & ~(WS_MAXIMIZE | WS_MINIMIZE));
|
|---|
| 874 | MinMaximize(swFlag, &newPos);
|
|---|
| 875 | swFlag = ((getStyle() & WS_CHILD) || GetActiveWindow()) ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
|
|---|
| 876 | : SWP_NOZORDER | SWP_FRAMECHANGED;
|
|---|
| 877 | SetWindowPos(0, newPos.left, newPos.top, newPos.right, newPos.bottom, swFlag);
|
|---|
| 878 | if(!::IsWindow(hwnd))
|
|---|
| 879 | {
|
|---|
| 880 | dprintf(("Createwindow: min/max destroyed window"));
|
|---|
| 881 | goto end;
|
|---|
| 882 | }
|
|---|
| 883 | }
|
|---|
| 884 |
|
|---|
| 885 | if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
|---|
| 886 | {
|
|---|
| 887 | /* Notify the parent window only */
|
|---|
| 888 | if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
|
|---|
| 889 | {
|
|---|
| 890 | SendMessageA(getParent()->getWindowHandle(), WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
|
|---|
| 891 | }
|
|---|
| 892 | if(!::IsWindow(hwnd))
|
|---|
| 893 | {
|
|---|
| 894 | dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
|
|---|
| 895 | goto end;
|
|---|
| 896 | }
|
|---|
| 897 | }
|
|---|
| 898 |
|
|---|
| 899 | if(cs->style & WS_VISIBLE) {
|
|---|
| 900 | dwStyle &= ~WS_VISIBLE;
|
|---|
| 901 | ShowWindow(sw);
|
|---|
| 902 | }
|
|---|
| 903 |
|
|---|
| 904 | /* Call WH_SHELL hook */
|
|---|
| 905 | if (!(getStyle() & WS_CHILD) && !owner)
|
|---|
| 906 | HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0);
|
|---|
| 907 |
|
|---|
| 908 | //Call custom Odin hook for window creation (for all windows)
|
|---|
| 909 | HOOK_CallOdinHookA(HODIN_WINDOWCREATED, hwnd, 0);
|
|---|
| 910 |
|
|---|
| 911 | SetLastError(0);
|
|---|
| 912 | return TRUE;
|
|---|
| 913 | }
|
|---|
| 914 | }
|
|---|
| 915 | dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
|
|---|
| 916 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 917 | end:
|
|---|
| 918 | return FALSE;
|
|---|
| 919 | }
|
|---|
| 920 | //******************************************************************************
|
|---|
| 921 | //******************************************************************************
|
|---|
| 922 | ULONG Win32BaseWindow::MsgQuit()
|
|---|
| 923 | {
|
|---|
| 924 | return SendMessageA(getWindowHandle(), WM_QUIT, 0, 0);
|
|---|
| 925 | }
|
|---|
| 926 | //******************************************************************************
|
|---|
| 927 | //******************************************************************************
|
|---|
| 928 | ULONG Win32BaseWindow::MsgClose()
|
|---|
| 929 | {
|
|---|
| 930 | return SendMessageA(getWindowHandle(), WM_CLOSE,0,0);
|
|---|
| 931 | }
|
|---|
| 932 | //******************************************************************************
|
|---|
| 933 | //******************************************************************************
|
|---|
| 934 | ULONG Win32BaseWindow::MsgDestroy()
|
|---|
| 935 | {
|
|---|
| 936 | ULONG rc;
|
|---|
| 937 | Win32BaseWindow *child;
|
|---|
| 938 | HWND hwnd = getWindowHandle();
|
|---|
| 939 |
|
|---|
| 940 | state = STATE_DESTROYED;
|
|---|
| 941 |
|
|---|
| 942 | if(fDestroyWindowCalled == FALSE)
|
|---|
| 943 | {//this window was destroyed because DestroyWindow was called for it's parent
|
|---|
| 944 | //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
|
|---|
| 945 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
|
|---|
| 946 | {
|
|---|
| 947 | if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
|
|---|
| 948 | {
|
|---|
| 949 | /* Notify the parent window only */
|
|---|
| 950 | SendMessageA(getParent()->getWindowHandle(), WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
|
|---|
| 951 | }
|
|---|
| 952 | //// else DebugInt3();
|
|---|
| 953 | }
|
|---|
| 954 | }
|
|---|
| 955 | SendMessageA(getWindowHandle(),WM_DESTROY, 0, 0);
|
|---|
| 956 | if(::IsWindow(hwnd) == FALSE) {
|
|---|
| 957 | //object already destroyed, so return immediately
|
|---|
| 958 | return 1;
|
|---|
| 959 | }
|
|---|
| 960 | SendMessageA(getWindowHandle(),WM_NCDESTROY, 0, 0);
|
|---|
| 961 |
|
|---|
| 962 | TIMER_KillTimerFromWindow(getWindowHandle());
|
|---|
| 963 |
|
|---|
| 964 | if(getRefCount() == 0 && getFirstChild() == NULL && state == STATE_CREATED) {
|
|---|
| 965 | delete this;
|
|---|
| 966 | }
|
|---|
| 967 | else {
|
|---|
| 968 | //make sure no message can ever arrive for this window again (PM or from other win32 windows)
|
|---|
| 969 | dprintf(("Mark window %x (%x) as deleted; refcount %d", getWindowHandle(), this, getRefCount()));
|
|---|
| 970 | markDeleted();
|
|---|
| 971 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
|
|---|
| 972 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
|
|---|
| 973 | if(Win32Hwnd) {
|
|---|
| 974 | HwFreeWindowHandle(Win32Hwnd);
|
|---|
| 975 | Win32Hwnd = 0;
|
|---|
| 976 | }
|
|---|
| 977 | }
|
|---|
| 978 | return 1;
|
|---|
| 979 | }
|
|---|
| 980 | //******************************************************************************
|
|---|
| 981 | //******************************************************************************
|
|---|
| 982 | ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
|
|---|
| 983 | {
|
|---|
| 984 | if(fEnable) {
|
|---|
| 985 | dwStyle &= ~WS_DISABLED;
|
|---|
| 986 | }
|
|---|
| 987 | else dwStyle |= WS_DISABLED;
|
|---|
| 988 |
|
|---|
| 989 | return SendMessageA(getWindowHandle(),WM_ENABLE, fEnable, 0);
|
|---|
| 990 | }
|
|---|
| 991 | //******************************************************************************
|
|---|
| 992 | //TODO: SW_PARENTCLOSING/OPENING flag (lParam)
|
|---|
| 993 | //******************************************************************************
|
|---|
| 994 | ULONG Win32BaseWindow::MsgShow(BOOL fShow)
|
|---|
| 995 | {
|
|---|
| 996 | if(!CanReceiveSizeMsgs() || fDestroyWindowCalled) {
|
|---|
| 997 | return 1;
|
|---|
| 998 | }
|
|---|
| 999 |
|
|---|
| 1000 | if(fShow) {
|
|---|
| 1001 | setStyle(getStyle() | WS_VISIBLE);
|
|---|
| 1002 | if(getStyle() & WS_MINIMIZE) {
|
|---|
| 1003 | return ShowWindow(SW_RESTORE);
|
|---|
| 1004 | }
|
|---|
| 1005 | }
|
|---|
| 1006 | else setStyle(getStyle() & ~WS_VISIBLE);
|
|---|
| 1007 |
|
|---|
| 1008 | //already sent from ShowWindow
|
|---|
| 1009 | //// return SendMessageA(getWindowHandle(),WM_SHOWWINDOW, fShow, 0);
|
|---|
| 1010 | return 0;
|
|---|
| 1011 | }
|
|---|
| 1012 | //******************************************************************************
|
|---|
| 1013 | //******************************************************************************
|
|---|
| 1014 | ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
|
|---|
| 1015 | {
|
|---|
| 1016 | //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
|
|---|
| 1017 | // a WM_WINDOWPOSCHANGED msg -> crash)
|
|---|
| 1018 | if(!CanReceiveSizeMsgs() || fDestroyWindowCalled)
|
|---|
| 1019 | return 0;
|
|---|
| 1020 |
|
|---|
| 1021 | return SendMessageA(getWindowHandle(),WM_WINDOWPOSCHANGING, 0, lp);
|
|---|
| 1022 | }
|
|---|
| 1023 | //******************************************************************************
|
|---|
| 1024 | //******************************************************************************
|
|---|
| 1025 | ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
|
|---|
| 1026 | {
|
|---|
| 1027 | //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
|
|---|
| 1028 | // a WM_WINDOWPOSCHANGED msg -> crash)
|
|---|
| 1029 | if(!CanReceiveSizeMsgs() || fDestroyWindowCalled)
|
|---|
| 1030 | return 1;
|
|---|
| 1031 |
|
|---|
| 1032 | return SendMessageA(getWindowHandle(),WM_WINDOWPOSCHANGED, 0, lp);
|
|---|
| 1033 | }
|
|---|
| 1034 | //******************************************************************************
|
|---|
| 1035 | //******************************************************************************
|
|---|
| 1036 | ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
|
|---|
| 1037 | {
|
|---|
| 1038 | //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
|
|---|
| 1039 | //window scrollbars send these messages
|
|---|
| 1040 | return SendMessageA(getWindowHandle(),msg, MAKELONG(scrollCode, scrollPos), 0);
|
|---|
| 1041 | }
|
|---|
| 1042 | //******************************************************************************
|
|---|
| 1043 | //******************************************************************************
|
|---|
| 1044 | ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win)
|
|---|
| 1045 | {
|
|---|
| 1046 | ULONG rc, procidhwnd = -1, threadidhwnd = 0;
|
|---|
| 1047 |
|
|---|
| 1048 | //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
|
|---|
| 1049 | if(fDestroyWindowCalled) {
|
|---|
| 1050 | return 0;
|
|---|
| 1051 | }
|
|---|
| 1052 |
|
|---|
| 1053 | //According to SDK docs, if app returns FALSE & window is being deactivated,
|
|---|
| 1054 | //default processing is cancelled
|
|---|
| 1055 | //TODO: According to Wine we should proceed anyway if window is sysmodal
|
|---|
| 1056 | if(SendMessageA(getWindowHandle(),WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
|
|---|
| 1057 | {
|
|---|
| 1058 | dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
|
|---|
| 1059 | return 0;
|
|---|
| 1060 | }
|
|---|
| 1061 | /* child windows get a WM_CHILDACTIVATE message */
|
|---|
| 1062 | if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
|
|---|
| 1063 | {
|
|---|
| 1064 | if(fActivate) {//WM_CHILDACTIVE is for activation only
|
|---|
| 1065 | SendMessageA(getWindowHandle(),WM_CHILDACTIVATE, 0, 0L);
|
|---|
| 1066 | }
|
|---|
| 1067 | return 0;
|
|---|
| 1068 | }
|
|---|
| 1069 |
|
|---|
| 1070 | return SendMessageA(getWindowHandle(),WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
|
|---|
| 1071 | }
|
|---|
| 1072 | //******************************************************************************
|
|---|
| 1073 | //******************************************************************************
|
|---|
| 1074 | ULONG Win32BaseWindow::MsgChildActivate(BOOL fActivate)
|
|---|
| 1075 | {
|
|---|
| 1076 | //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
|
|---|
| 1077 | if(fDestroyWindowCalled) {
|
|---|
| 1078 | return 0;
|
|---|
| 1079 | }
|
|---|
| 1080 |
|
|---|
| 1081 | //According to SDK docs, if app returns FALSE & window is being deactivated,
|
|---|
| 1082 | //default processing is cancelled
|
|---|
| 1083 | //TODO: According to Wine we should proceed anyway if window is sysmodal
|
|---|
| 1084 | if(SendMessageA(getWindowHandle(),WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
|
|---|
| 1085 | {
|
|---|
| 1086 | dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
|
|---|
| 1087 | return 0;
|
|---|
| 1088 | }
|
|---|
| 1089 | /* child windows get a WM_CHILDACTIVATE message */
|
|---|
| 1090 | if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
|
|---|
| 1091 | {
|
|---|
| 1092 | if(fActivate) {//WM_CHILDACTIVE is for activation only
|
|---|
| 1093 | SendMessageA(getWindowHandle(),WM_CHILDACTIVATE, 0, 0L);
|
|---|
| 1094 | }
|
|---|
| 1095 | return 0;
|
|---|
| 1096 | }
|
|---|
| 1097 | DebugInt3();
|
|---|
| 1098 | return 0;
|
|---|
| 1099 | }
|
|---|
| 1100 | //******************************************************************************
|
|---|
| 1101 | //******************************************************************************
|
|---|
| 1102 | ULONG Win32BaseWindow::DispatchMsgA(MSG *msg)
|
|---|
| 1103 | {
|
|---|
| 1104 | return SendMessageA(getWindowHandle(),msg->message, msg->wParam, msg->lParam);
|
|---|
| 1105 | }
|
|---|
| 1106 | //******************************************************************************
|
|---|
| 1107 | //******************************************************************************
|
|---|
| 1108 | ULONG Win32BaseWindow::DispatchMsgW(MSG *msg)
|
|---|
| 1109 | {
|
|---|
| 1110 | return SendMessageW(getWindowHandle(), msg->message, msg->wParam, msg->lParam);
|
|---|
| 1111 | }
|
|---|
| 1112 | //******************************************************************************
|
|---|
| 1113 | //******************************************************************************
|
|---|
| 1114 | ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
|
|---|
| 1115 | {
|
|---|
| 1116 | //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
|
|---|
| 1117 | if(fDestroyWindowCalled) {
|
|---|
| 1118 | return 0;
|
|---|
| 1119 | }
|
|---|
| 1120 |
|
|---|
| 1121 | return SendMessageA(getWindowHandle(),WM_SETFOCUS, hwnd, 0);
|
|---|
| 1122 | }
|
|---|
| 1123 | //******************************************************************************
|
|---|
| 1124 | //******************************************************************************
|
|---|
| 1125 | ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
|
|---|
| 1126 | {
|
|---|
| 1127 | //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
|
|---|
| 1128 | if(fDestroyWindowCalled) {
|
|---|
| 1129 | return 0;
|
|---|
| 1130 | }
|
|---|
| 1131 | return SendMessageA(getWindowHandle(),WM_KILLFOCUS, hwnd, 0);
|
|---|
| 1132 | }
|
|---|
| 1133 | //******************************************************************************
|
|---|
| 1134 | //******************************************************************************
|
|---|
| 1135 | ULONG Win32BaseWindow::MsgButton(MSG *msg)
|
|---|
| 1136 | {
|
|---|
| 1137 | BOOL fClick = FALSE;
|
|---|
| 1138 |
|
|---|
| 1139 | dprintf(("MsgButton %d at (%d,%d)", msg->message, msg->pt.x, msg->pt.y));
|
|---|
| 1140 | switch(msg->message)
|
|---|
| 1141 | {
|
|---|
| 1142 | case WM_LBUTTONDBLCLK:
|
|---|
| 1143 | case WM_RBUTTONDBLCLK:
|
|---|
| 1144 | case WM_MBUTTONDBLCLK:
|
|---|
| 1145 | if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS))
|
|---|
| 1146 | {
|
|---|
| 1147 | msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
|
|---|
| 1148 | return MsgButton(msg);
|
|---|
| 1149 | }
|
|---|
| 1150 | break;
|
|---|
| 1151 | case WM_NCLBUTTONDBLCLK:
|
|---|
| 1152 | case WM_NCRBUTTONDBLCLK:
|
|---|
| 1153 | case WM_NCMBUTTONDBLCLK:
|
|---|
| 1154 | //Docs say CS_DBLCLKS style doesn't matter for non-client double clicks
|
|---|
| 1155 | fClick = TRUE;
|
|---|
| 1156 | break;
|
|---|
| 1157 |
|
|---|
| 1158 | case WM_LBUTTONDOWN:
|
|---|
| 1159 | case WM_RBUTTONDOWN:
|
|---|
| 1160 | case WM_MBUTTONDOWN:
|
|---|
| 1161 | case WM_NCLBUTTONDOWN:
|
|---|
| 1162 | case WM_NCRBUTTONDOWN:
|
|---|
| 1163 | case WM_NCMBUTTONDOWN:
|
|---|
| 1164 | fClick = TRUE;
|
|---|
| 1165 | break;
|
|---|
| 1166 | }
|
|---|
| 1167 |
|
|---|
| 1168 | if(fClick)
|
|---|
| 1169 | {
|
|---|
| 1170 | HWND hwndTop;
|
|---|
| 1171 |
|
|---|
| 1172 | /* Activate the window if needed */
|
|---|
| 1173 | hwndTop = GetTopParent();
|
|---|
| 1174 |
|
|---|
| 1175 | HWND hwndActive = GetActiveWindow();
|
|---|
| 1176 | if (hwndTop && (getWindowHandle() != hwndActive))
|
|---|
| 1177 | {
|
|---|
| 1178 | LONG ret = SendMessageA(getWindowHandle(),WM_MOUSEACTIVATE, hwndTop,
|
|---|
| 1179 | MAKELONG( lastHitTestVal, msg->message) );
|
|---|
| 1180 |
|
|---|
| 1181 | dprintf2(("WM_MOUSEACTIVATE returned %d", ret));
|
|---|
| 1182 | #if 0
|
|---|
| 1183 | if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
|
|---|
| 1184 | eatMsg = TRUE;
|
|---|
| 1185 | #endif
|
|---|
| 1186 | //SvL: 0 is not documented, but experiments in NT4 show that
|
|---|
| 1187 | // the window will get activated when it returns this.
|
|---|
| 1188 | // (FreeCell is an example)
|
|---|
| 1189 | if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT) || (ret == 0))
|
|---|
| 1190 | && (hwndTop != GetForegroundWindow()) )
|
|---|
| 1191 | {
|
|---|
| 1192 | Win32BaseWindow *win32top = Win32BaseWindow::GetWindowFromHandle(hwndTop);
|
|---|
| 1193 |
|
|---|
| 1194 | //SvL: Calling OSLibSetActiveWindow(hwndTop); causes focus problems
|
|---|
| 1195 | if (win32top) {
|
|---|
| 1196 | OSLibWinSetFocus(win32top->getOS2FrameWindowHandle());
|
|---|
| 1197 | RELEASE_WNDOBJ(win32top);
|
|---|
| 1198 | }
|
|---|
| 1199 | }
|
|---|
| 1200 | }
|
|---|
| 1201 | }
|
|---|
| 1202 |
|
|---|
| 1203 | SendMessageA(getWindowHandle(),WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
|
|---|
| 1204 |
|
|---|
| 1205 | switch(msg->message)
|
|---|
| 1206 | {
|
|---|
| 1207 | case WM_LBUTTONDOWN:
|
|---|
| 1208 | case WM_MBUTTONDOWN:
|
|---|
| 1209 | case WM_RBUTTONDOWN:
|
|---|
| 1210 | {
|
|---|
| 1211 | if (getParent())
|
|---|
| 1212 | {
|
|---|
| 1213 | POINTS pt = MAKEPOINTS(msg->lParam);
|
|---|
| 1214 | POINT point;
|
|---|
| 1215 |
|
|---|
| 1216 | point.x = pt.x;
|
|---|
| 1217 | point.y = pt.y;
|
|---|
| 1218 | MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), &point, 1);
|
|---|
| 1219 | NotifyParent(msg->message, msg->wParam, MAKELPARAM(point.x,point.y));
|
|---|
| 1220 | }
|
|---|
| 1221 | break;
|
|---|
| 1222 | }
|
|---|
| 1223 | }
|
|---|
| 1224 | return SendMessageA(getWindowHandle(),msg->message, msg->wParam, msg->lParam);
|
|---|
| 1225 | }
|
|---|
| 1226 | //******************************************************************************
|
|---|
| 1227 | //******************************************************************************
|
|---|
| 1228 | ULONG Win32BaseWindow::MsgPaint(ULONG tmp, ULONG select)
|
|---|
| 1229 | {
|
|---|
| 1230 | if (select && IsWindowIconic())
|
|---|
| 1231 | return SendMessageA(getWindowHandle(),WM_PAINTICON, 1, 0);
|
|---|
| 1232 | else
|
|---|
| 1233 | return SendMessageA(getWindowHandle(),WM_PAINT, 0, 0);
|
|---|
| 1234 | }
|
|---|
| 1235 | //******************************************************************************
|
|---|
| 1236 | //TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
|
|---|
| 1237 | // (or are we simply erasing too much here)
|
|---|
| 1238 | //******************************************************************************
|
|---|
| 1239 | ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
|
|---|
| 1240 | {
|
|---|
| 1241 | ULONG rc;
|
|---|
| 1242 | HDC hdcErase = hdc;
|
|---|
| 1243 |
|
|---|
| 1244 | if (hdcErase == 0)
|
|---|
| 1245 | hdcErase = GetDC(getWindowHandle());
|
|---|
| 1246 |
|
|---|
| 1247 | if(IsWindowIconic())
|
|---|
| 1248 | rc = SendMessageA(getWindowHandle(),WM_ICONERASEBKGND, hdcErase, 0);
|
|---|
| 1249 | else
|
|---|
| 1250 | rc = SendMessageA(getWindowHandle(),WM_ERASEBKGND, hdcErase, 0);
|
|---|
| 1251 | if (hdc == 0)
|
|---|
| 1252 | ReleaseDC(getWindowHandle(), hdcErase);
|
|---|
| 1253 | return (rc);
|
|---|
| 1254 | }
|
|---|
| 1255 | //******************************************************************************
|
|---|
| 1256 | //******************************************************************************
|
|---|
| 1257 | ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
|
|---|
| 1258 | {
|
|---|
| 1259 | //TODO: hiword should be 0 if window enters menu mode (SDK docs)
|
|---|
| 1260 | //SDK: WM_SETCURSOR is not sent if the mouse is captured
|
|---|
| 1261 | if(GetCapture() == 0) {
|
|---|
| 1262 | SendMessageA(getWindowHandle(),WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
|
|---|
| 1263 | }
|
|---|
| 1264 |
|
|---|
| 1265 | //translated message == WM_(NC)MOUSEMOVE
|
|---|
| 1266 | return SendMessageA(getWindowHandle(),msg->message, msg->wParam, msg->lParam);
|
|---|
| 1267 | }
|
|---|
| 1268 | //******************************************************************************
|
|---|
| 1269 | //******************************************************************************
|
|---|
| 1270 | ULONG Win32BaseWindow::MsgChar(MSG *msg)
|
|---|
| 1271 | {
|
|---|
| 1272 | return DispatchMsgA(msg);
|
|---|
| 1273 | }
|
|---|
| 1274 | //******************************************************************************
|
|---|
| 1275 | //TODO: Should use update region, not rectangle
|
|---|
| 1276 | //******************************************************************************
|
|---|
| 1277 | ULONG Win32BaseWindow::MsgNCPaint(PRECT pUpdateRect)
|
|---|
| 1278 | {
|
|---|
| 1279 | HRGN hrgn;
|
|---|
| 1280 | ULONG rc;
|
|---|
| 1281 | RECT client = rectClient;
|
|---|
| 1282 |
|
|---|
| 1283 | if ((pUpdateRect->left >= client.left) && (pUpdateRect->left < client.right) &&
|
|---|
| 1284 | (pUpdateRect->right >= client.left) && (pUpdateRect->right < client.right) &&
|
|---|
| 1285 | (pUpdateRect->top >= client.top) && (pUpdateRect->top < client.bottom) &&
|
|---|
| 1286 | (pUpdateRect->bottom >= client.top) && (pUpdateRect->bottom < client.bottom)
|
|---|
| 1287 | && (!(getStyle() & WS_MINIMIZE)))
|
|---|
| 1288 | {
|
|---|
| 1289 | return 0;
|
|---|
| 1290 | }
|
|---|
| 1291 |
|
|---|
| 1292 | dprintf(("MsgNCPaint (%d,%d)(%d,%d)", pUpdateRect->left, pUpdateRect->top, pUpdateRect->right, pUpdateRect->bottom));
|
|---|
| 1293 | hrgn = CreateRectRgnIndirect(pUpdateRect);
|
|---|
| 1294 |
|
|---|
| 1295 | rc = SendMessageA(getWindowHandle(),WM_NCPAINT, hrgn, 0);
|
|---|
| 1296 | //Send WM_PAINTICON here if minimized, because client window will
|
|---|
| 1297 | //not receive a (valid) WM_PAINT message
|
|---|
| 1298 | if (getStyle() & WS_MINIMIZE)
|
|---|
| 1299 | {
|
|---|
| 1300 | rc = SendMessageA(getWindowHandle(),WM_PAINTICON, 1, 0);
|
|---|
| 1301 | }
|
|---|
| 1302 |
|
|---|
| 1303 | DeleteObject(hrgn);
|
|---|
| 1304 |
|
|---|
| 1305 | return rc;
|
|---|
| 1306 | }
|
|---|
| 1307 | //******************************************************************************
|
|---|
| 1308 | //Called when either the frame's size or position has changed (lpWndPos != NULL)
|
|---|
| 1309 | //or when the frame layout has changed (i.e. scrollbars added/removed) (lpWndPos == NULL)
|
|---|
| 1310 | //******************************************************************************
|
|---|
| 1311 | ULONG Win32BaseWindow::MsgFormatFrame(WINDOWPOS *lpWndPos)
|
|---|
| 1312 | {
|
|---|
| 1313 | RECT oldWindowRect = rectWindow, client = rectClient, newWindowRect;
|
|---|
| 1314 | RECT newClientRect;
|
|---|
| 1315 | WINDOWPOS wndPos;
|
|---|
| 1316 | ULONG rc;
|
|---|
| 1317 |
|
|---|
| 1318 | if(lpWndPos)
|
|---|
| 1319 | {
|
|---|
| 1320 | //set new window rectangle
|
|---|
| 1321 | setWindowRect(lpWndPos->x, lpWndPos->y, lpWndPos->x+lpWndPos->cx,
|
|---|
| 1322 | lpWndPos->y+lpWndPos->cy);
|
|---|
| 1323 | newWindowRect = rectWindow;
|
|---|
| 1324 | }
|
|---|
| 1325 | else {
|
|---|
| 1326 | wndPos.hwnd = getWindowHandle();
|
|---|
| 1327 | wndPos.hwndInsertAfter = 0;
|
|---|
| 1328 | newWindowRect= rectWindow;
|
|---|
| 1329 | wndPos.x = newWindowRect.left;
|
|---|
| 1330 | wndPos.y = newWindowRect.top;
|
|---|
| 1331 | wndPos.cx = newWindowRect.right - newWindowRect.left;
|
|---|
| 1332 | wndPos.cy = newWindowRect.bottom - newWindowRect.top;
|
|---|
| 1333 | wndPos.flags = SWP_FRAMECHANGED;
|
|---|
| 1334 | lpWndPos = &wndPos;
|
|---|
| 1335 | }
|
|---|
| 1336 |
|
|---|
| 1337 | newClientRect = rectClient;
|
|---|
| 1338 | rc = SendNCCalcSize(TRUE, &newWindowRect, &oldWindowRect, &client, lpWndPos, &newClientRect);
|
|---|
| 1339 | rectClient = newClientRect; //must update rectClient here
|
|---|
| 1340 |
|
|---|
| 1341 | 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));
|
|---|
| 1342 | dprintf(("MsgFormatFrame: old window rect (%d,%d)(%d,%d), new window (%d,%d)(%d,%d)", oldWindowRect.left, oldWindowRect.top, oldWindowRect.right, oldWindowRect.bottom, rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
|
|---|
| 1343 |
|
|---|
| 1344 | if(!CanReceiveSizeMsgs() || !EqualRect(&client, &rectClient)) {
|
|---|
| 1345 | OSLibWinSetClientPos(getOS2WindowHandle(), rectClient.left, rectClient.top, getClientWidth(), getClientHeight(), getWindowHeight());
|
|---|
| 1346 | }
|
|---|
| 1347 |
|
|---|
| 1348 | #if 1
|
|---|
| 1349 | //this doesn't always work
|
|---|
| 1350 | // if(CanReceiveSizeMsgs() && (client.left != rectClient.left || client.top != rectClient.top))
|
|---|
| 1351 | if(CanReceiveSizeMsgs() && ((oldWindowRect.right - oldWindowRect.left < rectClient.left
|
|---|
| 1352 | || oldWindowRect.bottom - oldWindowRect.top < rectClient.top) ||
|
|---|
| 1353 | (EqualRect(&oldWindowRect, &rectWindow) && (client.left != rectClient.left || client.top != rectClient.top))))
|
|---|
| 1354 | {
|
|---|
| 1355 | Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild();
|
|---|
| 1356 |
|
|---|
| 1357 | //client rectangle has moved -> inform children
|
|---|
| 1358 | dprintf(("MsgFormatFrame -> client rectangle has changed, move children"));
|
|---|
| 1359 | while(child) {
|
|---|
| 1360 | ::SetWindowPos(child->getWindowHandle(),
|
|---|
| 1361 | HWND_TOP, child->getWindowRect()->left,
|
|---|
| 1362 | child->getWindowRect()->top, 0, 0,
|
|---|
| 1363 | SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
|
|---|
| 1364 | child = (Win32BaseWindow *)child->getNextChild();
|
|---|
| 1365 | }
|
|---|
| 1366 | }
|
|---|
| 1367 | #endif
|
|---|
| 1368 | if(fOS2Look && ((dwStyle & WS_CAPTION) == WS_CAPTION))
|
|---|
| 1369 | {
|
|---|
| 1370 | RECT rect = {0};
|
|---|
| 1371 | int height = getWindowHeight();
|
|---|
| 1372 | RECTLOS2 rectOS2;
|
|---|
| 1373 |
|
|---|
| 1374 | AdjustRectOuter(&rect, FALSE);
|
|---|
| 1375 |
|
|---|
| 1376 | rect.left = -rect.left;
|
|---|
| 1377 | rect.top = rect.bottom - rect.top;
|
|---|
| 1378 | rect.right = rectWindow.right - rectWindow.left - rect.right;
|
|---|
| 1379 |
|
|---|
| 1380 | rectOS2.xLeft = rect.left;
|
|---|
| 1381 | rectOS2.xRight = rect.right;
|
|---|
| 1382 | rectOS2.yBottom = height - rect.top;
|
|---|
| 1383 | rectOS2.yTop = height - rect.bottom;
|
|---|
| 1384 | OSLibWinPositionFrameControls(getOS2FrameWindowHandle(), &rectOS2, dwStyle, dwExStyle, IconForWindow(ICON_SMALL));
|
|---|
| 1385 | }
|
|---|
| 1386 | return rc;
|
|---|
| 1387 | }
|
|---|
| 1388 | //******************************************************************************
|
|---|
| 1389 | //******************************************************************************
|
|---|
| 1390 | ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
|
|---|
| 1391 | {
|
|---|
| 1392 | return SendMessageA(getWindowHandle(),WM_SETTEXT, 0, (LPARAM)lpsz);
|
|---|
| 1393 | }
|
|---|
| 1394 | //******************************************************************************
|
|---|
| 1395 | //******************************************************************************
|
|---|
| 1396 | ULONG Win32BaseWindow::MsgGetTextLength()
|
|---|
| 1397 | {
|
|---|
| 1398 | return SendMessageA(getWindowHandle(),WM_GETTEXTLENGTH, 0, 0);
|
|---|
| 1399 | }
|
|---|
| 1400 | //******************************************************************************
|
|---|
| 1401 | //******************************************************************************
|
|---|
| 1402 | void Win32BaseWindow::MsgGetText(char *wndtext, ULONG textlength)
|
|---|
| 1403 | {
|
|---|
| 1404 | SendMessageA(getWindowHandle(),WM_GETTEXT, textlength, (LPARAM)wndtext);
|
|---|
| 1405 | }
|
|---|
| 1406 | //******************************************************************************
|
|---|
| 1407 | //******************************************************************************
|
|---|
| 1408 | BOOL Win32BaseWindow::isMDIClient()
|
|---|
| 1409 | {
|
|---|
| 1410 | return FALSE;
|
|---|
| 1411 | }
|
|---|
| 1412 | //******************************************************************************
|
|---|
| 1413 | //******************************************************************************
|
|---|
| 1414 | BOOL Win32BaseWindow::isMDIChild()
|
|---|
| 1415 | {
|
|---|
| 1416 | return FALSE;
|
|---|
| 1417 | }
|
|---|
| 1418 | //******************************************************************************
|
|---|
| 1419 | //TODO: Not complete
|
|---|
| 1420 | //******************************************************************************
|
|---|
| 1421 | BOOL Win32BaseWindow::isFrameWindow()
|
|---|
| 1422 | {
|
|---|
| 1423 | if(getParent() == NULL)
|
|---|
| 1424 | return TRUE;
|
|---|
| 1425 |
|
|---|
| 1426 | return FALSE;
|
|---|
| 1427 | }
|
|---|
| 1428 | //******************************************************************************
|
|---|
| 1429 | //******************************************************************************
|
|---|
| 1430 | BOOL Win32BaseWindow::isDesktopWindow()
|
|---|
| 1431 | {
|
|---|
| 1432 | return FALSE;
|
|---|
| 1433 | }
|
|---|
| 1434 | //******************************************************************************
|
|---|
| 1435 | //******************************************************************************
|
|---|
| 1436 | BOOL Win32BaseWindow::IsWindowIconic()
|
|---|
| 1437 | {
|
|---|
| 1438 | return ((getStyle() & WS_MINIMIZE) && windowClass->getIcon());
|
|---|
| 1439 | }
|
|---|
| 1440 | //******************************************************************************
|
|---|
| 1441 | //******************************************************************************
|
|---|
| 1442 | SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
|
|---|
| 1443 | {
|
|---|
| 1444 | switch(nBar)
|
|---|
| 1445 | {
|
|---|
| 1446 | case SB_HORZ:
|
|---|
| 1447 | if (!horzScrollInfo)
|
|---|
| 1448 | {
|
|---|
| 1449 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
|---|
| 1450 | if (!horzScrollInfo) break;
|
|---|
| 1451 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
|
|---|
| 1452 | horzScrollInfo->MaxVal = 100;
|
|---|
| 1453 | horzScrollInfo->flags = ESB_ENABLE_BOTH;
|
|---|
| 1454 | }
|
|---|
| 1455 | return horzScrollInfo;
|
|---|
| 1456 |
|
|---|
| 1457 | case SB_VERT:
|
|---|
| 1458 | if (!vertScrollInfo)
|
|---|
| 1459 | {
|
|---|
| 1460 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
|---|
| 1461 | if (!vertScrollInfo) break;
|
|---|
| 1462 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
|
|---|
| 1463 | vertScrollInfo->MaxVal = 100;
|
|---|
| 1464 | vertScrollInfo->flags = ESB_ENABLE_BOTH;
|
|---|
| 1465 | }
|
|---|
| 1466 | return vertScrollInfo;
|
|---|
| 1467 | }
|
|---|
| 1468 |
|
|---|
| 1469 | return NULL;
|
|---|
| 1470 | }
|
|---|
| 1471 | //******************************************************************************
|
|---|
| 1472 | //******************************************************************************
|
|---|
| 1473 | LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
|
|---|
| 1474 | {
|
|---|
| 1475 | //SvL: Set background color to default button color (not window (white))
|
|---|
| 1476 | if(ctlType == CTLCOLOR_BTN)
|
|---|
| 1477 | {
|
|---|
| 1478 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
|---|
| 1479 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
|---|
| 1480 | return GetSysColorBrush(COLOR_BTNFACE);
|
|---|
| 1481 | }
|
|---|
| 1482 | //SvL: Set background color to default dialog color if window is dialog
|
|---|
| 1483 | if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
|
|---|
| 1484 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
|---|
| 1485 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
|---|
| 1486 | return GetSysColorBrush(COLOR_BTNFACE);
|
|---|
| 1487 | }
|
|---|
| 1488 | if( ctlType == CTLCOLOR_SCROLLBAR)
|
|---|
| 1489 | {
|
|---|
| 1490 | HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
|
|---|
| 1491 | COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
|
|---|
| 1492 | SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
|
|---|
| 1493 | SetBkColor( hdc, bk);
|
|---|
| 1494 |
|
|---|
| 1495 | /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
|
|---|
| 1496 | * we better use 0x55aa bitmap brush to make scrollbar's background
|
|---|
| 1497 | * look different from the window background.
|
|---|
| 1498 | */
|
|---|
| 1499 | if (bk == GetSysColor(COLOR_WINDOW)) {
|
|---|
| 1500 | return GetPattern55AABrush();
|
|---|
| 1501 | }
|
|---|
| 1502 |
|
|---|
| 1503 | UnrealizeObject( hb );
|
|---|
| 1504 | return (LRESULT)hb;
|
|---|
| 1505 | }
|
|---|
| 1506 |
|
|---|
| 1507 | SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
|
|---|
| 1508 |
|
|---|
| 1509 | if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
|
|---|
| 1510 | {
|
|---|
| 1511 | SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
|
|---|
| 1512 | }
|
|---|
| 1513 | else
|
|---|
| 1514 | {
|
|---|
| 1515 | SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
|
|---|
| 1516 | return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
|
|---|
| 1517 | }
|
|---|
| 1518 | return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
|
|---|
| 1519 | }
|
|---|
| 1520 | //******************************************************************************
|
|---|
| 1521 | //******************************************************************************
|
|---|
| 1522 | LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags)
|
|---|
| 1523 | {
|
|---|
| 1524 | /*
|
|---|
| 1525 | * Visibility flag.
|
|---|
| 1526 | */
|
|---|
| 1527 | if ( (uFlags & PRF_CHECKVISIBLE) &&
|
|---|
| 1528 | !IsWindowVisible(getWindowHandle()) )
|
|---|
| 1529 | return 0;
|
|---|
| 1530 |
|
|---|
| 1531 | /*
|
|---|
| 1532 | * Unimplemented flags.
|
|---|
| 1533 | */
|
|---|
| 1534 | if ( (uFlags & PRF_CHILDREN) ||
|
|---|
| 1535 | (uFlags & PRF_OWNED) ||
|
|---|
| 1536 | (uFlags & PRF_NONCLIENT) )
|
|---|
| 1537 | {
|
|---|
| 1538 | dprintf(("WM_PRINT message with unsupported flags\n"));
|
|---|
| 1539 | }
|
|---|
| 1540 |
|
|---|
| 1541 | /*
|
|---|
| 1542 | * Background
|
|---|
| 1543 | */
|
|---|
| 1544 | if ( uFlags & PRF_ERASEBKGND)
|
|---|
| 1545 | SendMessageA(getWindowHandle(),WM_ERASEBKGND, (WPARAM)hdc, 0);
|
|---|
| 1546 |
|
|---|
| 1547 | /*
|
|---|
| 1548 | * Client area
|
|---|
| 1549 | */
|
|---|
| 1550 | if ( uFlags & PRF_CLIENT)
|
|---|
| 1551 | SendMessageA(getWindowHandle(),WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
|
|---|
| 1552 |
|
|---|
| 1553 |
|
|---|
| 1554 | return 0;
|
|---|
| 1555 | }
|
|---|
| 1556 | //******************************************************************************
|
|---|
| 1557 | //******************************************************************************
|
|---|
| 1558 | LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1559 | {
|
|---|
| 1560 | switch(Msg)
|
|---|
| 1561 | {
|
|---|
| 1562 | case WM_CLOSE:
|
|---|
| 1563 | dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
|
|---|
| 1564 | DestroyWindow();
|
|---|
| 1565 | return 0;
|
|---|
| 1566 |
|
|---|
| 1567 | case WM_GETTEXTLENGTH:
|
|---|
| 1568 | return windowNameLength;
|
|---|
| 1569 |
|
|---|
| 1570 | case WM_GETTEXT:
|
|---|
| 1571 | if (!lParam || !wParam)
|
|---|
| 1572 | return 0;
|
|---|
| 1573 | if (!windowNameA)
|
|---|
| 1574 | ((LPSTR)lParam)[0] = 0;
|
|---|
| 1575 | else
|
|---|
| 1576 | memcpy((LPSTR)lParam, windowNameA, min(windowNameLength+1, wParam) );
|
|---|
| 1577 | return min(windowNameLength, wParam);
|
|---|
| 1578 |
|
|---|
| 1579 | case WM_SETTEXT:
|
|---|
| 1580 | {
|
|---|
| 1581 | LPCSTR lpsz = (LPCSTR)lParam;
|
|---|
| 1582 |
|
|---|
| 1583 | // reallocate if new buffer is larger
|
|---|
| 1584 | if (!lParam)
|
|---|
| 1585 | {
|
|---|
| 1586 | free(windowNameA);
|
|---|
| 1587 | free(windowNameW);
|
|---|
| 1588 | windowNameLength = 0;
|
|---|
| 1589 | windowNameA = NULL;
|
|---|
| 1590 | windowNameW = NULL;
|
|---|
| 1591 | }
|
|---|
| 1592 | else
|
|---|
| 1593 | {
|
|---|
| 1594 | // determine length of new text
|
|---|
| 1595 | int iTextLength = strlen(lpsz);
|
|---|
| 1596 |
|
|---|
| 1597 | if (windowNameLength < iTextLength)
|
|---|
| 1598 | {
|
|---|
| 1599 | if (windowNameA)
|
|---|
| 1600 | {
|
|---|
| 1601 | free(windowNameA);
|
|---|
| 1602 | windowNameA = NULL;
|
|---|
| 1603 | }
|
|---|
| 1604 |
|
|---|
| 1605 | if (windowNameW)
|
|---|
| 1606 | {
|
|---|
| 1607 | free(windowNameW);
|
|---|
| 1608 | windowNameW = NULL;
|
|---|
| 1609 | }
|
|---|
| 1610 | }
|
|---|
| 1611 |
|
|---|
| 1612 | windowNameLength = iTextLength;
|
|---|
| 1613 | if(!windowNameA)
|
|---|
| 1614 | windowNameA = (LPSTR)_smalloc(windowNameLength+1);
|
|---|
| 1615 | memcpy(windowNameA, lpsz, windowNameLength+1);
|
|---|
| 1616 | if(!windowNameW)
|
|---|
| 1617 | windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
|
|---|
| 1618 | lstrcpynAtoW(windowNameW, windowNameA, windowNameLength+1);
|
|---|
| 1619 | }
|
|---|
| 1620 |
|
|---|
| 1621 | dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
|
|---|
| 1622 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
|---|
| 1623 | {
|
|---|
| 1624 | HandleNCPaint((HRGN)1);
|
|---|
| 1625 | if(hTaskList) {
|
|---|
| 1626 | OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
|
|---|
| 1627 | }
|
|---|
| 1628 | if(fOS2Look) {
|
|---|
| 1629 | OSLibWinSetTitleBarText(OS2HwndFrame, getWindowNameA());
|
|---|
| 1630 | }
|
|---|
| 1631 | }
|
|---|
| 1632 |
|
|---|
| 1633 | return TRUE;
|
|---|
| 1634 | }
|
|---|
| 1635 |
|
|---|
| 1636 | case WM_SETREDRAW:
|
|---|
| 1637 | {
|
|---|
| 1638 | if (wParam)
|
|---|
| 1639 | {
|
|---|
| 1640 | setStyle(getStyle() | WS_VISIBLE);
|
|---|
| 1641 | dprintf(("Enable window update for %x", getWindowHandle()));
|
|---|
| 1642 | OSLibWinEnableWindowUpdate(OS2HwndFrame, OS2Hwnd, TRUE);
|
|---|
| 1643 | }
|
|---|
| 1644 | else
|
|---|
| 1645 | {
|
|---|
| 1646 | if (getStyle() & WS_VISIBLE)
|
|---|
| 1647 | {
|
|---|
| 1648 | setStyle(getStyle() & ~WS_VISIBLE);
|
|---|
| 1649 | dprintf(("Disable window update for %x", getWindowHandle()));
|
|---|
| 1650 | OSLibWinEnableWindowUpdate(OS2HwndFrame, OS2Hwnd, FALSE);
|
|---|
| 1651 | }
|
|---|
| 1652 | }
|
|---|
| 1653 | return 0;
|
|---|
| 1654 | }
|
|---|
| 1655 |
|
|---|
| 1656 | case WM_CTLCOLORMSGBOX:
|
|---|
| 1657 | case WM_CTLCOLOREDIT:
|
|---|
| 1658 | case WM_CTLCOLORLISTBOX:
|
|---|
| 1659 | case WM_CTLCOLORBTN:
|
|---|
| 1660 | case WM_CTLCOLORDLG:
|
|---|
| 1661 | case WM_CTLCOLORSTATIC:
|
|---|
| 1662 | case WM_CTLCOLORSCROLLBAR:
|
|---|
| 1663 | return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
|
|---|
| 1664 |
|
|---|
| 1665 | case WM_CTLCOLOR:
|
|---|
| 1666 | return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
|
|---|
| 1667 |
|
|---|
| 1668 | case WM_VKEYTOITEM:
|
|---|
| 1669 | case WM_CHARTOITEM:
|
|---|
| 1670 | return -1;
|
|---|
| 1671 |
|
|---|
| 1672 | case WM_PARENTNOTIFY:
|
|---|
| 1673 | return 0;
|
|---|
| 1674 |
|
|---|
| 1675 | case WM_MOUSEACTIVATE:
|
|---|
| 1676 | {
|
|---|
| 1677 | dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
|
|---|
| 1678 | if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
|---|
| 1679 | {
|
|---|
| 1680 | if(getParent()) {
|
|---|
| 1681 | LRESULT rc = SendMessageA(getParent()->getWindowHandle(), WM_MOUSEACTIVATE, wParam, lParam );
|
|---|
| 1682 | if(rc) return rc;
|
|---|
| 1683 | }
|
|---|
| 1684 | }
|
|---|
| 1685 | return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
|
|---|
| 1686 | }
|
|---|
| 1687 |
|
|---|
| 1688 | case WM_ACTIVATE:
|
|---|
| 1689 | /* The default action in Windows is to set the keyboard focus to
|
|---|
| 1690 | * the window, if it's being activated and not minimized */
|
|---|
| 1691 | if (LOWORD(wParam) != WA_INACTIVE) {
|
|---|
| 1692 | if(!(getStyle() & WS_MINIMIZE))
|
|---|
| 1693 | SetFocus(getWindowHandle());
|
|---|
| 1694 | }
|
|---|
| 1695 | return 0;
|
|---|
| 1696 |
|
|---|
| 1697 | case WM_SETCURSOR:
|
|---|
| 1698 | {
|
|---|
| 1699 | dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
|
|---|
| 1700 | if((getStyle() & WS_CHILD))
|
|---|
| 1701 | {
|
|---|
| 1702 | if(getParent()) {
|
|---|
| 1703 | LRESULT rc = SendMessageA(getParent()->getWindowHandle(), WM_SETCURSOR, wParam, lParam);
|
|---|
| 1704 | if(rc) return rc;
|
|---|
| 1705 | }
|
|---|
| 1706 | }
|
|---|
| 1707 | if (wParam == getWindowHandle())
|
|---|
| 1708 | {
|
|---|
| 1709 | HCURSOR hCursor;
|
|---|
| 1710 |
|
|---|
| 1711 | switch(LOWORD(lParam))
|
|---|
| 1712 | {
|
|---|
| 1713 | case HTCLIENT:
|
|---|
| 1714 | hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
|
|---|
| 1715 | break;
|
|---|
| 1716 |
|
|---|
| 1717 | case HTLEFT:
|
|---|
| 1718 | case HTRIGHT:
|
|---|
| 1719 | hCursor = LoadCursorA(0,IDC_SIZEWEA);
|
|---|
| 1720 | break;
|
|---|
| 1721 |
|
|---|
| 1722 | case HTTOP:
|
|---|
| 1723 | case HTBOTTOM:
|
|---|
| 1724 | hCursor = LoadCursorA(0,IDC_SIZENSA);
|
|---|
| 1725 | break;
|
|---|
| 1726 |
|
|---|
| 1727 | case HTTOPLEFT:
|
|---|
| 1728 | case HTBOTTOMRIGHT:
|
|---|
| 1729 | hCursor = LoadCursorA(0,IDC_SIZENWSEA);
|
|---|
| 1730 | break;
|
|---|
| 1731 |
|
|---|
| 1732 | case HTTOPRIGHT:
|
|---|
| 1733 | case HTBOTTOMLEFT:
|
|---|
| 1734 | hCursor = LoadCursorA(0,IDC_SIZENESWA);
|
|---|
| 1735 | break;
|
|---|
| 1736 |
|
|---|
| 1737 | default:
|
|---|
| 1738 | hCursor = LoadCursorA(0,IDC_ARROWA);
|
|---|
| 1739 | break;
|
|---|
| 1740 | }
|
|---|
| 1741 |
|
|---|
| 1742 | if (hCursor)
|
|---|
| 1743 | {
|
|---|
| 1744 | SetCursor(hCursor);
|
|---|
| 1745 | return 1;
|
|---|
| 1746 | }
|
|---|
| 1747 | else return 0;
|
|---|
| 1748 | }
|
|---|
| 1749 | else return 0;
|
|---|
| 1750 | }
|
|---|
| 1751 |
|
|---|
| 1752 | case WM_MOUSEMOVE:
|
|---|
| 1753 | return 0;
|
|---|
| 1754 |
|
|---|
| 1755 | case WM_WINDOWPOSCHANGED:
|
|---|
| 1756 | {
|
|---|
| 1757 | PWINDOWPOS wpos = (PWINDOWPOS)lParam;
|
|---|
| 1758 | WPARAM wp = SIZE_RESTORED;
|
|---|
| 1759 |
|
|---|
| 1760 | if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
|
|---|
| 1761 | {
|
|---|
| 1762 | SendMessageA(getWindowHandle(),WM_MOVE, 0, MAKELONG(rectClient.left,rectClient.top));
|
|---|
| 1763 | }
|
|---|
| 1764 | if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
|
|---|
| 1765 | {
|
|---|
| 1766 | if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
|
|---|
| 1767 | else
|
|---|
| 1768 | if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
|
|---|
| 1769 |
|
|---|
| 1770 | SendMessageA(getWindowHandle(),WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
|
|---|
| 1771 | rectClient.bottom - rectClient.top));
|
|---|
| 1772 | }
|
|---|
| 1773 | return 0;
|
|---|
| 1774 | }
|
|---|
| 1775 | case WM_WINDOWPOSCHANGING:
|
|---|
| 1776 | return HandleWindowPosChanging((WINDOWPOS *)lParam);
|
|---|
| 1777 |
|
|---|
| 1778 | case WM_ERASEBKGND:
|
|---|
| 1779 | case WM_ICONERASEBKGND:
|
|---|
| 1780 | {
|
|---|
| 1781 | RECT rect;
|
|---|
| 1782 | int rc;
|
|---|
| 1783 |
|
|---|
| 1784 | if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
|
|---|
| 1785 |
|
|---|
| 1786 | rc = GetClipBox( (HDC)wParam, &rect );
|
|---|
| 1787 | if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
|
|---|
| 1788 | {
|
|---|
| 1789 | HBRUSH hBrush = windowClass->getBackgroundBrush();
|
|---|
| 1790 |
|
|---|
| 1791 | if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1))
|
|---|
| 1792 | hBrush = GetSysColorBrush(hBrush-1);
|
|---|
| 1793 |
|
|---|
| 1794 | FillRect( (HDC)wParam, &rect, hBrush);
|
|---|
| 1795 | }
|
|---|
| 1796 | return 1;
|
|---|
| 1797 | }
|
|---|
| 1798 |
|
|---|
| 1799 | case WM_PRINT:
|
|---|
| 1800 | return DefWndPrint(wParam,lParam);
|
|---|
| 1801 |
|
|---|
| 1802 | case WM_SYNCPAINT:
|
|---|
| 1803 | RedrawWindow(getWindowHandle(), NULL, 0, RDW_ERASENOW | RDW_ERASE | RDW_ALLCHILDREN);
|
|---|
| 1804 | return 0;
|
|---|
| 1805 |
|
|---|
| 1806 | case WM_PAINTICON:
|
|---|
| 1807 | case WM_PAINT:
|
|---|
| 1808 | {
|
|---|
| 1809 | PAINTSTRUCT ps;
|
|---|
| 1810 | HDC hdc = BeginPaint(getWindowHandle(), &ps );
|
|---|
| 1811 | if( hdc )
|
|---|
| 1812 | {
|
|---|
| 1813 | if( (getStyle() & WS_MINIMIZE) && (getWindowClass()->getIcon() || hIcon))
|
|---|
| 1814 | {
|
|---|
| 1815 | int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
|
|---|
| 1816 | int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
|
|---|
| 1817 | dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
|
|---|
| 1818 | DrawIcon(hdc, x, y, hIcon ? hIcon:getWindowClass()->getIcon() );
|
|---|
| 1819 | }
|
|---|
| 1820 | EndPaint(getWindowHandle(), &ps );
|
|---|
| 1821 | }
|
|---|
| 1822 | return 0;
|
|---|
| 1823 | }
|
|---|
| 1824 |
|
|---|
| 1825 | case WM_GETDLGCODE:
|
|---|
| 1826 | return 0;
|
|---|
| 1827 |
|
|---|
| 1828 | case WM_NCPAINT:
|
|---|
| 1829 | return HandleNCPaint((HRGN)wParam);
|
|---|
| 1830 |
|
|---|
| 1831 | case WM_NCACTIVATE:
|
|---|
| 1832 | return HandleNCActivate(wParam);
|
|---|
| 1833 |
|
|---|
| 1834 | case WM_NCCREATE:
|
|---|
| 1835 | return(TRUE);
|
|---|
| 1836 |
|
|---|
| 1837 | case WM_NCDESTROY:
|
|---|
| 1838 | return 0;
|
|---|
| 1839 |
|
|---|
| 1840 | case WM_NCCALCSIZE:
|
|---|
| 1841 | return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam);
|
|---|
| 1842 |
|
|---|
| 1843 | case WM_NCLBUTTONDOWN:
|
|---|
| 1844 | return HandleNCLButtonDown(wParam,lParam);
|
|---|
| 1845 |
|
|---|
| 1846 | case WM_LBUTTONDBLCLK:
|
|---|
| 1847 | case WM_NCLBUTTONDBLCLK:
|
|---|
| 1848 | return HandleNCLButtonDblClk(wParam,lParam);
|
|---|
| 1849 |
|
|---|
| 1850 | case WM_NCRBUTTONDOWN:
|
|---|
| 1851 | case WM_NCRBUTTONDBLCLK:
|
|---|
| 1852 | case WM_NCMBUTTONDOWN:
|
|---|
| 1853 | case WM_NCMBUTTONDBLCLK:
|
|---|
| 1854 | if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
|
|---|
| 1855 | return 0;
|
|---|
| 1856 |
|
|---|
| 1857 | case WM_NCRBUTTONUP:
|
|---|
| 1858 | return HandleNCRButtonUp(wParam,lParam);
|
|---|
| 1859 |
|
|---|
| 1860 | case WM_NCMBUTTONUP:
|
|---|
| 1861 | return 0;
|
|---|
| 1862 |
|
|---|
| 1863 | case WM_NCHITTEST:
|
|---|
| 1864 | {
|
|---|
| 1865 | POINT point;
|
|---|
| 1866 | LRESULT retvalue;
|
|---|
| 1867 |
|
|---|
| 1868 | point.x = (SHORT)LOWORD(lParam);
|
|---|
| 1869 | point.y = (SHORT)HIWORD(lParam);
|
|---|
| 1870 |
|
|---|
| 1871 | retvalue = HandleNCHitTest(point);
|
|---|
| 1872 | #if 0 //CB: let the Corel people fix the bugs first
|
|---|
| 1873 | if(retvalue == HTMENU)
|
|---|
| 1874 | MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,TRUE);
|
|---|
| 1875 | else
|
|---|
| 1876 | MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,FALSE);
|
|---|
| 1877 | #endif
|
|---|
| 1878 | return retvalue;
|
|---|
| 1879 | }
|
|---|
| 1880 |
|
|---|
| 1881 | case WM_SYSCOMMAND:
|
|---|
| 1882 | {
|
|---|
| 1883 | POINT point;
|
|---|
| 1884 |
|
|---|
| 1885 | point.x = LOWORD(lParam);
|
|---|
| 1886 | point.y = HIWORD(lParam);
|
|---|
| 1887 | return HandleSysCommand(wParam,&point);
|
|---|
| 1888 | }
|
|---|
| 1889 |
|
|---|
| 1890 | case WM_SYSKEYDOWN:
|
|---|
| 1891 | {
|
|---|
| 1892 | if( HIWORD(lParam) & KEYDATA_ALT )
|
|---|
| 1893 | {
|
|---|
| 1894 | /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
|
|---|
| 1895 | if( wParam == VK_MENU && !iMenuSysKey )
|
|---|
| 1896 | iMenuSysKey = 1;
|
|---|
| 1897 | else
|
|---|
| 1898 | iMenuSysKey = 0;
|
|---|
| 1899 |
|
|---|
| 1900 | iF10Key = 0;
|
|---|
| 1901 |
|
|---|
| 1902 | if( wParam == VK_F4 ) /* try to close the window */
|
|---|
| 1903 | {
|
|---|
| 1904 | HWND top = GetTopParent();
|
|---|
| 1905 | if (!(GetClassLongW( top, GCL_STYLE ) & CS_NOCLOSE))
|
|---|
| 1906 | PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
|
|---|
| 1907 | }
|
|---|
| 1908 | }
|
|---|
| 1909 | else if( wParam == VK_F10 )
|
|---|
| 1910 | iF10Key = 1;
|
|---|
| 1911 | else
|
|---|
| 1912 | if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
|
|---|
| 1913 | SendMessageW(getWindowHandle(), WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE );
|
|---|
| 1914 |
|
|---|
| 1915 | Win32BaseWindow *siblingWindow;
|
|---|
| 1916 | HWND sibling;
|
|---|
| 1917 | char nameBuffer [40], mnemonic;
|
|---|
| 1918 | int nameLength;
|
|---|
| 1919 |
|
|---|
| 1920 | GetWindowTextA (nameBuffer, 40);
|
|---|
| 1921 |
|
|---|
| 1922 | // search all sibling to see it this key is their mnemonic
|
|---|
| 1923 | sibling = GetWindow (GW_HWNDFIRST);
|
|---|
| 1924 | while (sibling != 0) {
|
|---|
| 1925 | siblingWindow = GetWindowFromHandle (sibling);
|
|---|
| 1926 | nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
|
|---|
| 1927 |
|
|---|
| 1928 | // find the siblings mnemonic
|
|---|
| 1929 | mnemonic = '\0';
|
|---|
| 1930 | for (int i=0 ; i<nameLength ; i++) {
|
|---|
| 1931 | if (IsDBCSLeadByte(nameBuffer[i])) {
|
|---|
| 1932 | // Skip DBCS
|
|---|
| 1933 | continue;
|
|---|
| 1934 | }
|
|---|
| 1935 | if (nameBuffer [i] == '&') {
|
|---|
| 1936 | mnemonic = nameBuffer [i+1];
|
|---|
| 1937 | if ((mnemonic >= 'a') && (mnemonic <= 'z'))
|
|---|
| 1938 | mnemonic -= 32; // make it uppercase
|
|---|
| 1939 | break; // stop searching
|
|---|
| 1940 | }
|
|---|
| 1941 | }
|
|---|
| 1942 |
|
|---|
| 1943 | // key matches siblings mnemonic, send mouseclick
|
|---|
| 1944 | if (mnemonic == (char) wParam) {
|
|---|
| 1945 | ::SendMessageA(siblingWindow->getWindowHandle(), BM_CLICK, 0, 0);
|
|---|
| 1946 | }
|
|---|
| 1947 | sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
|
|---|
| 1948 | RELEASE_WNDOBJ(siblingWindow);
|
|---|
| 1949 | }
|
|---|
| 1950 |
|
|---|
| 1951 | return 0;
|
|---|
| 1952 | }
|
|---|
| 1953 |
|
|---|
| 1954 | case WM_KEYUP:
|
|---|
| 1955 | case WM_SYSKEYUP:
|
|---|
| 1956 | /* Press and release F10 or ALT */
|
|---|
| 1957 | if (((wParam == VK_MENU) && iMenuSysKey) ||
|
|---|
| 1958 | ((wParam == VK_F10) && iF10Key))
|
|---|
| 1959 | ::SendMessageW( GetTopWindow(), WM_SYSCOMMAND, SC_KEYMENU, 0L );
|
|---|
| 1960 | iMenuSysKey = iF10Key = 0;
|
|---|
| 1961 | break;
|
|---|
| 1962 |
|
|---|
| 1963 | case WM_SYSCHAR:
|
|---|
| 1964 | {
|
|---|
| 1965 | iMenuSysKey = 0;
|
|---|
| 1966 | if (wParam == VK_RETURN && (getStyle() & WS_MINIMIZE))
|
|---|
| 1967 | {
|
|---|
| 1968 | PostMessageA(getWindowHandle(), WM_SYSCOMMAND,
|
|---|
| 1969 | (WPARAM)SC_RESTORE, 0L );
|
|---|
| 1970 | break;
|
|---|
| 1971 | }
|
|---|
| 1972 | if((HIWORD(lParam) & KEYDATA_ALT) && wParam)
|
|---|
| 1973 | {
|
|---|
| 1974 | if (wParam == VK_TAB || wParam == VK_ESCAPE || wParam == VK_F4)
|
|---|
| 1975 | break;
|
|---|
| 1976 | if (wParam == VK_SPACE && (getStyle() & WS_CHILD)) {
|
|---|
| 1977 | ::SendMessageW(GetParent(), Msg, wParam, lParam );
|
|---|
| 1978 | }
|
|---|
| 1979 | else ::SendMessageA(getWindowHandle(), WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam );
|
|---|
| 1980 | }
|
|---|
| 1981 | #if 0
|
|---|
| 1982 | else /* check for Ctrl-Esc */
|
|---|
| 1983 | if (wParam != VK_ESCAPE) MessageBeep(0);
|
|---|
| 1984 | break;
|
|---|
| 1985 | #endif
|
|---|
| 1986 | }
|
|---|
| 1987 |
|
|---|
| 1988 | case WM_SETHOTKEY:
|
|---|
| 1989 | hotkey = wParam;
|
|---|
| 1990 | return 1; //CB: always successful
|
|---|
| 1991 |
|
|---|
| 1992 | case WM_GETHOTKEY:
|
|---|
| 1993 | return hotkey;
|
|---|
| 1994 |
|
|---|
| 1995 | case WM_CONTEXTMENU:
|
|---|
| 1996 | if ((dwStyle & WS_CHILD) && getParent())
|
|---|
| 1997 | SendMessageA(getParent()->getWindowHandle(), WM_CONTEXTMENU,wParam,lParam);
|
|---|
| 1998 | return 0;
|
|---|
| 1999 |
|
|---|
| 2000 | case WM_SHOWWINDOW:
|
|---|
| 2001 | if (!lParam) return 0; /* sent from ShowWindow */
|
|---|
| 2002 | if (!(dwStyle & WS_POPUP) || !owner) return 0;
|
|---|
| 2003 | if ((dwStyle & WS_VISIBLE) && wParam) return 0;
|
|---|
| 2004 | else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
|
|---|
| 2005 | ShowWindow(wParam ? SW_SHOW:SW_HIDE);
|
|---|
| 2006 | return 0;
|
|---|
| 2007 |
|
|---|
| 2008 | case WM_CANCELMODE:
|
|---|
| 2009 | if (getParent() == windowDesktop) EndMenu();
|
|---|
| 2010 | if (GetCapture() == Win32Hwnd) ReleaseCapture();
|
|---|
| 2011 | return 0;
|
|---|
| 2012 |
|
|---|
| 2013 | case WM_DROPOBJECT:
|
|---|
| 2014 | return DRAG_FILE;
|
|---|
| 2015 |
|
|---|
| 2016 | case WM_QUERYDROPOBJECT:
|
|---|
| 2017 | return (dwExStyle & WS_EX_ACCEPTFILES) ? 1:0;
|
|---|
| 2018 |
|
|---|
| 2019 | case WM_QUERYDRAGICON:
|
|---|
| 2020 | {
|
|---|
| 2021 | HICON hDragIcon = windowClass->getCursor();
|
|---|
| 2022 | UINT len;
|
|---|
| 2023 |
|
|---|
| 2024 | if(hDragIcon) return (LRESULT)hDragIcon;
|
|---|
| 2025 | for(len = 1; len < 64; len++)
|
|---|
| 2026 | {
|
|---|
| 2027 | hDragIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
|
|---|
| 2028 | if(hDragIcon)
|
|---|
| 2029 | return (LRESULT)hDragIcon;
|
|---|
| 2030 | }
|
|---|
| 2031 | return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
|
|---|
| 2032 | }
|
|---|
| 2033 |
|
|---|
| 2034 | case WM_QUERYOPEN:
|
|---|
| 2035 | case WM_QUERYENDSESSION:
|
|---|
| 2036 | return 1;
|
|---|
| 2037 |
|
|---|
| 2038 | case WM_NOTIFYFORMAT:
|
|---|
| 2039 | return IsWindowUnicode() ? NFR_UNICODE:NFR_ANSI;
|
|---|
| 2040 |
|
|---|
| 2041 | case WM_SETICON:
|
|---|
| 2042 | case WM_GETICON:
|
|---|
| 2043 | {
|
|---|
| 2044 | LRESULT result = 0;
|
|---|
| 2045 |
|
|---|
| 2046 | /* Set the appropriate icon members in the window structure. */
|
|---|
| 2047 | if (wParam == ICON_SMALL)
|
|---|
| 2048 | {
|
|---|
| 2049 | result = hIconSm;
|
|---|
| 2050 | if (Msg == WM_SETICON)
|
|---|
| 2051 | hIconSm = (HICON)lParam;
|
|---|
| 2052 | }
|
|---|
| 2053 | else
|
|---|
| 2054 | {
|
|---|
| 2055 | result = hIcon;
|
|---|
| 2056 | if (Msg == WM_SETICON)
|
|---|
| 2057 | {
|
|---|
| 2058 | hIcon = (HICON)lParam;
|
|---|
| 2059 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
|---|
| 2060 | OSLibWinSetIcon(OS2HwndFrame,hIcon);
|
|---|
| 2061 | }
|
|---|
| 2062 | }
|
|---|
| 2063 | if ((Msg == WM_SETICON) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
|
|---|
| 2064 | HandleNCPaint((HRGN)1);
|
|---|
| 2065 |
|
|---|
| 2066 | return result;
|
|---|
| 2067 | }
|
|---|
| 2068 |
|
|---|
| 2069 | case WM_HELP:
|
|---|
| 2070 | if (getParent()) SendMessageA(getParent()->getWindowHandle(), Msg,wParam,lParam);
|
|---|
| 2071 | break;
|
|---|
| 2072 |
|
|---|
| 2073 | case WM_NOTIFY:
|
|---|
| 2074 | return 0; //comctl32 controls expect this
|
|---|
| 2075 |
|
|---|
| 2076 | default:
|
|---|
| 2077 | return 0;
|
|---|
| 2078 | }
|
|---|
| 2079 | return 0;
|
|---|
| 2080 | }
|
|---|
| 2081 | //******************************************************************************
|
|---|
| 2082 | //******************************************************************************
|
|---|
| 2083 | LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 2084 | {
|
|---|
| 2085 | switch(Msg)
|
|---|
| 2086 | {
|
|---|
| 2087 | case WM_GETTEXTLENGTH:
|
|---|
| 2088 | return windowNameLength;
|
|---|
| 2089 |
|
|---|
| 2090 | case WM_GETTEXT:
|
|---|
| 2091 | if (!lParam || !wParam)
|
|---|
| 2092 | return 0;
|
|---|
| 2093 | if (!windowNameW)
|
|---|
| 2094 | ((LPWSTR)lParam)[0] = 0;
|
|---|
| 2095 | else
|
|---|
| 2096 | memcpy((LPSTR)lParam, windowNameW, min( sizeof(WCHAR) * (windowNameLength+1), wParam) );
|
|---|
| 2097 | return min(windowNameLength, wParam);
|
|---|
| 2098 |
|
|---|
| 2099 | case WM_SETTEXT:
|
|---|
| 2100 | {
|
|---|
| 2101 | LPWSTR lpsz = (LPWSTR)lParam;
|
|---|
| 2102 |
|
|---|
| 2103 | // reallocate if new buffer is larger
|
|---|
| 2104 | if (!lParam)
|
|---|
| 2105 | {
|
|---|
| 2106 | free(windowNameA);
|
|---|
| 2107 | free(windowNameW);
|
|---|
| 2108 | windowNameLength = 0;
|
|---|
| 2109 | windowNameA = NULL;
|
|---|
| 2110 | windowNameW = NULL;
|
|---|
| 2111 | }
|
|---|
| 2112 | else
|
|---|
| 2113 | {
|
|---|
| 2114 | // determine length of new text
|
|---|
| 2115 | int iTextLength = lstrlenW(lpsz);
|
|---|
| 2116 |
|
|---|
| 2117 | if (windowNameLength < iTextLength)
|
|---|
| 2118 | {
|
|---|
| 2119 | if (windowNameA)
|
|---|
| 2120 | {
|
|---|
| 2121 | free(windowNameA);
|
|---|
| 2122 | windowNameA = NULL;
|
|---|
| 2123 | }
|
|---|
| 2124 |
|
|---|
| 2125 | if (windowNameW)
|
|---|
| 2126 | {
|
|---|
| 2127 | free(windowNameW);
|
|---|
| 2128 | windowNameW = NULL;
|
|---|
| 2129 | }
|
|---|
| 2130 | }
|
|---|
| 2131 |
|
|---|
| 2132 | windowNameLength = iTextLength;
|
|---|
| 2133 | if(!windowNameW)
|
|---|
| 2134 | windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
|
|---|
| 2135 | memcpy(windowNameW, lpsz, (windowNameLength+1) * sizeof(WCHAR));
|
|---|
| 2136 | if(!windowNameA)
|
|---|
| 2137 | windowNameA = (LPSTR)_smalloc(windowNameLength+1);
|
|---|
| 2138 | lstrcpynWtoA(windowNameA, windowNameW, windowNameLength+1);
|
|---|
| 2139 | }
|
|---|
| 2140 |
|
|---|
| 2141 | dprintf(("WM_SETTEXT of %x\n",Win32Hwnd));
|
|---|
| 2142 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
|---|
| 2143 | {
|
|---|
| 2144 | HandleNCPaint((HRGN)1);
|
|---|
| 2145 | if(hTaskList) {
|
|---|
| 2146 | OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
|
|---|
| 2147 | }
|
|---|
| 2148 | if(fOS2Look) {
|
|---|
| 2149 | OSLibWinSetTitleBarText(OS2HwndFrame, getWindowNameA());
|
|---|
| 2150 | }
|
|---|
| 2151 | }
|
|---|
| 2152 |
|
|---|
| 2153 | return TRUE;
|
|---|
| 2154 | }
|
|---|
| 2155 |
|
|---|
| 2156 | default:
|
|---|
| 2157 | return DefWindowProcA(Msg, wParam, lParam);
|
|---|
| 2158 | }
|
|---|
| 2159 | }
|
|---|
| 2160 | //******************************************************************************
|
|---|
| 2161 | //******************************************************************************
|
|---|
| 2162 | void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 2163 | {
|
|---|
| 2164 | Win32BaseWindow *window = this;
|
|---|
| 2165 | Win32BaseWindow *parentwindow;
|
|---|
| 2166 |
|
|---|
| 2167 | while(window)
|
|---|
| 2168 | {
|
|---|
| 2169 | if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
|---|
| 2170 | {
|
|---|
| 2171 | /* Notify the parent window only */
|
|---|
| 2172 | parentwindow = window->getParent();
|
|---|
| 2173 | if(parentwindow) {
|
|---|
| 2174 | SendMessageA(parentwindow->getWindowHandle(), WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
|
|---|
| 2175 | }
|
|---|
| 2176 | }
|
|---|
| 2177 | else break;
|
|---|
| 2178 |
|
|---|
| 2179 | window = parentwindow;
|
|---|
| 2180 | }
|
|---|
| 2181 | }
|
|---|
| 2182 | //******************************************************************************
|
|---|
| 2183 | // Returns the big or small icon for the window, falling back to the
|
|---|
| 2184 | // class as windows does.
|
|---|
| 2185 | //******************************************************************************
|
|---|
| 2186 | HICON Win32BaseWindow::IconForWindow(WPARAM fType)
|
|---|
| 2187 | {
|
|---|
| 2188 | HICON hWndIcon;
|
|---|
| 2189 |
|
|---|
| 2190 | if (fType == ICON_BIG)
|
|---|
| 2191 | {
|
|---|
| 2192 | if (hIcon)
|
|---|
| 2193 | hWndIcon = hIcon;
|
|---|
| 2194 | else
|
|---|
| 2195 | if (windowClass && windowClass->getIcon())
|
|---|
| 2196 | hWndIcon = windowClass->getIcon();
|
|---|
| 2197 | else
|
|---|
| 2198 | if (!(dwStyle & DS_MODALFRAME))
|
|---|
| 2199 | hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR);
|
|---|
| 2200 | else hWndIcon = 0;
|
|---|
| 2201 | }
|
|---|
| 2202 | else
|
|---|
| 2203 | {
|
|---|
| 2204 | if (hIconSm)
|
|---|
| 2205 | hWndIcon = hIconSm;
|
|---|
| 2206 | else
|
|---|
| 2207 | if (hIcon)
|
|---|
| 2208 | hWndIcon = hIcon;
|
|---|
| 2209 | else
|
|---|
| 2210 | if (windowClass && windowClass->getIconSm())
|
|---|
| 2211 | hWndIcon = windowClass->getIconSm();
|
|---|
| 2212 | else
|
|---|
| 2213 | if (windowClass && windowClass->getIcon())
|
|---|
| 2214 | hWndIcon = windowClass->getIcon();
|
|---|
| 2215 | else
|
|---|
| 2216 | if (!(dwStyle & DS_MODALFRAME))
|
|---|
| 2217 | hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR);
|
|---|
| 2218 | else hWndIcon = 0;
|
|---|
| 2219 | }
|
|---|
| 2220 |
|
|---|
| 2221 | return hWndIcon;
|
|---|
| 2222 | }
|
|---|
| 2223 | //******************************************************************************
|
|---|
| 2224 | //******************************************************************************
|
|---|
| 2225 | BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
|
|---|
| 2226 | {
|
|---|
| 2227 | ULONG swp = 0;
|
|---|
| 2228 | HWND hWinAfter;
|
|---|
| 2229 | BOOL rc,wasVisible,showFlag;
|
|---|
| 2230 | RECT newPos = {0, 0, 0, 0};
|
|---|
| 2231 |
|
|---|
| 2232 | dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
|
|---|
| 2233 | wasVisible = (getStyle() & WS_VISIBLE) != 0;
|
|---|
| 2234 |
|
|---|
| 2235 | dwOldStyle = getStyle();
|
|---|
| 2236 |
|
|---|
| 2237 | switch(nCmdShow)
|
|---|
| 2238 | {
|
|---|
| 2239 | case SW_HIDE:
|
|---|
| 2240 | if (!wasVisible) goto END;
|
|---|
| 2241 |
|
|---|
| 2242 | swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER;
|
|---|
| 2243 | break;
|
|---|
| 2244 |
|
|---|
| 2245 | case SW_SHOWMINNOACTIVE:
|
|---|
| 2246 | swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
|---|
| 2247 | /* fall through */
|
|---|
| 2248 | case SW_SHOWMINIMIZED:
|
|---|
| 2249 | swp |= SWP_SHOWWINDOW;
|
|---|
| 2250 | /* fall through */
|
|---|
| 2251 | case SW_MINIMIZE:
|
|---|
| 2252 | swp |= SWP_FRAMECHANGED;
|
|---|
| 2253 | if( !(getStyle() & WS_MINIMIZE) ) {
|
|---|
| 2254 | swp |= MinMaximize(SW_MINIMIZE, &newPos );
|
|---|
| 2255 | fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
|
|---|
| 2256 | }
|
|---|
| 2257 | else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|---|
| 2258 | break;
|
|---|
| 2259 |
|
|---|
| 2260 | case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
|
|---|
| 2261 | swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
|
|---|
| 2262 | if( !(getStyle() & WS_MAXIMIZE) ) {
|
|---|
| 2263 | swp |= MinMaximize(SW_MAXIMIZE, &newPos );
|
|---|
| 2264 | fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
|
|---|
| 2265 | }
|
|---|
| 2266 | else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|---|
| 2267 | break;
|
|---|
| 2268 |
|
|---|
| 2269 | case SW_SHOWNA:
|
|---|
| 2270 | swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
|---|
| 2271 | /* fall through */
|
|---|
| 2272 | case SW_SHOW:
|
|---|
| 2273 | swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
|
|---|
| 2274 |
|
|---|
| 2275 | /*
|
|---|
| 2276 | * ShowWindow has a little peculiar behavior that if the
|
|---|
| 2277 | * window is already the topmost window, it will not
|
|---|
| 2278 | * activate it.
|
|---|
| 2279 | */
|
|---|
| 2280 | if (::GetTopWindow((HWND)0)==getWindowHandle() && (wasVisible || GetActiveWindow() == getWindowHandle()))
|
|---|
| 2281 | swp |= SWP_NOACTIVATE;
|
|---|
| 2282 |
|
|---|
| 2283 | break;
|
|---|
| 2284 |
|
|---|
| 2285 | case SW_SHOWNOACTIVATE:
|
|---|
| 2286 | swp |= SWP_NOZORDER;
|
|---|
| 2287 | if (GetActiveWindow())
|
|---|
| 2288 | swp |= SWP_NOACTIVATE;
|
|---|
| 2289 | /* fall through */
|
|---|
| 2290 | case SW_SHOWNORMAL: /* same as SW_NORMAL: */
|
|---|
| 2291 | case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
|
|---|
| 2292 | case SW_RESTORE:
|
|---|
| 2293 | dprintf(("ShowWindow:restoring window"));
|
|---|
| 2294 |
|
|---|
| 2295 | swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
|
|---|
| 2296 | if( getStyle() & (WS_MINIMIZE | WS_MAXIMIZE) ) {
|
|---|
| 2297 | swp |= MinMaximize(SW_RESTORE, &newPos );
|
|---|
| 2298 | fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
|
|---|
| 2299 | }
|
|---|
| 2300 | else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
|---|
| 2301 | break;
|
|---|
| 2302 | }
|
|---|
| 2303 |
|
|---|
| 2304 | showFlag = (nCmdShow != SW_HIDE);
|
|---|
| 2305 | if (showFlag != wasVisible)
|
|---|
| 2306 | {
|
|---|
| 2307 | SendMessageA(getWindowHandle(),WM_SHOWWINDOW, showFlag, 0 );
|
|---|
| 2308 | if (!::IsWindow( getWindowHandle() )) goto END;
|
|---|
| 2309 | }
|
|---|
| 2310 |
|
|---|
| 2311 | /* We can't activate a child window */
|
|---|
| 2312 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_MDICHILD))
|
|---|
| 2313 | swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
|---|
| 2314 |
|
|---|
| 2315 | dprintf(("ShowWindow : SetWindowPos now"));
|
|---|
| 2316 | if (!(getStyle() & WS_MINIMIZE)) {
|
|---|
| 2317 | SetWindowPos(HWND_TOP, newPos.left, newPos.top, newPos.right, newPos.bottom, LOWORD(swp));
|
|---|
| 2318 | }
|
|---|
| 2319 | else OSLibWinMinimizeWindow(getOS2FrameWindowHandle());
|
|---|
| 2320 |
|
|---|
| 2321 | if(!(swp & SWP_NOACTIVATE)) {
|
|---|
| 2322 | OSLibWinSetActiveWindow(OS2HwndFrame);
|
|---|
| 2323 | }
|
|---|
| 2324 |
|
|---|
| 2325 | if (flags & WIN_NEED_SIZE)
|
|---|
| 2326 | {
|
|---|
| 2327 | /* should happen only in CreateWindowEx() */
|
|---|
| 2328 | int wParam = SIZE_RESTORED;
|
|---|
| 2329 |
|
|---|
| 2330 | flags &= ~WIN_NEED_SIZE;
|
|---|
| 2331 | if (dwStyle & WS_MAXIMIZE)
|
|---|
| 2332 | wParam = SIZE_MAXIMIZED;
|
|---|
| 2333 | else
|
|---|
| 2334 | if (dwStyle & WS_MINIMIZE)
|
|---|
| 2335 | wParam = SIZE_MINIMIZED;
|
|---|
| 2336 |
|
|---|
| 2337 | SendMessageA(getWindowHandle(),WM_SIZE, wParam,
|
|---|
| 2338 | MAKELONG(rectClient.right-rectClient.left,
|
|---|
| 2339 | rectClient.bottom-rectClient.top));
|
|---|
| 2340 | SendMessageA(getWindowHandle(),WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
|
|---|
| 2341 | }
|
|---|
| 2342 | //testestest
|
|---|
| 2343 | //temporary workaround for file dialogs with template dialog child
|
|---|
| 2344 | //they don't redraw when switching directories
|
|---|
| 2345 | //For some reason the new child's (syslistview32) update rectangle stays
|
|---|
| 2346 | //empty after its parent is made visible with ShowWindow
|
|---|
| 2347 | //TODO: find real cause
|
|---|
| 2348 | if(!wasVisible) {
|
|---|
| 2349 | InvalidateRect(getWindowHandle(), NULL, TRUE);
|
|---|
| 2350 | }
|
|---|
| 2351 | //testestest
|
|---|
| 2352 | END:
|
|---|
| 2353 | fMinMaxChange = FALSE;
|
|---|
| 2354 | return wasVisible;
|
|---|
| 2355 | }
|
|---|
| 2356 | //******************************************************************************
|
|---|
| 2357 | //******************************************************************************
|
|---|
| 2358 | BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
|
|---|
| 2359 | {
|
|---|
| 2360 | BOOL rc = FALSE;
|
|---|
| 2361 | Win32BaseWindow *window;
|
|---|
| 2362 | HWND hParent = 0;
|
|---|
| 2363 | RECT oldClientRect = rectClient;
|
|---|
| 2364 |
|
|---|
| 2365 | if (fuFlags &
|
|---|
| 2366 | ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
|
|---|
| 2367 | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
|
|---|
| 2368 | SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
|
|---|
| 2369 | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_DEFERERASE |
|
|---|
| 2370 | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE))
|
|---|
| 2371 | {
|
|---|
| 2372 | dprintf(("ERROR: SetWindowPos; UNKNOWN flag"));
|
|---|
| 2373 | return FALSE;
|
|---|
| 2374 | }
|
|---|
| 2375 |
|
|---|
| 2376 | if( fuFlags & (SWP_DEFERERASE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)) {
|
|---|
| 2377 | dprintf(("WARNING: SetWindowPos; unsupported flag"));
|
|---|
| 2378 | }
|
|---|
| 2379 |
|
|---|
| 2380 | if(IsWindowDestroyed()) {
|
|---|
| 2381 | //changing the position of a window that's being destroyed can cause crashes in PMMERGE
|
|---|
| 2382 | dprintf(("SetWindowPos; window already destroyed"));
|
|---|
| 2383 | return TRUE;
|
|---|
| 2384 | }
|
|---|
| 2385 |
|
|---|
| 2386 | #if 0
|
|---|
| 2387 | /* Fix redundant flags */
|
|---|
| 2388 | if(getStyle() & WS_VISIBLE) {
|
|---|
| 2389 | fuFlags &= ~SWP_SHOWWINDOW;
|
|---|
| 2390 | }
|
|---|
| 2391 | else
|
|---|
| 2392 | {
|
|---|
| 2393 | if (!(fuFlags & SWP_SHOWWINDOW))
|
|---|
| 2394 | fuFlags |= SWP_NOREDRAW;
|
|---|
| 2395 | fuFlags &= ~SWP_HIDEWINDOW;
|
|---|
| 2396 | }
|
|---|
| 2397 |
|
|---|
| 2398 | //// if(cx < 0) cx = 0;
|
|---|
| 2399 | //// if(cy < 0) cy = 0;
|
|---|
| 2400 |
|
|---|
| 2401 | if((rectWindow.right - rectWindow.left == cx) && (rectWindow.bottom - rectWindow.top == cy)) {
|
|---|
| 2402 | fuFlags |= SWP_NOSIZE; /* Already the right size */
|
|---|
| 2403 | }
|
|---|
| 2404 |
|
|---|
| 2405 | if((rectWindow.left == x) && (rectWindow.top == y)) {
|
|---|
| 2406 | fuFlags |= SWP_NOMOVE; /* Already the right position */
|
|---|
| 2407 | }
|
|---|
| 2408 |
|
|---|
| 2409 | if(getWindowHandle() == GetActiveWindow()) {
|
|---|
| 2410 | fuFlags |= SWP_NOACTIVATE; /* Already active */
|
|---|
| 2411 | }
|
|---|
| 2412 | else
|
|---|
| 2413 | if((getStyle() & (WS_POPUP | WS_CHILD)) != WS_CHILD )
|
|---|
| 2414 | {
|
|---|
| 2415 | if(!(fuFlags & SWP_NOACTIVATE)) /* Bring to the top when activating */
|
|---|
| 2416 | {
|
|---|
| 2417 | fuFlags &= ~SWP_NOZORDER;
|
|---|
| 2418 | hwndInsertAfter = HWND_TOP;
|
|---|
| 2419 | }
|
|---|
| 2420 | }
|
|---|
| 2421 | /* TODO: Check hwndInsertAfter */
|
|---|
| 2422 |
|
|---|
| 2423 | #endif
|
|---|
| 2424 |
|
|---|
| 2425 | //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
|
|---|
| 2426 | if(state < STATE_POST_WMNCCREATE)
|
|---|
| 2427 | {//don't change size; modify internal structures only
|
|---|
| 2428 | //TODO: not 100% correct yet (activate)
|
|---|
| 2429 | dprintf2(("state < STATE_POST_WMNCCREATE"));
|
|---|
| 2430 | if(!(fuFlags & SWP_NOZORDER)) {
|
|---|
| 2431 | hwndLinkAfter = hwndInsertAfter;
|
|---|
| 2432 | }
|
|---|
| 2433 | if(!(fuFlags & SWP_NOMOVE)) {
|
|---|
| 2434 | rectWindow.bottom = (rectWindow.bottom - rectWindow.top) + y;
|
|---|
| 2435 | rectWindow.top = y;
|
|---|
| 2436 | rectWindow.right = (rectWindow.right - rectWindow.left) + x;
|
|---|
| 2437 | rectWindow.left = x;
|
|---|
| 2438 | }
|
|---|
| 2439 | if(!(fuFlags & SWP_NOSIZE)) {
|
|---|
| 2440 | rectWindow.bottom = rectWindow.top + cy;
|
|---|
| 2441 | rectWindow.right = rectWindow.left + cx;
|
|---|
| 2442 | }
|
|---|
| 2443 | return TRUE;
|
|---|
| 2444 | }
|
|---|
| 2445 |
|
|---|
| 2446 | WINDOWPOS wpos;
|
|---|
| 2447 | SWP swp, swpOld;
|
|---|
| 2448 | wpos.flags = fuFlags;
|
|---|
| 2449 | wpos.cy = cy;
|
|---|
| 2450 | wpos.cx = cx;
|
|---|
| 2451 | wpos.x = x;
|
|---|
| 2452 | wpos.y = y;
|
|---|
| 2453 | wpos.hwndInsertAfter = hwndInsertAfter;
|
|---|
| 2454 | wpos.hwnd = getWindowHandle();
|
|---|
| 2455 |
|
|---|
| 2456 | if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
|
|---|
| 2457 | {
|
|---|
| 2458 | if (isChild())
|
|---|
| 2459 | {
|
|---|
| 2460 | if(!getParent()) {
|
|---|
| 2461 | dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
|
|---|
| 2462 | }
|
|---|
| 2463 | }
|
|---|
| 2464 | OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
|
|---|
| 2465 | }
|
|---|
| 2466 |
|
|---|
| 2467 | if(getParent()) {
|
|---|
| 2468 | OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, getParent()->getClientHeight(),
|
|---|
| 2469 | OS2HwndFrame);
|
|---|
| 2470 | }
|
|---|
| 2471 | else OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, OSLibQueryScreenHeight(), OS2HwndFrame);
|
|---|
| 2472 |
|
|---|
| 2473 | if (swp.fl == 0) {
|
|---|
| 2474 | dprintf2(("swp.fl == 0"));
|
|---|
| 2475 | if(fuFlags & SWP_FRAMECHANGED)
|
|---|
| 2476 | {
|
|---|
| 2477 | NotifyFrameChanged(&wpos, &oldClientRect);
|
|---|
| 2478 | }
|
|---|
| 2479 | return TRUE;
|
|---|
| 2480 | }
|
|---|
| 2481 |
|
|---|
| 2482 | // if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
|
|---|
| 2483 | if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
|
|---|
| 2484 | {
|
|---|
| 2485 | Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
|
|---|
| 2486 | if(wndBehind) {
|
|---|
| 2487 | swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
|
|---|
| 2488 | RELEASE_WNDOBJ(wndBehind);
|
|---|
| 2489 | }
|
|---|
| 2490 | else {
|
|---|
| 2491 | dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
|
|---|
| 2492 | swp.hwndInsertBehind = 0;
|
|---|
| 2493 | }
|
|---|
| 2494 | }
|
|---|
| 2495 | swp.hwnd = OS2HwndFrame;
|
|---|
| 2496 |
|
|---|
| 2497 | if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible(getWindowHandle())) {
|
|---|
| 2498 | setStyle(getStyle() | WS_VISIBLE);
|
|---|
| 2499 | if(hTaskList) {
|
|---|
| 2500 | dprintf(("Adding window %x to tasklist", getWindowHandle()));
|
|---|
| 2501 | OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), 1);
|
|---|
| 2502 | }
|
|---|
| 2503 | }
|
|---|
| 2504 | else
|
|---|
| 2505 | if((fuFlags & SWP_HIDEWINDOW) && IsWindowVisible(getWindowHandle())) {
|
|---|
| 2506 | setStyle(getStyle() & ~WS_VISIBLE);
|
|---|
| 2507 | if(hTaskList && !(getStyle() & WS_MINIMIZE)) {
|
|---|
| 2508 | dprintf(("Removing window %x from tasklist", getWindowHandle()));
|
|---|
| 2509 | OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), 0);
|
|---|
| 2510 | }
|
|---|
| 2511 | }
|
|---|
| 2512 | dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
|
|---|
| 2513 | rc = OSLibWinSetMultWindowPos(&swp, 1);
|
|---|
| 2514 |
|
|---|
| 2515 | if(rc == FALSE)
|
|---|
| 2516 | {
|
|---|
| 2517 | dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
|
|---|
| 2518 | return 0;
|
|---|
| 2519 | }
|
|---|
| 2520 |
|
|---|
| 2521 | if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
|
|---|
| 2522 | {
|
|---|
| 2523 | NotifyFrameChanged(&wpos, &oldClientRect);
|
|---|
| 2524 | }
|
|---|
| 2525 | if(!(getStyle() & (WS_MAXIMIZE|WS_MINIMIZE))) {
|
|---|
| 2526 | //Restore position always changes when the window position is changed
|
|---|
| 2527 | dprintf(("Save new restore position (%d,%d)(%d,%d)", rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
|
|---|
| 2528 | windowpos.rcNormalPosition = rectWindow;
|
|---|
| 2529 | }
|
|---|
| 2530 | return (rc);
|
|---|
| 2531 | }
|
|---|
| 2532 | //******************************************************************************
|
|---|
| 2533 | //Called by ScrollWindowEx (dc.cpp) to notify child window that it has moved
|
|---|
| 2534 | //******************************************************************************
|
|---|
| 2535 | BOOL Win32BaseWindow::ScrollWindow(int dx, int dy)
|
|---|
| 2536 | {
|
|---|
| 2537 | rectWindow.left += dx;
|
|---|
| 2538 | rectWindow.right += dx;
|
|---|
| 2539 | rectWindow.top += dy;
|
|---|
| 2540 | rectWindow.bottom += dy;
|
|---|
| 2541 | SendMessageA(getWindowHandle(),WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
|
|---|
| 2542 | return TRUE;
|
|---|
| 2543 | }
|
|---|
| 2544 | //******************************************************************************
|
|---|
| 2545 | //******************************************************************************
|
|---|
| 2546 | void Win32BaseWindow::NotifyFrameChanged(WINDOWPOS *wpos, RECT *oldClientRect)
|
|---|
| 2547 | {
|
|---|
| 2548 | HRGN hrgn, hrgnClient;
|
|---|
| 2549 | RECT rect;
|
|---|
| 2550 |
|
|---|
| 2551 | MsgFormatFrame(NULL);
|
|---|
| 2552 |
|
|---|
| 2553 | if(RECT_WIDTH(rectClient) != RECT_WIDTH(*oldClientRect) ||
|
|---|
| 2554 | RECT_HEIGHT(rectClient) != RECT_HEIGHT(*oldClientRect))
|
|---|
| 2555 | {
|
|---|
| 2556 | wpos->flags &= ~(SWP_NOSIZE|SWP_NOCLIENTSIZE);
|
|---|
| 2557 | wpos->cx = RECT_WIDTH(rectWindow);
|
|---|
| 2558 | wpos->cy = RECT_HEIGHT(rectWindow);
|
|---|
| 2559 | }
|
|---|
| 2560 |
|
|---|
| 2561 | if(rectClient.left != oldClientRect->left ||
|
|---|
| 2562 | rectClient.top != oldClientRect->top)
|
|---|
| 2563 | {
|
|---|
| 2564 | wpos->flags &= ~(SWP_NOMOVE|SWP_NOCLIENTMOVE);
|
|---|
| 2565 | wpos->x = rectWindow.left;
|
|---|
| 2566 | wpos->y = rectWindow.top;
|
|---|
| 2567 | }
|
|---|
| 2568 |
|
|---|
| 2569 | WINDOWPOS wpOld = *wpos;
|
|---|
| 2570 | if(!(wpos->flags & SWP_NOSENDCHANGING))
|
|---|
| 2571 | SendMessageA(getWindowHandle(),WM_WINDOWPOSCHANGING, 0, (LPARAM)wpos);
|
|---|
| 2572 |
|
|---|
| 2573 | if ((wpos->hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
|---|
| 2574 | (wpos->x != wpOld.x) || (wpos->y != wpOld.y) || (wpos->cx != wpOld.cx) || (wpos->cy != wpOld.cy) || (wpos->flags != wpOld.flags))
|
|---|
| 2575 | {
|
|---|
| 2576 | dprintf(("WARNING, NotifyFrameChanged: TODO -> adjust flags!!!!"));
|
|---|
| 2577 | SetWindowPos(wpos->hwndInsertAfter, wpos->x, wpos->y, wpos->cx, wpos->cy, wpos->flags | SWP_NOSENDCHANGING);
|
|---|
| 2578 | }
|
|---|
| 2579 | else SendMessageA(getWindowHandle(),WM_WINDOWPOSCHANGED, 0, (LPARAM)wpos);
|
|---|
| 2580 |
|
|---|
| 2581 | //Calculate invalid areas
|
|---|
| 2582 | rect = rectWindow;
|
|---|
| 2583 | OffsetRect(&rect, -rectWindow.left, -rectWindow.top);
|
|---|
| 2584 | hrgn = CreateRectRgnIndirect(&rect);
|
|---|
| 2585 | if (!hrgn) {
|
|---|
| 2586 | dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
|
|---|
| 2587 | return;
|
|---|
| 2588 | }
|
|---|
| 2589 | rect = rectClient;
|
|---|
| 2590 | hrgnClient = CreateRectRgnIndirect(&rect);
|
|---|
| 2591 | if (!hrgn) {
|
|---|
| 2592 | dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
|
|---|
| 2593 | return;
|
|---|
| 2594 | }
|
|---|
| 2595 | CombineRgn(hrgn, hrgn, hrgnClient, RGN_DIFF);
|
|---|
| 2596 | DeleteObject(hrgnClient);
|
|---|
| 2597 |
|
|---|
| 2598 | if(!EqualRect(oldClientRect, &rectClient)) {
|
|---|
| 2599 | UnionRect(oldClientRect, oldClientRect, &rectClient);
|
|---|
| 2600 | hrgnClient = CreateRectRgnIndirect(oldClientRect);
|
|---|
| 2601 | if (!hrgn) {
|
|---|
| 2602 | dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
|
|---|
| 2603 | return;
|
|---|
| 2604 | }
|
|---|
| 2605 | CombineRgn(hrgn, hrgn, hrgnClient, RGN_OR);
|
|---|
| 2606 | DeleteObject(hrgnClient);
|
|---|
| 2607 | }
|
|---|
| 2608 | RedrawWindow(getWindowHandle(), NULL, hrgn, RDW_ALLCHILDREN |
|
|---|
| 2609 | RDW_INVALIDATE | RDW_ERASE | RDW_FRAME);
|
|---|
| 2610 | DeleteObject(hrgn);
|
|---|
| 2611 | }
|
|---|
| 2612 | //******************************************************************************
|
|---|
| 2613 | //TODO: Check how this api really works in NT
|
|---|
| 2614 | //******************************************************************************
|
|---|
| 2615 | BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *wndpl)
|
|---|
| 2616 | {
|
|---|
| 2617 | dprintf(("SetWindowPlacement %x min (%d,%d)", getWindowHandle(), wndpl->ptMinPosition.x, wndpl->ptMinPosition.y));
|
|---|
| 2618 | dprintf(("SetWindowPlacement %x max (%d,%d)", getWindowHandle(), wndpl->ptMaxPosition.x, wndpl->ptMaxPosition.y));
|
|---|
| 2619 | dprintf(("SetWindowPlacement %x norm (%d,%d)(%d,%d)", getWindowHandle(), wndpl->rcNormalPosition.left, wndpl->rcNormalPosition.top, wndpl->rcNormalPosition.right, wndpl->rcNormalPosition.bottom));
|
|---|
| 2620 | windowpos.ptMinPosition = wndpl->ptMinPosition;
|
|---|
| 2621 | windowpos.ptMaxPosition = wndpl->ptMaxPosition;
|
|---|
| 2622 | windowpos.rcNormalPosition = wndpl->rcNormalPosition;
|
|---|
| 2623 |
|
|---|
| 2624 | if(getStyle() & WS_MINIMIZE )
|
|---|
| 2625 | {
|
|---|
| 2626 | //TODO: Why can't this be (0,0)?
|
|---|
| 2627 | if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
|
|---|
| 2628 | SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
|
|---|
| 2629 | 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 2630 | }
|
|---|
| 2631 | }
|
|---|
| 2632 | else
|
|---|
| 2633 | if(getStyle() & WS_MAXIMIZE )
|
|---|
| 2634 | {
|
|---|
| 2635 | //TODO: Why can't this be (0,0)?
|
|---|
| 2636 | if(windowpos.ptMaxPosition.x != 0 || windowpos.ptMaxPosition.y != 0 )
|
|---|
| 2637 | SetWindowPos(0, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
|
|---|
| 2638 | 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|---|
| 2639 | }
|
|---|
| 2640 | else {
|
|---|
| 2641 | SetWindowPos(0, windowpos.rcNormalPosition.left, windowpos.rcNormalPosition.top,
|
|---|
| 2642 | windowpos.rcNormalPosition.right - windowpos.rcNormalPosition.left,
|
|---|
| 2643 | windowpos.rcNormalPosition.bottom - windowpos.rcNormalPosition.top,
|
|---|
| 2644 | SWP_NOZORDER | SWP_NOACTIVATE );
|
|---|
| 2645 | }
|
|---|
| 2646 | ShowWindow(wndpl->showCmd);
|
|---|
| 2647 | if( ::IsWindow(getWindowHandle()) && getStyle() & WS_MINIMIZE )
|
|---|
| 2648 | {
|
|---|
| 2649 | /* SDK: ...valid only the next time... */
|
|---|
| 2650 | if(wndpl->flags & WPF_RESTORETOMAXIMIZED)
|
|---|
| 2651 | setFlags(getFlags() | WIN_RESTORE_MAX);
|
|---|
| 2652 | }
|
|---|
| 2653 | return TRUE;
|
|---|
| 2654 | }
|
|---|
| 2655 | //******************************************************************************
|
|---|
| 2656 | //******************************************************************************
|
|---|
| 2657 | BOOL Win32BaseWindow::GetWindowPlacement(LPWINDOWPLACEMENT wndpl)
|
|---|
| 2658 | {
|
|---|
| 2659 | wndpl->length = sizeof(*wndpl);
|
|---|
| 2660 | if(getStyle() & WS_MINIMIZE )
|
|---|
| 2661 | wndpl->showCmd = SW_SHOWMINIMIZED;
|
|---|
| 2662 | else wndpl->showCmd = (getStyle() & WS_MAXIMIZE) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
|
|---|
| 2663 |
|
|---|
| 2664 | //TODO: Verify if this is correct -> SDK docs claim this flag must always be set to 0
|
|---|
| 2665 | if(getFlags() & WIN_RESTORE_MAX )
|
|---|
| 2666 | wndpl->flags = WPF_RESTORETOMAXIMIZED;
|
|---|
| 2667 | else wndpl->flags = 0;
|
|---|
| 2668 |
|
|---|
| 2669 | wndpl->ptMinPosition = windowpos.ptMinPosition;
|
|---|
| 2670 | wndpl->ptMaxPosition = windowpos.ptMaxPosition;
|
|---|
| 2671 | //Must be in parent coordinates (or screen if no parent); verified in NT4, SP6
|
|---|
| 2672 | wndpl->rcNormalPosition = windowpos.rcNormalPosition;
|
|---|
| 2673 |
|
|---|
| 2674 | return TRUE;
|
|---|
| 2675 | }
|
|---|
| 2676 | //******************************************************************************
|
|---|
| 2677 | //Also destroys all the child windows (destroy children first, parent last)
|
|---|
| 2678 | //******************************************************************************
|
|---|
| 2679 | BOOL Win32BaseWindow::DestroyWindow()
|
|---|
| 2680 | {
|
|---|
| 2681 | HWND hwnd = getWindowHandle();
|
|---|
| 2682 |
|
|---|
| 2683 | dprintf(("DestroyWindow %x", hwnd));
|
|---|
| 2684 |
|
|---|
| 2685 | /* Call hooks */
|
|---|
| 2686 | if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
|
|---|
| 2687 | {
|
|---|
| 2688 | return FALSE;
|
|---|
| 2689 | }
|
|---|
| 2690 |
|
|---|
| 2691 | if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
|
|---|
| 2692 | {
|
|---|
| 2693 | HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
|
|---|
| 2694 | /* FIXME: clean up palette - see "Internals" p.352 */
|
|---|
| 2695 | }
|
|---|
| 2696 |
|
|---|
| 2697 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
|
|---|
| 2698 | {
|
|---|
| 2699 | if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
|
|---|
| 2700 | {
|
|---|
| 2701 | /* Notify the parent window only */
|
|---|
| 2702 | SendMessageA(getParent()->getWindowHandle(), WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
|
|---|
| 2703 | if(!::IsWindow(hwnd) )
|
|---|
| 2704 | {
|
|---|
| 2705 | return TRUE;
|
|---|
| 2706 | }
|
|---|
| 2707 | }
|
|---|
| 2708 | //// else DebugInt3();
|
|---|
| 2709 | }
|
|---|
| 2710 | /* Hide the window */
|
|---|
| 2711 | if(IsWindowVisible(getWindowHandle()))
|
|---|
| 2712 | {
|
|---|
| 2713 | SetWindowPos(0, 0, 0, 0, 0, SWP_HIDEWINDOW |
|
|---|
| 2714 | SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE);
|
|---|
| 2715 | if(!::IsWindow(hwnd))
|
|---|
| 2716 | {
|
|---|
| 2717 | return TRUE;
|
|---|
| 2718 | }
|
|---|
| 2719 | }
|
|---|
| 2720 | dprintf(("DestroyWindow %x -> HIDDEN", hwnd));
|
|---|
| 2721 |
|
|---|
| 2722 | // check the handle for the last active popup window
|
|---|
| 2723 | Win32BaseWindow* owner = getOwner();
|
|---|
| 2724 | if (NULL != owner)
|
|---|
| 2725 | {
|
|---|
| 2726 | if (owner->getLastActive() == hwnd)
|
|---|
| 2727 | owner->setLastActive( owner->getWindowHandle() );
|
|---|
| 2728 | }
|
|---|
| 2729 |
|
|---|
| 2730 | fDestroyWindowCalled = TRUE;
|
|---|
| 2731 | return OSLibWinDestroyWindow(OS2HwndFrame);
|
|---|
| 2732 | }
|
|---|
| 2733 | //******************************************************************************
|
|---|
| 2734 | //******************************************************************************
|
|---|
| 2735 | Win32BaseWindow *Win32BaseWindow::getParent()
|
|---|
| 2736 | {
|
|---|
| 2737 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
|---|
| 2738 | return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
|
|---|
| 2739 | }
|
|---|
| 2740 | //******************************************************************************
|
|---|
| 2741 | //Note: does not set last error if no parent (verified in NT4, SP6)
|
|---|
| 2742 | //******************************************************************************
|
|---|
| 2743 | HWND Win32BaseWindow::GetParent()
|
|---|
| 2744 | {
|
|---|
| 2745 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
|---|
| 2746 |
|
|---|
| 2747 | if(getStyle() & WS_CHILD) {
|
|---|
| 2748 | if(wndparent) {
|
|---|
| 2749 | return wndparent->getWindowHandle();
|
|---|
| 2750 | }
|
|---|
| 2751 | dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
|
|---|
| 2752 | DebugInt3();
|
|---|
| 2753 | return 0;
|
|---|
| 2754 | }
|
|---|
| 2755 | else
|
|---|
| 2756 | if(getStyle() & WS_POPUP)
|
|---|
| 2757 | return (getOwner()) ? getOwner()->getWindowHandle() : 0;
|
|---|
| 2758 | else return 0;
|
|---|
| 2759 | }
|
|---|
| 2760 | //******************************************************************************
|
|---|
| 2761 | //******************************************************************************
|
|---|
| 2762 | HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
|
|---|
| 2763 | {
|
|---|
| 2764 | HWND oldhwnd;
|
|---|
| 2765 | Win32BaseWindow *newparent;
|
|---|
| 2766 | Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
|---|
| 2767 | BOOL fShow = FALSE;
|
|---|
| 2768 |
|
|---|
| 2769 | if(oldparent) {
|
|---|
| 2770 | oldhwnd = oldparent->getWindowHandle();
|
|---|
| 2771 | oldparent->removeChild(this);
|
|---|
| 2772 | }
|
|---|
| 2773 | else oldhwnd = 0;
|
|---|
| 2774 |
|
|---|
| 2775 | /* Windows hides the window first, then shows it again
|
|---|
| 2776 | * including the WM_SHOWWINDOW messages and all */
|
|---|
| 2777 | if(IsWindowCreated() && (getStyle() & WS_VISIBLE)) {
|
|---|
| 2778 | ShowWindow(SW_HIDE);
|
|---|
| 2779 | fShow = TRUE;
|
|---|
| 2780 | }
|
|---|
| 2781 | if(oldparent) {
|
|---|
| 2782 | //release parent here (increased refcount during creation)
|
|---|
| 2783 | RELEASE_WNDOBJ(oldparent);
|
|---|
| 2784 | }
|
|---|
| 2785 | newparent = GetWindowFromHandle(hwndNewParent);
|
|---|
| 2786 | if(newparent && !newparent->isDesktopWindow())
|
|---|
| 2787 | {
|
|---|
| 2788 | setParent(newparent);
|
|---|
| 2789 | getParent()->addChild(this);
|
|---|
| 2790 | fParentChange = TRUE;
|
|---|
| 2791 |
|
|---|
| 2792 | OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
|
|---|
| 2793 | if(!(getStyle() & WS_CHILD))
|
|---|
| 2794 | {
|
|---|
| 2795 | //TODO: Send WM_STYLECHANGED msg?
|
|---|
| 2796 | setStyle(getStyle() | WS_CHILD);
|
|---|
| 2797 | if(getWindowId())
|
|---|
| 2798 | {
|
|---|
| 2799 | DestroyMenu( (HMENU) getWindowId() );
|
|---|
| 2800 | setWindowId(0);
|
|---|
| 2801 | }
|
|---|
| 2802 | }
|
|---|
| 2803 | //SvL: Even though the win32 coordinates might not change, the PM
|
|---|
| 2804 | // coordinates can. We must make sure the control stays at the
|
|---|
| 2805 | // same position (y) relative to the (new) parent.
|
|---|
| 2806 | SetWindowPos(HWND_TOPMOST, rectWindow.left, rectWindow.top, 0, 0,
|
|---|
| 2807 | SWP_NOACTIVATE|SWP_NOSIZE);
|
|---|
| 2808 | fParentChange = FALSE;
|
|---|
| 2809 | }
|
|---|
| 2810 | else {
|
|---|
| 2811 | if(newparent) RELEASE_WNDOBJ(newparent);
|
|---|
| 2812 |
|
|---|
| 2813 | setParent(windowDesktop);
|
|---|
| 2814 | windowDesktop->addRef();
|
|---|
| 2815 | windowDesktop->addChild(this);
|
|---|
| 2816 | OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
|
|---|
| 2817 |
|
|---|
| 2818 | //TODO: Send WM_STYLECHANGED msg?
|
|---|
| 2819 | setStyle(getStyle() & ~WS_CHILD);
|
|---|
| 2820 | setWindowId(0);
|
|---|
| 2821 | }
|
|---|
| 2822 | /* SetParent additionally needs to make hwndChild the topmost window
|
|---|
| 2823 | in the x-order and send the expected WM_WINDOWPOSCHANGING and
|
|---|
| 2824 | WM_WINDOWPOSCHANGED notification messages.
|
|---|
| 2825 | */
|
|---|
| 2826 | if(state >= STATE_PRE_WMNCCREATE) {
|
|---|
| 2827 | SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
|
|---|
| 2828 | SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
|
|---|
| 2829 |
|
|---|
| 2830 | /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
|
|---|
| 2831 | * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
|
|---|
| 2832 | }
|
|---|
| 2833 | return oldhwnd;
|
|---|
| 2834 | }
|
|---|
| 2835 | //******************************************************************************
|
|---|
| 2836 | //******************************************************************************
|
|---|
| 2837 | BOOL Win32BaseWindow::IsChild(HWND hwndParent)
|
|---|
| 2838 | {
|
|---|
| 2839 | // PH: Optimizer won't unroll calls to getParent() even
|
|---|
| 2840 | // in release build.
|
|---|
| 2841 | Win32BaseWindow *_parent = getParent();
|
|---|
| 2842 |
|
|---|
| 2843 | if(_parent)
|
|---|
| 2844 | {
|
|---|
| 2845 | if(_parent->getWindowHandle() == hwndParent)
|
|---|
| 2846 | return TRUE;
|
|---|
| 2847 |
|
|---|
| 2848 | return _parent->IsChild(hwndParent);
|
|---|
| 2849 | }
|
|---|
| 2850 | else
|
|---|
| 2851 | return 0;
|
|---|
| 2852 | }
|
|---|
| 2853 | //******************************************************************************
|
|---|
| 2854 | //******************************************************************************
|
|---|
| 2855 | HWND Win32BaseWindow::GetTopWindow()
|
|---|
| 2856 | {
|
|---|
| 2857 | HWND hwndTop;
|
|---|
| 2858 | Win32BaseWindow *topwindow;
|
|---|
| 2859 |
|
|---|
| 2860 | hwndTop = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
|
|---|
| 2861 | if(!isDesktopWindow())
|
|---|
| 2862 | {
|
|---|
| 2863 | topwindow = GetWindowFromOS2FrameHandle(hwndTop);
|
|---|
| 2864 | //Note: GetTopWindow can't return a window that hasn't processed
|
|---|
| 2865 | // WM_NCCREATE yet (verified in NT4, SP6)
|
|---|
| 2866 | if(topwindow) {
|
|---|
| 2867 | if(topwindow->state >= STATE_POST_WMNCCREATE) {
|
|---|
| 2868 | hwndTop = topwindow->getWindowHandle();
|
|---|
| 2869 | }
|
|---|
| 2870 | else hwndTop = topwindow->GetWindow(GW_HWNDNEXT);
|
|---|
| 2871 | RELEASE_WNDOBJ(topwindow);
|
|---|
| 2872 | return hwndTop;
|
|---|
| 2873 | }
|
|---|
| 2874 | if(topwindow) RELEASE_WNDOBJ(topwindow);
|
|---|
| 2875 | return 0;
|
|---|
| 2876 | }
|
|---|
| 2877 | while(hwndTop) {
|
|---|
| 2878 | topwindow = GetWindowFromOS2FrameHandle(hwndTop);
|
|---|
| 2879 | //Note: GetTopWindow can't return a window that hasn't processed
|
|---|
| 2880 | // WM_NCCREATE yet (verified in NT4, SP6)
|
|---|
| 2881 | if(topwindow) {
|
|---|
| 2882 | if(topwindow->state >= STATE_POST_WMNCCREATE) {
|
|---|
| 2883 | hwndTop = topwindow->getWindowHandle();
|
|---|
| 2884 | }
|
|---|
| 2885 | else hwndTop = topwindow->GetWindow(GW_HWNDNEXT);
|
|---|
| 2886 | RELEASE_WNDOBJ(topwindow);
|
|---|
| 2887 | return hwndTop;
|
|---|
| 2888 | }
|
|---|
| 2889 | if(topwindow) RELEASE_WNDOBJ(topwindow);
|
|---|
| 2890 | hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
|
|---|
| 2891 | }
|
|---|
| 2892 |
|
|---|
| 2893 | return 0;
|
|---|
| 2894 | }
|
|---|
| 2895 | //******************************************************************************
|
|---|
| 2896 | // Get the top-level parent for a child window.
|
|---|
| 2897 | //******************************************************************************
|
|---|
| 2898 | HWND Win32BaseWindow::GetTopParent()
|
|---|
| 2899 | {
|
|---|
| 2900 | Win32BaseWindow *window = this;
|
|---|
| 2901 | HWND hwndTopParent = 0;
|
|---|
| 2902 |
|
|---|
| 2903 | lock();
|
|---|
| 2904 | while(window && (window->getStyle() & WS_CHILD))
|
|---|
| 2905 | {
|
|---|
| 2906 | window = window->getParent();
|
|---|
| 2907 | }
|
|---|
| 2908 | if(window) {
|
|---|
| 2909 | hwndTopParent = window->getWindowHandle();
|
|---|
| 2910 | }
|
|---|
| 2911 | unlock();
|
|---|
| 2912 | return hwndTopParent;
|
|---|
| 2913 | }
|
|---|
| 2914 | //******************************************************************************
|
|---|
| 2915 | //TODO: Should not enumerate children that are created during the enumeration!
|
|---|
| 2916 | //TODO: Do this more efficiently
|
|---|
| 2917 | //******************************************************************************
|
|---|
| 2918 | BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 2919 | {
|
|---|
| 2920 | BOOL rc = TRUE;
|
|---|
| 2921 | HWND hwnd;
|
|---|
| 2922 | Win32BaseWindow *prevchild = 0, *child = 0;
|
|---|
| 2923 |
|
|---|
| 2924 | dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
|
|---|
| 2925 | lock();
|
|---|
| 2926 | for (child = (Win32BaseWindow *)getFirstChild(); child != NULL; child = (Win32BaseWindow *)child->getNextChild())
|
|---|
| 2927 | {
|
|---|
| 2928 | dprintf(("EnumChildWindows: enumerating child %x (owner %x; parent %x)", child->getWindowHandle(), (child->getOwner()) ? child->getOwner()->getWindowHandle() : 0, getWindowHandle()));
|
|---|
| 2929 | hwnd = child->getWindowHandle();
|
|---|
| 2930 | if(child->IsWindowDestroyed() || child->getOwner()) {
|
|---|
| 2931 | continue; //shouldn't have an owner (Wine)
|
|---|
| 2932 | }
|
|---|
| 2933 | child->addRef();
|
|---|
| 2934 | unlock();
|
|---|
| 2935 | if(lpfn(hwnd, lParam) == FALSE)
|
|---|
| 2936 | {
|
|---|
| 2937 | child->release();
|
|---|
| 2938 | return FALSE;
|
|---|
| 2939 | }
|
|---|
| 2940 | child->release();
|
|---|
| 2941 | lock();
|
|---|
| 2942 | //check if the window still exists
|
|---|
| 2943 | if(!::IsWindow(hwnd))
|
|---|
| 2944 | {
|
|---|
| 2945 | child = prevchild;
|
|---|
| 2946 | if(child == NULL) break;
|
|---|
| 2947 | continue;
|
|---|
| 2948 | }
|
|---|
| 2949 | if(child->getFirstChild() != NULL)
|
|---|
| 2950 | {
|
|---|
| 2951 | dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
|
|---|
| 2952 | child->addRef();
|
|---|
| 2953 | unlock();
|
|---|
| 2954 | if(child->EnumChildWindows(lpfn, lParam) == FALSE)
|
|---|
| 2955 | {
|
|---|
| 2956 | child->release();
|
|---|
| 2957 | return FALSE;
|
|---|
| 2958 | }
|
|---|
| 2959 | child->release();
|
|---|
| 2960 | lock();
|
|---|
| 2961 | }
|
|---|
| 2962 | prevchild = child;
|
|---|
| 2963 | }
|
|---|
| 2964 | unlock();
|
|---|
| 2965 | return rc;
|
|---|
| 2966 | }
|
|---|
| 2967 | //******************************************************************************
|
|---|
| 2968 | //Enumerate first-level children only and check thread id
|
|---|
| 2969 | //******************************************************************************
|
|---|
| 2970 | BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 2971 | {
|
|---|
| 2972 | Win32BaseWindow *child = 0;
|
|---|
| 2973 | ULONG tid, pid;
|
|---|
| 2974 | BOOL rc;
|
|---|
| 2975 | HWND hwnd;
|
|---|
| 2976 |
|
|---|
| 2977 | dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
|
|---|
| 2978 |
|
|---|
| 2979 | for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
|
|---|
| 2980 | {
|
|---|
| 2981 | OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
|
|---|
| 2982 |
|
|---|
| 2983 | if(dwThreadId == tid) {
|
|---|
| 2984 | dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
|
|---|
| 2985 | if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
|
|---|
| 2986 | break;
|
|---|
| 2987 | }
|
|---|
| 2988 | }
|
|---|
| 2989 | }
|
|---|
| 2990 | return TRUE;
|
|---|
| 2991 | }
|
|---|
| 2992 | //******************************************************************************
|
|---|
| 2993 | //Enumerate first-level children only
|
|---|
| 2994 | //******************************************************************************
|
|---|
| 2995 | BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
|---|
| 2996 | {
|
|---|
| 2997 | Win32BaseWindow *window;
|
|---|
| 2998 | BOOL rc;
|
|---|
| 2999 | HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
|
|---|
| 3000 |
|
|---|
| 3001 | dprintf(("EnumWindows %x %x", lpfn, lParam));
|
|---|
| 3002 |
|
|---|
| 3003 | for(int i=0;i<MAX_WINDOW_HANDLES;i++)
|
|---|
| 3004 | {
|
|---|
| 3005 | window = GetWindowFromHandle(hwnd++);
|
|---|
| 3006 | if(window)
|
|---|
| 3007 | {
|
|---|
| 3008 | if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
|
|---|
| 3009 | {
|
|---|
| 3010 | dprintf2(("EnumWindows: Found Window %x", window->getWindowHandle()));
|
|---|
| 3011 | if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE) {
|
|---|
| 3012 | break;
|
|---|
| 3013 | }
|
|---|
| 3014 | }
|
|---|
| 3015 | RELEASE_WNDOBJ(window);
|
|---|
| 3016 | }
|
|---|
| 3017 | }
|
|---|
| 3018 | if(window) RELEASE_WNDOBJ(window);
|
|---|
| 3019 | return TRUE;
|
|---|
| 3020 | }
|
|---|
| 3021 | //******************************************************************************
|
|---|
| 3022 | //******************************************************************************
|
|---|
| 3023 | HWND Win32BaseWindow::FindWindowById(int id)
|
|---|
| 3024 | {
|
|---|
| 3025 | HWND hwnd;
|
|---|
| 3026 |
|
|---|
| 3027 | lock();
|
|---|
| 3028 | for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
|
|---|
| 3029 | {
|
|---|
| 3030 | if (child->getWindowId() == id)
|
|---|
| 3031 | {
|
|---|
| 3032 | hwnd = child->getWindowHandle();
|
|---|
| 3033 | unlock();
|
|---|
| 3034 | return hwnd;
|
|---|
| 3035 | }
|
|---|
| 3036 | }
|
|---|
| 3037 | unlock();
|
|---|
| 3038 | return 0;
|
|---|
| 3039 | }
|
|---|
| 3040 | //******************************************************************************
|
|---|
| 3041 | //TODO:
|
|---|
| 3042 | //We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
|
|---|
| 3043 | //the current process owns them.
|
|---|
| 3044 | //******************************************************************************
|
|---|
| 3045 | HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow)
|
|---|
| 3046 | {
|
|---|
| 3047 | Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
|
|---|
| 3048 | Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
|
|---|
| 3049 | Win32BaseWindow *firstchild = child;
|
|---|
| 3050 |
|
|---|
| 3051 | dprintf(("FindWindowEx %x %x %x %s", hwndParent, hwndChildAfter, atom, lpszWindow));
|
|---|
| 3052 | if((hwndParent != 0 && !parent) ||
|
|---|
| 3053 | (hwndChildAfter != 0 && !child) ||
|
|---|
| 3054 | (hwndParent == 0 && hwndChildAfter != 0))
|
|---|
| 3055 | {
|
|---|
| 3056 | if(parent) RELEASE_WNDOBJ(parent);
|
|---|
| 3057 | if(firstchild) RELEASE_WNDOBJ(firstchild);
|
|---|
| 3058 | dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
|
|---|
| 3059 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 3060 | return 0;
|
|---|
| 3061 | }
|
|---|
| 3062 | SetLastError(0);
|
|---|
| 3063 | if(hwndParent != 0)
|
|---|
| 3064 | {//if the current process owns the window, just do a quick search
|
|---|
| 3065 | lock(&critsect);
|
|---|
| 3066 | child = (Win32BaseWindow *)parent->getFirstChild();
|
|---|
| 3067 | if(hwndChildAfter != 0)
|
|---|
| 3068 | {
|
|---|
| 3069 | while(child)
|
|---|
| 3070 | {
|
|---|
| 3071 | if(child->getWindowHandle() == hwndChildAfter)
|
|---|
| 3072 | {
|
|---|
| 3073 | child = (Win32BaseWindow *)child->getNextChild();
|
|---|
| 3074 | break;
|
|---|
| 3075 | }
|
|---|
| 3076 | child = (Win32BaseWindow *)child->getNextChild();
|
|---|
| 3077 | }
|
|---|
| 3078 | }
|
|---|
| 3079 | while(child)
|
|---|
| 3080 | {
|
|---|
| 3081 | //According to Wine, the class doesn't need to be specified
|
|---|
| 3082 | if((!atom || child->getWindowClass()->getAtom() == atom) &&
|
|---|
| 3083 | (!lpszWindow || child->hasWindowName(lpszWindow)))
|
|---|
| 3084 | {
|
|---|
| 3085 | dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
|
|---|
| 3086 | HWND hwndChild = child->getWindowHandle();
|
|---|
| 3087 | unlock(&critsect);
|
|---|
| 3088 | if(parent) RELEASE_WNDOBJ(parent);
|
|---|
| 3089 | if(firstchild) RELEASE_WNDOBJ(firstchild);
|
|---|
| 3090 | dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
|
|---|
| 3091 | return hwndChild;
|
|---|
| 3092 | }
|
|---|
| 3093 | child = (Win32BaseWindow *)child->getNextChild();
|
|---|
| 3094 | }
|
|---|
| 3095 | unlock(&critsect);
|
|---|
| 3096 | if(parent) RELEASE_WNDOBJ(parent);
|
|---|
| 3097 | if(firstchild) RELEASE_WNDOBJ(firstchild);
|
|---|
| 3098 | }
|
|---|
| 3099 | else {
|
|---|
| 3100 | Win32BaseWindow *wnd;
|
|---|
| 3101 | HWND henum, hwnd;
|
|---|
| 3102 |
|
|---|
| 3103 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
|
|---|
| 3104 | hwnd = OSLibWinGetNextWindow(henum);
|
|---|
| 3105 |
|
|---|
| 3106 | while(hwnd)
|
|---|
| 3107 | {
|
|---|
| 3108 | wnd = GetWindowFromOS2FrameHandle(hwnd);
|
|---|
| 3109 | if(wnd == NULL) {
|
|---|
| 3110 | hwnd = OSLibWinQueryClientWindow(hwnd);
|
|---|
| 3111 | if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
|
|---|
| 3112 | }
|
|---|
| 3113 |
|
|---|
| 3114 | if(wnd) {
|
|---|
| 3115 | //According to Wine, the class doesn't need to be specified
|
|---|
| 3116 | if((!atom || wnd->getWindowClass()->getAtom() == atom) &&
|
|---|
| 3117 | (!lpszWindow || wnd->hasWindowName(lpszWindow)))
|
|---|
| 3118 | {
|
|---|
| 3119 | OSLibWinEndEnumWindows(henum);
|
|---|
| 3120 | dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
|
|---|
| 3121 | HWND hwndret = wnd->getWindowHandle();
|
|---|
| 3122 | RELEASE_WNDOBJ(wnd);
|
|---|
| 3123 | return hwndret;
|
|---|
| 3124 | }
|
|---|
| 3125 | RELEASE_WNDOBJ(wnd);
|
|---|
| 3126 | }
|
|---|
| 3127 | hwnd = OSLibWinGetNextWindow(henum);
|
|---|
| 3128 | }
|
|---|
| 3129 | OSLibWinEndEnumWindows(henum);
|
|---|
| 3130 | if(parent) RELEASE_WNDOBJ(parent);
|
|---|
| 3131 | if(firstchild) RELEASE_WNDOBJ(firstchild);
|
|---|
| 3132 | }
|
|---|
| 3133 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
|
|---|
| 3134 | return 0;
|
|---|
| 3135 | }
|
|---|
| 3136 | //******************************************************************************
|
|---|
| 3137 | //******************************************************************************
|
|---|
| 3138 | HWND Win32BaseWindow::GetWindow(UINT uCmd)
|
|---|
| 3139 | {
|
|---|
| 3140 | HWND hwndRelated = 0;
|
|---|
| 3141 | Win32BaseWindow *window;
|
|---|
| 3142 |
|
|---|
| 3143 | switch(uCmd)
|
|---|
| 3144 | {
|
|---|
| 3145 | case GW_HWNDFIRST:
|
|---|
| 3146 | window = (Win32BaseWindow *)getParent();
|
|---|
| 3147 | if(window)
|
|---|
| 3148 | {
|
|---|
| 3149 | hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_TOP);
|
|---|
| 3150 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
|---|
| 3151 | if(window) {
|
|---|
| 3152 | hwndRelated = window->getWindowHandle();
|
|---|
| 3153 | RELEASE_WNDOBJ(window);
|
|---|
| 3154 | }
|
|---|
| 3155 | else hwndRelated = 0;
|
|---|
| 3156 | }
|
|---|
| 3157 | else {
|
|---|
| 3158 | dprintf(("WARNING: GW_HWNDFIRST not correctly implemented for toplevel/most windows!"));
|
|---|
| 3159 | hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
|
|---|
| 3160 | }
|
|---|
| 3161 | break;
|
|---|
| 3162 |
|
|---|
| 3163 | case GW_HWNDLAST:
|
|---|
| 3164 | window = (Win32BaseWindow *)getParent();
|
|---|
| 3165 | if(window) {
|
|---|
| 3166 | hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_BOTTOM);
|
|---|
| 3167 | dprintf(("os2 handle %x", hwndRelated));
|
|---|
| 3168 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
|---|
| 3169 | if(window) {
|
|---|
| 3170 | hwndRelated = window->getWindowHandle();
|
|---|
| 3171 | RELEASE_WNDOBJ(window);
|
|---|
| 3172 | }
|
|---|
| 3173 | else hwndRelated = 0;
|
|---|
| 3174 | }
|
|---|
| 3175 | else {
|
|---|
| 3176 | dprintf(("WARNING: GW_HWNDLAST not correctly implemented for toplevel/most windows!"));
|
|---|
| 3177 | hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
|
|---|
| 3178 | }
|
|---|
| 3179 | break;
|
|---|
| 3180 |
|
|---|
| 3181 | case GW_HWNDNEXT:
|
|---|
| 3182 | if(getParent()) {
|
|---|
| 3183 | hwndRelated = OSLibWinQueryWindow(getOS2FrameWindowHandle(), QWOS_NEXT);
|
|---|
| 3184 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
|---|
| 3185 | if(window) {
|
|---|
| 3186 | hwndRelated = window->getWindowHandle();
|
|---|
| 3187 | RELEASE_WNDOBJ(window);
|
|---|
| 3188 | }
|
|---|
| 3189 | else hwndRelated = 0;
|
|---|
| 3190 | }
|
|---|
| 3191 | else {
|
|---|
| 3192 | dprintf(("WARNING: GW_HWNDNEXT not correctly implemented for toplevel/most windows!"));
|
|---|
| 3193 | hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
|
|---|
| 3194 | }
|
|---|
| 3195 | break;
|
|---|
| 3196 |
|
|---|
| 3197 | case GW_HWNDPREV:
|
|---|
| 3198 | if(getParent()) {
|
|---|
| 3199 | hwndRelated = OSLibWinQueryWindow(getOS2FrameWindowHandle(), QWOS_PREV);
|
|---|
| 3200 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
|---|
| 3201 | if(window) {
|
|---|
| 3202 | hwndRelated = window->getWindowHandle();
|
|---|
| 3203 | RELEASE_WNDOBJ(window);
|
|---|
| 3204 | }
|
|---|
| 3205 | else hwndRelated = 0;
|
|---|
| 3206 | }
|
|---|
| 3207 | else {
|
|---|
| 3208 | dprintf(("WARNING: GW_HWNDPREV not correctly implemented for toplevel/most windows!"));
|
|---|
| 3209 | hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
|
|---|
| 3210 | }
|
|---|
| 3211 | break;
|
|---|
| 3212 |
|
|---|
| 3213 | case GW_OWNER:
|
|---|
| 3214 | {
|
|---|
| 3215 | Win32BaseWindow *owner = getOwner();
|
|---|
| 3216 | if(owner) {
|
|---|
| 3217 | hwndRelated = owner->getWindowHandle();
|
|---|
| 3218 | }
|
|---|
| 3219 | break;
|
|---|
| 3220 | }
|
|---|
| 3221 |
|
|---|
| 3222 | case GW_CHILD:
|
|---|
| 3223 | hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
|
|---|
| 3224 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
|---|
| 3225 |
|
|---|
| 3226 | //Before a window has processed WM_NCCREATE:
|
|---|
| 3227 | //- GetWindow(parent, GW_CHILD) can't return that window handle
|
|---|
| 3228 | //(verified in NT4, SP6)
|
|---|
| 3229 | if(window) {
|
|---|
| 3230 | if(window->state >= STATE_POST_WMNCCREATE) {
|
|---|
| 3231 | hwndRelated = window->getWindowHandle();
|
|---|
| 3232 | RELEASE_WNDOBJ(window);
|
|---|
| 3233 | }
|
|---|
| 3234 | else {
|
|---|
| 3235 | hwndRelated = window->GetWindow(GW_HWNDNEXT);
|
|---|
| 3236 | RELEASE_WNDOBJ(window);
|
|---|
| 3237 | }
|
|---|
| 3238 | }
|
|---|
| 3239 | else hwndRelated = 0;
|
|---|
| 3240 |
|
|---|
| 3241 | break;
|
|---|
| 3242 |
|
|---|
| 3243 | //for internal use only
|
|---|
| 3244 | case GW_HWNDNEXTCHILD:
|
|---|
| 3245 | lock();
|
|---|
| 3246 | window = (Win32BaseWindow *)getNextChild();
|
|---|
| 3247 | if(window) {
|
|---|
| 3248 | hwndRelated = window->getWindowHandle();
|
|---|
| 3249 | }
|
|---|
| 3250 | else hwndRelated = 0;
|
|---|
| 3251 | unlock();
|
|---|
| 3252 | break;
|
|---|
| 3253 |
|
|---|
| 3254 | case GW_HWNDPREVCHILD:
|
|---|
| 3255 | DebugInt3();
|
|---|
| 3256 | break;
|
|---|
| 3257 |
|
|---|
| 3258 | case GW_HWNDFIRSTCHILD:
|
|---|
| 3259 | lock();
|
|---|
| 3260 | window = (Win32BaseWindow *)getFirstChild();
|
|---|
| 3261 | if(window) {
|
|---|
| 3262 | hwndRelated = window->getWindowHandle();
|
|---|
| 3263 | }
|
|---|
| 3264 | else hwndRelated = 0;
|
|---|
| 3265 | unlock();
|
|---|
| 3266 | break;
|
|---|
| 3267 |
|
|---|
| 3268 | case GW_HWNDLASTCHILD:
|
|---|
| 3269 | lock();
|
|---|
| 3270 | window = (Win32BaseWindow *)getFirstChild();
|
|---|
| 3271 | if(window) {
|
|---|
| 3272 | while (window->getNextChild())
|
|---|
| 3273 | {
|
|---|
| 3274 | window = (Win32BaseWindow *)window->getNextChild();
|
|---|
| 3275 | }
|
|---|
| 3276 | hwndRelated = window->getWindowHandle();
|
|---|
| 3277 | }
|
|---|
| 3278 | else hwndRelated = 0;
|
|---|
| 3279 | unlock();
|
|---|
| 3280 | break;
|
|---|
| 3281 | }
|
|---|
| 3282 | end:
|
|---|
| 3283 | dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
|
|---|
| 3284 | return hwndRelated;
|
|---|
| 3285 | }
|
|---|
| 3286 | //******************************************************************************
|
|---|
| 3287 | //******************************************************************************
|
|---|
| 3288 | HWND Win32BaseWindow::SetActiveWindow()
|
|---|
| 3289 | {
|
|---|
| 3290 | HWND hwndActive;
|
|---|
| 3291 |
|
|---|
| 3292 | dprintf(("SetActiveWindow %x", getWindowHandle()));
|
|---|
| 3293 | if(getStyle() & WS_CHILD) {
|
|---|
| 3294 | // if(getStyle() & (WS_DISABLED | WS_CHILD)) {
|
|---|
| 3295 | dprintf(("WARNING: Window is a child or disabled"));
|
|---|
| 3296 | return 0;
|
|---|
| 3297 | }
|
|---|
| 3298 |
|
|---|
| 3299 | if(GetActiveWindow() == getWindowHandle()) {
|
|---|
| 3300 | dprintf(("Window already active"));
|
|---|
| 3301 | return getWindowHandle();
|
|---|
| 3302 | }
|
|---|
| 3303 | if (HOOK_IsHooked( WH_CBT ))
|
|---|
| 3304 | {
|
|---|
| 3305 | CBTACTIVATESTRUCT cbta;
|
|---|
| 3306 | LRESULT ret;
|
|---|
| 3307 |
|
|---|
| 3308 | cbta.fMouse = FALSE;
|
|---|
| 3309 | cbta.hWndActive = GetActiveWindow();
|
|---|
| 3310 | ret = HOOK_CallHooksA(WH_CBT, HCBT_ACTIVATE, getWindowHandle(), (LPARAM)&cbta);
|
|---|
| 3311 | if(ret)
|
|---|
| 3312 | {
|
|---|
| 3313 | dprintf(("SetActiveWindow %x, CBT hook cancelled operation", getWindowHandle()));
|
|---|
| 3314 | return cbta.hWndActive;
|
|---|
| 3315 | }
|
|---|
| 3316 | }
|
|---|
| 3317 | SetWindowPos(HWND_TOP, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
|
|---|
| 3318 |
|
|---|
| 3319 | // if(OSLibWinSetActiveWindow(OS2Hwnd) == FALSE) {
|
|---|
| 3320 | // dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2Hwnd));
|
|---|
| 3321 | // }
|
|---|
| 3322 | hwndActive = GetActiveWindow();
|
|---|
| 3323 | return (hwndActive) ? hwndActive : windowDesktop->getWindowHandle(); //pretend the desktop was active
|
|---|
| 3324 | }
|
|---|
| 3325 | //******************************************************************************
|
|---|
| 3326 | //Used to change active status of an mdi window
|
|---|
| 3327 | //******************************************************************************
|
|---|
| 3328 | BOOL Win32BaseWindow::DeactivateChildWindow()
|
|---|
| 3329 | {
|
|---|
| 3330 | /* child windows get a WM_CHILDACTIVATE message */
|
|---|
| 3331 | if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
|
|---|
| 3332 | {
|
|---|
| 3333 | ULONG flags = OSLibWinGetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS);
|
|---|
| 3334 | OSLibWinSetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS, (flags & ~WINDOWFLAG_ACTIVE));
|
|---|
| 3335 | return TRUE;
|
|---|
| 3336 | }
|
|---|
| 3337 | DebugInt3(); //should not be called for non-child window
|
|---|
| 3338 | return FALSE;
|
|---|
| 3339 | }
|
|---|
| 3340 | //******************************************************************************
|
|---|
| 3341 | //WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
|
|---|
| 3342 | //******************************************************************************
|
|---|
| 3343 | BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
|
|---|
| 3344 | {
|
|---|
| 3345 | BOOL rc;
|
|---|
| 3346 |
|
|---|
| 3347 | dprintf(("Win32BaseWindow::EnableWindow %x %d", getWindowHandle(), fEnable));
|
|---|
| 3348 | //return true if previous state was disabled, else false (sdk docs)
|
|---|
| 3349 | rc = (getStyle() & WS_DISABLED) != 0;
|
|---|
| 3350 | if(rc && !fEnable) {
|
|---|
| 3351 | SendMessageA(getWindowHandle(), WM_CANCELMODE, 0, 0);
|
|---|
| 3352 | }
|
|---|
| 3353 | OSLibWinEnableWindow(OS2HwndFrame, fEnable);
|
|---|
| 3354 | if(fEnable == FALSE) {
|
|---|
| 3355 | //SvL: No need to clear focus as PM already does this
|
|---|
| 3356 | if(getWindowHandle() == GetCapture()) {
|
|---|
| 3357 | ReleaseCapture(); /* A disabled window can't capture the mouse */
|
|---|
| 3358 | dprintf(("Released capture for window %x that is being disabled", getWindowHandle()));
|
|---|
| 3359 | }
|
|---|
| 3360 | }
|
|---|
| 3361 | return rc;
|
|---|
| 3362 | }
|
|---|
| 3363 | //******************************************************************************
|
|---|
| 3364 | //******************************************************************************
|
|---|
| 3365 | BOOL Win32BaseWindow::CloseWindow()
|
|---|
| 3366 | {
|
|---|
| 3367 | if (::GetWindowLongW( getWindowHandle() , GWL_STYLE ) & WS_CHILD) return FALSE;
|
|---|
| 3368 | ShowWindow( SW_MINIMIZE );
|
|---|
| 3369 | return TRUE;
|
|---|
| 3370 | }
|
|---|
| 3371 | //******************************************************************************
|
|---|
| 3372 | //TODO: Not be 100% correct; should return active window of current thread
|
|---|
| 3373 | // or NULL when there is none -> WinQueryActiveWindow just returns
|
|---|
| 3374 | // the current active window
|
|---|
| 3375 | //******************************************************************************
|
|---|
| 3376 | HWND Win32BaseWindow::GetActiveWindow()
|
|---|
| 3377 | {
|
|---|
| 3378 | HWND hwndActive;
|
|---|
| 3379 |
|
|---|
| 3380 | hwndActive = OSLibWinQueryActiveWindow();
|
|---|
| 3381 | return OS2ToWin32Handle(hwndActive);
|
|---|
| 3382 | }
|
|---|
| 3383 | //******************************************************************************
|
|---|
| 3384 | //******************************************************************************
|
|---|
| 3385 | BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
|
|---|
| 3386 | {
|
|---|
| 3387 | INT len = GetWindowTextLength(fUnicode);
|
|---|
| 3388 | BOOL res;
|
|---|
| 3389 |
|
|---|
| 3390 | if (wndname == NULL)
|
|---|
| 3391 | return (len == 0);
|
|---|
| 3392 |
|
|---|
| 3393 | len++;
|
|---|
| 3394 | if (fUnicode)
|
|---|
| 3395 | {
|
|---|
| 3396 | WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
|
|---|
| 3397 |
|
|---|
| 3398 | GetWindowTextW(text,len);
|
|---|
| 3399 | res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
|
|---|
| 3400 | free(text);
|
|---|
| 3401 | }
|
|---|
| 3402 | else
|
|---|
| 3403 | {
|
|---|
| 3404 | CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
|
|---|
| 3405 |
|
|---|
| 3406 | GetWindowTextA(text,len);
|
|---|
| 3407 | res = (strcmp(text,wndname) == 0);
|
|---|
| 3408 | free(text);
|
|---|
| 3409 | }
|
|---|
| 3410 |
|
|---|
| 3411 | return res;
|
|---|
| 3412 | }
|
|---|
| 3413 | //******************************************************************************
|
|---|
| 3414 | //******************************************************************************
|
|---|
| 3415 | CHAR *Win32BaseWindow::getWindowNamePtrA()
|
|---|
| 3416 | {
|
|---|
| 3417 | INT len = GetWindowTextLength(FALSE);
|
|---|
| 3418 | CHAR *text;
|
|---|
| 3419 |
|
|---|
| 3420 | if (len == 0) return NULL;
|
|---|
| 3421 | len++;
|
|---|
| 3422 | text = (CHAR*)malloc(len*sizeof(CHAR));
|
|---|
| 3423 | GetWindowTextA(text,len);
|
|---|
| 3424 |
|
|---|
| 3425 | return text;
|
|---|
| 3426 | }
|
|---|
| 3427 | //******************************************************************************
|
|---|
| 3428 | //******************************************************************************
|
|---|
| 3429 | WCHAR *Win32BaseWindow::getWindowNamePtrW()
|
|---|
| 3430 | {
|
|---|
| 3431 | INT len = GetWindowTextLength(TRUE);
|
|---|
| 3432 | WCHAR *text;
|
|---|
| 3433 |
|
|---|
| 3434 | if (len == 0) return NULL;
|
|---|
| 3435 | len++;
|
|---|
| 3436 | text = (WCHAR*)malloc(len*sizeof(WCHAR));
|
|---|
| 3437 | GetWindowTextW(text,len);
|
|---|
| 3438 |
|
|---|
| 3439 | return text;
|
|---|
| 3440 | }
|
|---|
| 3441 | //******************************************************************************
|
|---|
| 3442 | //******************************************************************************
|
|---|
| 3443 | VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
|
|---|
| 3444 | {
|
|---|
| 3445 | if (namePtr) free(namePtr);
|
|---|
| 3446 | }
|
|---|
| 3447 | //******************************************************************************
|
|---|
| 3448 | //When using this API for a window that was created by a different process, NT
|
|---|
| 3449 | //does NOT send WM_GETTEXTLENGTH.
|
|---|
| 3450 | //******************************************************************************
|
|---|
| 3451 | int Win32BaseWindow::GetWindowTextLength(BOOL fUnicode)
|
|---|
| 3452 | {
|
|---|
| 3453 | //if the destination window is created by this process, send message
|
|---|
| 3454 | if(dwProcessId == currentProcessId)
|
|---|
| 3455 | {
|
|---|
| 3456 | if(fUnicode) {
|
|---|
| 3457 | return SendMessageW(getWindowHandle(), WM_GETTEXTLENGTH,0,0);
|
|---|
| 3458 | }
|
|---|
| 3459 | else return SendMessageA(getWindowHandle(), WM_GETTEXTLENGTH,0,0);
|
|---|
| 3460 | }
|
|---|
| 3461 | //else get data directory from window structure
|
|---|
| 3462 | //TODO: must lock window structure.... (TODO)
|
|---|
| 3463 | return windowNameLength;
|
|---|
| 3464 | }
|
|---|
| 3465 | //******************************************************************************
|
|---|
| 3466 | //When using this API for a window that was created by a different process, NT
|
|---|
| 3467 | //does NOT send WM_GETTEXT.
|
|---|
| 3468 | //******************************************************************************
|
|---|
| 3469 | int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
|
|---|
| 3470 | {
|
|---|
| 3471 | //if the destination window is created by this process, send message
|
|---|
| 3472 | if(dwProcessId == currentProcessId) {
|
|---|
| 3473 | return SendMessageA(getWindowHandle(),WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
|
|---|
| 3474 | }
|
|---|
| 3475 |
|
|---|
| 3476 | //else get data directory from window structure
|
|---|
| 3477 | if (!lpsz || !cch) return 0;
|
|---|
| 3478 | if (!windowNameA) lpsz[0] = 0;
|
|---|
| 3479 | else memcpy(lpsz, windowNameA, min(windowNameLength + 1, cch) );
|
|---|
| 3480 | return min(windowNameLength, cch);
|
|---|
| 3481 | }
|
|---|
| 3482 | //******************************************************************************
|
|---|
| 3483 | //When using this API for a window that was created by a different process, NT
|
|---|
| 3484 | //does NOT send WM_GETTEXT.
|
|---|
| 3485 | //******************************************************************************
|
|---|
| 3486 | int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
|
|---|
| 3487 | {
|
|---|
| 3488 | //if the destination window is created by this process, send message
|
|---|
| 3489 | if(dwProcessId == currentProcessId) {
|
|---|
| 3490 | return ::SendMessageW(getWindowHandle(), WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
|
|---|
| 3491 | }
|
|---|
| 3492 | //else get data directory from window structure
|
|---|
| 3493 | if (!lpsz || !cch)
|
|---|
| 3494 | return 0;
|
|---|
| 3495 | if (!windowNameW)
|
|---|
| 3496 | lpsz[0] = 0;
|
|---|
| 3497 | else
|
|---|
| 3498 | memcpy(lpsz, windowNameW, min( sizeof(WCHAR) * (windowNameLength+1), cch));
|
|---|
| 3499 |
|
|---|
| 3500 | return min(windowNameLength, cch);
|
|---|
| 3501 | }
|
|---|
| 3502 | //******************************************************************************
|
|---|
| 3503 | //TODO: How does this work when the target window belongs to a different process???
|
|---|
| 3504 | //******************************************************************************
|
|---|
| 3505 | BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
|
|---|
| 3506 | {
|
|---|
| 3507 | return SendMessageA(getWindowHandle(),WM_SETTEXT,0,(LPARAM)lpsz);
|
|---|
| 3508 | }
|
|---|
| 3509 | //******************************************************************************
|
|---|
| 3510 | //******************************************************************************
|
|---|
| 3511 | BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
|
|---|
| 3512 | {
|
|---|
| 3513 | return SendMessageW(getWindowHandle(), WM_SETTEXT,0,(LPARAM)lpsz);
|
|---|
| 3514 | }
|
|---|
| 3515 | //******************************************************************************
|
|---|
| 3516 | //******************************************************************************
|
|---|
| 3517 | LONG Win32BaseWindow::SetWindowLong(int index, ULONG value, BOOL fUnicode)
|
|---|
| 3518 | {
|
|---|
| 3519 | LONG oldval;
|
|---|
| 3520 |
|
|---|
| 3521 | switch(index) {
|
|---|
| 3522 | case GWL_EXSTYLE:
|
|---|
| 3523 | {
|
|---|
| 3524 | STYLESTRUCT ss;
|
|---|
| 3525 |
|
|---|
| 3526 | if(dwExStyle == value) {
|
|---|
| 3527 | oldval = value;
|
|---|
| 3528 | break;
|
|---|
| 3529 | }
|
|---|
| 3530 | ss.styleOld = dwExStyle;
|
|---|
| 3531 | ss.styleNew = value;
|
|---|
| 3532 | dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
|
|---|
| 3533 | SendMessageA(getWindowHandle(),WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
|
|---|
| 3534 | setExStyle(ss.styleNew);
|
|---|
| 3535 | SendMessageA(getWindowHandle(),WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
|
|---|
| 3536 | oldval = ss.styleOld;
|
|---|
| 3537 | break;
|
|---|
| 3538 | }
|
|---|
| 3539 | case GWL_STYLE:
|
|---|
| 3540 | {
|
|---|
| 3541 | STYLESTRUCT ss;
|
|---|
| 3542 |
|
|---|
| 3543 | //SvL: TODO: Can you change minimize or maximize status here too?
|
|---|
| 3544 |
|
|---|
| 3545 | if(dwStyle == value) {
|
|---|
| 3546 | oldval = value;
|
|---|
| 3547 | break;
|
|---|
| 3548 | }
|
|---|
| 3549 | dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x (%x)", getWindowHandle(), dwStyle, value));
|
|---|
| 3550 | #ifdef DEBUG
|
|---|
| 3551 | // if((value & WS_CHILD) != (dwStyle & WS_CHILD)) {
|
|---|
| 3552 | // DebugInt3(); //is this allowed?
|
|---|
| 3553 | // }
|
|---|
| 3554 | #endif
|
|---|
| 3555 | value &= ~(WS_CHILD);
|
|---|
| 3556 | ss.styleOld = getStyle();
|
|---|
| 3557 | ss.styleNew = value | (ss.styleOld & WS_CHILD);
|
|---|
| 3558 | SendMessageA(getWindowHandle(),WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
|
|---|
| 3559 | setStyle(ss.styleNew);
|
|---|
| 3560 | SendMessageA(getWindowHandle(),WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
|
|---|
| 3561 | OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(), getStyle(), getExStyle());
|
|---|
| 3562 |
|
|---|
| 3563 | //TODO: Might not be correct to use ShowWindow here
|
|---|
| 3564 | if((ss.styleOld & WS_VISIBLE) != (ss.styleNew & WS_VISIBLE)) {
|
|---|
| 3565 | if(ss.styleNew & WS_VISIBLE)
|
|---|
| 3566 | ShowWindow(SW_SHOWNOACTIVATE);
|
|---|
| 3567 | else ShowWindow(SW_HIDE);
|
|---|
| 3568 | }
|
|---|
| 3569 | #ifdef DEBUG
|
|---|
| 3570 | PrintWindowStyle(ss.styleNew, 0);
|
|---|
| 3571 | #endif
|
|---|
| 3572 | oldval = ss.styleOld;
|
|---|
| 3573 | break;
|
|---|
| 3574 | }
|
|---|
| 3575 | case GWL_WNDPROC:
|
|---|
| 3576 | {
|
|---|
| 3577 | //Note: Type of SetWindowLong determines new window proc type
|
|---|
| 3578 | // UNLESS the new window proc has already been registered
|
|---|
| 3579 | // (use the old type in that case)
|
|---|
| 3580 | // (VERIFIED in NT 4, SP6)
|
|---|
| 3581 | WINDOWPROCTYPE type = WINPROC_GetProcType((HWINDOWPROC)value);
|
|---|
| 3582 | if(type == WIN_PROC_INVALID) {
|
|---|
| 3583 | type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A;
|
|---|
| 3584 | }
|
|---|
| 3585 | oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
|
|---|
| 3586 | dprintf(("SetWindowLong%c GWL_WNDPROC %x old %x new wndproc %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), oldval, value));
|
|---|
| 3587 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, type, WIN_PROC_WINDOW);
|
|---|
| 3588 | break;
|
|---|
| 3589 | }
|
|---|
| 3590 | case GWL_HINSTANCE:
|
|---|
| 3591 | oldval = hInstance;
|
|---|
| 3592 | hInstance = value;
|
|---|
| 3593 | break;
|
|---|
| 3594 |
|
|---|
| 3595 | case GWL_HWNDPARENT:
|
|---|
| 3596 | oldval = SetParent((HWND)value);
|
|---|
| 3597 | break;
|
|---|
| 3598 |
|
|---|
| 3599 | case GWL_ID:
|
|---|
| 3600 | dprintf(("GWL_ID old %x, new %x", getWindowId(), value));
|
|---|
| 3601 | oldval = getWindowId();
|
|---|
| 3602 | setWindowId(value);
|
|---|
| 3603 | break;
|
|---|
| 3604 |
|
|---|
| 3605 | case GWL_USERDATA:
|
|---|
| 3606 | oldval = userData;
|
|---|
| 3607 | userData = value;
|
|---|
| 3608 | break;
|
|---|
| 3609 |
|
|---|
| 3610 | default:
|
|---|
| 3611 | if(index >= 0 && index + sizeof(ULONG) <= nrUserWindowBytes)
|
|---|
| 3612 | {
|
|---|
| 3613 | oldval = *(ULONG *)(userWindowBytes + index);
|
|---|
| 3614 | *(ULONG *)(userWindowBytes + index) = value;
|
|---|
| 3615 | break;
|
|---|
| 3616 | }
|
|---|
| 3617 | dprintf(("WARNING: SetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
|
|---|
| 3618 | SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
|
|---|
| 3619 | return 0;
|
|---|
| 3620 | }
|
|---|
| 3621 | //Note: NT4, SP6 does not set the last error to 0
|
|---|
| 3622 | SetLastError(ERROR_SUCCESS);
|
|---|
| 3623 | dprintf2(("SetWindowLong%c %x %d %x returned %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value, oldval));
|
|---|
| 3624 | return oldval;
|
|---|
| 3625 | }
|
|---|
| 3626 | //******************************************************************************
|
|---|
| 3627 | //******************************************************************************
|
|---|
| 3628 | ULONG Win32BaseWindow::GetWindowLong(int index, BOOL fUnicode)
|
|---|
| 3629 | {
|
|---|
| 3630 | ULONG value;
|
|---|
| 3631 |
|
|---|
| 3632 | switch(index) {
|
|---|
| 3633 | case GWL_EXSTYLE:
|
|---|
| 3634 | value = dwExStyle;
|
|---|
| 3635 | break;
|
|---|
| 3636 | case GWL_STYLE:
|
|---|
| 3637 | value = dwStyle;
|
|---|
| 3638 | break;
|
|---|
| 3639 | case GWL_WNDPROC:
|
|---|
| 3640 | value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
|
|---|
| 3641 | break;
|
|---|
| 3642 | case GWL_HINSTANCE:
|
|---|
| 3643 | value = hInstance;
|
|---|
| 3644 | break;
|
|---|
| 3645 | case GWL_HWNDPARENT:
|
|---|
| 3646 | value = GetParent();
|
|---|
| 3647 | break;
|
|---|
| 3648 | case GWL_ID:
|
|---|
| 3649 | value = getWindowId();
|
|---|
| 3650 | break;
|
|---|
| 3651 | case GWL_USERDATA:
|
|---|
| 3652 | value = userData;
|
|---|
| 3653 | break;
|
|---|
| 3654 | default:
|
|---|
| 3655 | if(index >= 0 && index + sizeof(ULONG) <= nrUserWindowBytes)
|
|---|
| 3656 | {
|
|---|
| 3657 | value = *(ULONG *)(userWindowBytes + index);
|
|---|
| 3658 | break;
|
|---|
| 3659 | }
|
|---|
| 3660 | dprintf(("WARNING: GetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
|
|---|
| 3661 | SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
|
|---|
| 3662 | return 0;
|
|---|
| 3663 | }
|
|---|
| 3664 | dprintf2(("GetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
|
|---|
| 3665 | //Note: NT4, SP6 does not set the last error to 0
|
|---|
| 3666 | SetLastError(ERROR_SUCCESS);
|
|---|
| 3667 | return value;
|
|---|
| 3668 | }
|
|---|
| 3669 | //******************************************************************************
|
|---|
| 3670 | //******************************************************************************
|
|---|
| 3671 | WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
|
|---|
| 3672 | {
|
|---|
| 3673 | WORD oldval;
|
|---|
| 3674 |
|
|---|
| 3675 | if(index >= 0 && index + sizeof(WORD) <= nrUserWindowBytes)
|
|---|
| 3676 | {
|
|---|
| 3677 | oldval = *(WORD *)(userWindowBytes + index);
|
|---|
| 3678 | *(WORD *)(userWindowBytes + index) = value;
|
|---|
| 3679 | //Note: NT4, SP6 does not set the last error to 0
|
|---|
| 3680 | dprintf2(("SetWindowWord %x %d %x returned %x", getWindowHandle(), index, value, oldval));
|
|---|
| 3681 | SetLastError(ERROR_SUCCESS);
|
|---|
| 3682 | return oldval;
|
|---|
| 3683 | }
|
|---|
| 3684 | switch(index)
|
|---|
| 3685 | {
|
|---|
| 3686 | case GWW_HINSTANCE:
|
|---|
| 3687 | oldval = hInstance;
|
|---|
| 3688 | hInstance = value;
|
|---|
| 3689 | break;
|
|---|
| 3690 |
|
|---|
| 3691 | case GWW_HWNDPARENT:
|
|---|
| 3692 | oldval = SetParent((HWND)(WNDHANDLE_MAGIC_HIGHWORD | value));
|
|---|
| 3693 | break;
|
|---|
| 3694 |
|
|---|
| 3695 | case GWW_ID:
|
|---|
| 3696 | oldval = getWindowId();
|
|---|
| 3697 | setWindowId(value);
|
|---|
| 3698 | break;
|
|---|
| 3699 |
|
|---|
| 3700 | default:
|
|---|
| 3701 | dprintf(("WARNING: SetWindowWord %x %d %x returned %x INVALID index!", getWindowHandle(), index, value));
|
|---|
| 3702 | SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
|
|---|
| 3703 | return 0;
|
|---|
| 3704 | }
|
|---|
| 3705 | //Note: NT4, SP6 does not set the last error to 0
|
|---|
| 3706 | SetLastError(ERROR_SUCCESS);
|
|---|
| 3707 | dprintf2(("SetWindowWord %x %d %x returned %x", getWindowHandle(), index, value, oldval));
|
|---|
| 3708 | return oldval;
|
|---|
| 3709 | }
|
|---|
| 3710 | //******************************************************************************
|
|---|
| 3711 | //******************************************************************************
|
|---|
| 3712 | WORD Win32BaseWindow::GetWindowWord(int index)
|
|---|
| 3713 | {
|
|---|
| 3714 | if(index >= 0 && index + sizeof(WORD) <= nrUserWindowBytes)
|
|---|
| 3715 | {
|
|---|
| 3716 | //Note: NT4, SP6 does not set the last error to 0
|
|---|
| 3717 | SetLastError(ERROR_SUCCESS);
|
|---|
| 3718 | dprintf2(("GetWindowWord %x %d %x", getWindowHandle(), index, *(WORD *)(userWindowBytes + index)));
|
|---|
| 3719 | return *(WORD *)(userWindowBytes + index);
|
|---|
| 3720 | }
|
|---|
| 3721 | switch(index)
|
|---|
| 3722 | {
|
|---|
| 3723 | case GWW_ID:
|
|---|
| 3724 | if(HIWORD(getWindowId()))
|
|---|
| 3725 | dprintf(("WARNING: GWW_ID: discards high bits of 0x%08x!\n", getWindowId()));
|
|---|
| 3726 | return (WORD)getWindowId();
|
|---|
| 3727 |
|
|---|
| 3728 | case GWW_HWNDPARENT:
|
|---|
| 3729 | dprintf(("WARNING: GWW_HWNDPARENT: discards high bits of 0x%08x!\n", GetParent()));
|
|---|
| 3730 | return (WORD) GetParent();
|
|---|
| 3731 |
|
|---|
| 3732 | case GWW_HINSTANCE:
|
|---|
| 3733 | if (HIWORD(hInstance))
|
|---|
| 3734 | dprintf(("WARNING: GWW_HINSTANCE: discards high bits of 0x%08x!\n", hInstance));
|
|---|
| 3735 | return (WORD)hInstance;
|
|---|
| 3736 | }
|
|---|
| 3737 |
|
|---|
| 3738 | dprintf(("WARNING: GetWindowWord %x %d returned %x INVALID index!", getWindowHandle(), index));
|
|---|
| 3739 | SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
|
|---|
| 3740 | return 0;
|
|---|
| 3741 | }
|
|---|
| 3742 | //******************************************************************************
|
|---|
| 3743 | //Locates window in linked list and increases reference count (if found)
|
|---|
| 3744 | //Window object must be unreferenced after usage
|
|---|
| 3745 | //******************************************************************************
|
|---|
| 3746 | Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
|
|---|
| 3747 | {
|
|---|
| 3748 | Win32BaseWindow *window;
|
|---|
| 3749 |
|
|---|
| 3750 | ////TODO: temporary workaround for crashes in Opera (pmwinx; releasesemaphore)
|
|---|
| 3751 | //// while browsing
|
|---|
| 3752 | //// Not thread safe now!
|
|---|
| 3753 | //// lock(&critsect);
|
|---|
| 3754 | if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
|
|---|
| 3755 | if(window) {
|
|---|
| 3756 | //// dprintf(("addRef %x; refcount %d", hwnd, window->getRefCount()+1));
|
|---|
| 3757 | window->addRef();
|
|---|
| 3758 | }
|
|---|
| 3759 | //// unlock(&critsect);
|
|---|
| 3760 | return window;
|
|---|
| 3761 | }
|
|---|
| 3762 | //// unlock(&critsect);
|
|---|
| 3763 | // dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
|
|---|
| 3764 | return NULL;
|
|---|
| 3765 | }
|
|---|
| 3766 | //******************************************************************************
|
|---|
| 3767 | //Locates window in linked list and increases reference count (if found)
|
|---|
| 3768 | //Window object must be unreferenced after usage
|
|---|
| 3769 | //******************************************************************************
|
|---|
| 3770 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwndOS2)
|
|---|
| 3771 | {
|
|---|
| 3772 | DWORD magic;
|
|---|
| 3773 | HWND hwnd;
|
|---|
| 3774 |
|
|---|
| 3775 | if(hwndOS2 == OSLIB_HWND_DESKTOP)
|
|---|
| 3776 | {
|
|---|
| 3777 | windowDesktop->addRef();
|
|---|
| 3778 | return windowDesktop;
|
|---|
| 3779 | }
|
|---|
| 3780 |
|
|---|
| 3781 | hwnd = (HWND)OSLibWinGetWindowULong(hwndOS2, OFFSET_WIN32WNDPTR);
|
|---|
| 3782 | magic = OSLibWinGetWindowULong(hwndOS2, OFFSET_WIN32PM_MAGIC);
|
|---|
| 3783 |
|
|---|
| 3784 | if(hwnd && CheckMagicDword(magic)) {
|
|---|
| 3785 | return GetWindowFromHandle(hwnd);
|
|---|
| 3786 | }
|
|---|
| 3787 | // dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwndOS2));
|
|---|
| 3788 | return 0;
|
|---|
| 3789 | }
|
|---|
| 3790 | //******************************************************************************
|
|---|
| 3791 | //Locates window in linked list and increases reference count (if found)
|
|---|
| 3792 | //Window object must be unreferenced after usage
|
|---|
| 3793 | //******************************************************************************
|
|---|
| 3794 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
|
|---|
| 3795 | {
|
|---|
| 3796 | return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
|
|---|
| 3797 | }
|
|---|
| 3798 | //******************************************************************************
|
|---|
| 3799 | //******************************************************************************
|
|---|
| 3800 | HWND WIN32API Win32ToOS2Handle(HWND hwnd)
|
|---|
| 3801 | {
|
|---|
| 3802 | HWND hwndOS2;
|
|---|
| 3803 |
|
|---|
| 3804 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 3805 |
|
|---|
| 3806 | if(window) {
|
|---|
| 3807 | hwndOS2 = window->getOS2WindowHandle();
|
|---|
| 3808 | RELEASE_WNDOBJ(window);
|
|---|
| 3809 | return hwndOS2;
|
|---|
| 3810 | }
|
|---|
| 3811 | // dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
|
|---|
| 3812 | return hwnd;
|
|---|
| 3813 | }
|
|---|
| 3814 | //******************************************************************************
|
|---|
| 3815 | //******************************************************************************
|
|---|
| 3816 | HWND WIN32API Win32ToOS2FrameHandle(HWND hwnd)
|
|---|
| 3817 | {
|
|---|
| 3818 | HWND hwndOS2;
|
|---|
| 3819 |
|
|---|
| 3820 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 3821 |
|
|---|
| 3822 | if(window) {
|
|---|
| 3823 | hwndOS2 = window->getOS2FrameWindowHandle();
|
|---|
| 3824 | RELEASE_WNDOBJ(window);
|
|---|
| 3825 | return hwndOS2;
|
|---|
| 3826 | }
|
|---|
| 3827 | // dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
|
|---|
| 3828 | return hwnd;
|
|---|
| 3829 | }
|
|---|
| 3830 | //******************************************************************************
|
|---|
| 3831 | //******************************************************************************
|
|---|
| 3832 | HWND WIN32API OS2ToWin32Handle(HWND hwnd)
|
|---|
| 3833 | {
|
|---|
| 3834 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 3835 | HWND hwndWin32;
|
|---|
| 3836 |
|
|---|
| 3837 | if(window) {
|
|---|
| 3838 | hwndWin32 = window->getWindowHandle();
|
|---|
| 3839 | RELEASE_WNDOBJ(window);
|
|---|
| 3840 | return hwndWin32;
|
|---|
| 3841 | }
|
|---|
| 3842 | window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
|---|
| 3843 | if(window) {
|
|---|
| 3844 | hwndWin32 = window->getWindowHandle();
|
|---|
| 3845 | RELEASE_WNDOBJ(window);
|
|---|
| 3846 | return hwndWin32;
|
|---|
| 3847 | }
|
|---|
| 3848 |
|
|---|
| 3849 | // dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
|
|---|
| 3850 | return 0;
|
|---|
| 3851 | // else return hwnd; //OS/2 window handle
|
|---|
| 3852 | }
|
|---|
| 3853 | #ifdef DEBUG
|
|---|
| 3854 | LONG Win32BaseWindow::addRef()
|
|---|
| 3855 | {
|
|---|
| 3856 | // dprintf2(("addRef %x %d", getWindowHandle(), getRefCount()+1));
|
|---|
| 3857 | return GenericObject::addRef();
|
|---|
| 3858 | }
|
|---|
| 3859 | //******************************************************************************
|
|---|
| 3860 | //******************************************************************************
|
|---|
| 3861 | LONG Win32BaseWindow::release(char *function, int line)
|
|---|
| 3862 | {
|
|---|
| 3863 | // dprintf2(("release %s %d %x %d", function, line, getWindowHandle(), getRefCount()-1));
|
|---|
| 3864 | return GenericObject::release();
|
|---|
| 3865 | }
|
|---|
| 3866 | #endif
|
|---|
| 3867 | //******************************************************************************
|
|---|
| 3868 | //******************************************************************************
|
|---|
| 3869 | GenericObject *Win32BaseWindow::windows = NULL;
|
|---|
| 3870 | CRITICAL_SECTION Win32BaseWindow::critsect = {0};
|
|---|
| 3871 |
|
|---|
| 3872 | //******************************************************************************
|
|---|
| 3873 | //******************************************************************************
|
|---|
| 3874 | #ifdef DEBUG
|
|---|
| 3875 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
|
|---|
| 3876 | {
|
|---|
| 3877 | char style[256] = "";
|
|---|
| 3878 | char exstyle[256] = "";
|
|---|
| 3879 |
|
|---|
| 3880 | /* Window styles */
|
|---|
| 3881 | if(dwStyle & WS_CHILD)
|
|---|
| 3882 | strcat(style, "WS_CHILD ");
|
|---|
| 3883 | if(dwStyle & WS_POPUP)
|
|---|
| 3884 | strcat(style, "WS_POPUP ");
|
|---|
| 3885 | if(dwStyle & WS_VISIBLE)
|
|---|
| 3886 | strcat(style, "WS_VISIBLE ");
|
|---|
| 3887 | if(dwStyle & WS_DISABLED)
|
|---|
| 3888 | strcat(style, "WS_DISABLED ");
|
|---|
| 3889 | if(dwStyle & WS_CLIPSIBLINGS)
|
|---|
| 3890 | strcat(style, "WS_CLIPSIBLINGS ");
|
|---|
| 3891 | if(dwStyle & WS_CLIPCHILDREN)
|
|---|
| 3892 | strcat(style, "WS_CLIPCHILDREN ");
|
|---|
| 3893 | if(dwStyle & WS_MAXIMIZE)
|
|---|
| 3894 | strcat(style, "WS_MAXIMIZE ");
|
|---|
| 3895 | if(dwStyle & WS_MINIMIZE)
|
|---|
| 3896 | strcat(style, "WS_MINIMIZE ");
|
|---|
| 3897 | if(dwStyle & WS_GROUP)
|
|---|
| 3898 | strcat(style, "WS_GROUP ");
|
|---|
| 3899 | if(dwStyle & WS_TABSTOP)
|
|---|
| 3900 | strcat(style, "WS_TABSTOP ");
|
|---|
| 3901 |
|
|---|
| 3902 | if((dwStyle & WS_CAPTION) == WS_CAPTION)
|
|---|
| 3903 | strcat(style, "WS_CAPTION ");
|
|---|
| 3904 | if(dwStyle & WS_DLGFRAME)
|
|---|
| 3905 | strcat(style, "WS_DLGFRAME ");
|
|---|
| 3906 | if(dwStyle & WS_BORDER)
|
|---|
| 3907 | strcat(style, "WS_BORDER ");
|
|---|
| 3908 |
|
|---|
| 3909 | if(dwStyle & WS_VSCROLL)
|
|---|
| 3910 | strcat(style, "WS_VSCROLL ");
|
|---|
| 3911 | if(dwStyle & WS_HSCROLL)
|
|---|
| 3912 | strcat(style, "WS_HSCROLL ");
|
|---|
| 3913 | if(dwStyle & WS_SYSMENU)
|
|---|
| 3914 | strcat(style, "WS_SYSMENU ");
|
|---|
| 3915 | if(dwStyle & WS_THICKFRAME)
|
|---|
| 3916 | strcat(style, "WS_THICKFRAME ");
|
|---|
| 3917 | if(dwStyle & WS_MINIMIZEBOX)
|
|---|
| 3918 | strcat(style, "WS_MINIMIZEBOX ");
|
|---|
| 3919 | if(dwStyle & WS_MAXIMIZEBOX)
|
|---|
| 3920 | strcat(style, "WS_MAXIMIZEBOX ");
|
|---|
| 3921 |
|
|---|
| 3922 | if(dwExStyle & WS_EX_DLGMODALFRAME)
|
|---|
| 3923 | strcat(exstyle, "WS_EX_DLGMODALFRAME ");
|
|---|
| 3924 | if(dwExStyle & WS_EX_ACCEPTFILES)
|
|---|
| 3925 | strcat(exstyle, "WS_EX_ACCEPTFILES ");
|
|---|
| 3926 | if(dwExStyle & WS_EX_NOPARENTNOTIFY)
|
|---|
| 3927 | strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
|
|---|
| 3928 | if(dwExStyle & WS_EX_TOPMOST)
|
|---|
| 3929 | strcat(exstyle, "WS_EX_TOPMOST ");
|
|---|
| 3930 | if(dwExStyle & WS_EX_TRANSPARENT)
|
|---|
| 3931 | strcat(exstyle, "WS_EX_TRANSPARENT ");
|
|---|
| 3932 |
|
|---|
| 3933 | if(dwExStyle & WS_EX_MDICHILD)
|
|---|
| 3934 | strcat(exstyle, "WS_EX_MDICHILD ");
|
|---|
| 3935 | if(dwExStyle & WS_EX_TOOLWINDOW)
|
|---|
| 3936 | strcat(exstyle, "WS_EX_TOOLWINDOW ");
|
|---|
| 3937 | if(dwExStyle & WS_EX_WINDOWEDGE)
|
|---|
| 3938 | strcat(exstyle, "WS_EX_WINDOWEDGE ");
|
|---|
| 3939 | if(dwExStyle & WS_EX_CLIENTEDGE)
|
|---|
| 3940 | strcat(exstyle, "WS_EX_CLIENTEDGE ");
|
|---|
| 3941 | if(dwExStyle & WS_EX_CONTEXTHELP)
|
|---|
| 3942 | strcat(exstyle, "WS_EX_CONTEXTHELP ");
|
|---|
| 3943 | if(dwExStyle & WS_EX_RIGHT)
|
|---|
| 3944 | strcat(exstyle, "WS_EX_RIGHT ");
|
|---|
| 3945 | if(dwExStyle & WS_EX_LEFT)
|
|---|
| 3946 | strcat(exstyle, "WS_EX_LEFT ");
|
|---|
| 3947 | if(dwExStyle & WS_EX_RTLREADING)
|
|---|
| 3948 | strcat(exstyle, "WS_EX_RTLREADING ");
|
|---|
| 3949 | if(dwExStyle & WS_EX_LTRREADING)
|
|---|
| 3950 | strcat(exstyle, "WS_EX_LTRREADING ");
|
|---|
| 3951 | if(dwExStyle & WS_EX_LEFTSCROLLBAR)
|
|---|
| 3952 | strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
|
|---|
| 3953 | if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
|
|---|
| 3954 | strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
|
|---|
| 3955 | if(dwExStyle & WS_EX_CONTROLPARENT)
|
|---|
| 3956 | strcat(exstyle, "WS_EX_CONTROLPARENT ");
|
|---|
| 3957 | if(dwExStyle & WS_EX_STATICEDGE)
|
|---|
| 3958 | strcat(exstyle, "WS_EX_STATICEDGE ");
|
|---|
| 3959 | if(dwExStyle & WS_EX_APPWINDOW)
|
|---|
| 3960 | strcat(exstyle, "WS_EX_APPWINDOW ");
|
|---|
| 3961 |
|
|---|
| 3962 | dprintf(("Window style: %x %s", dwStyle, style));
|
|---|
| 3963 | dprintf(("Window exStyle: %x %s", dwExStyle, exstyle));
|
|---|
| 3964 | }
|
|---|
| 3965 | #endif
|
|---|
| 3966 | //******************************************************************************
|
|---|
| 3967 | //******************************************************************************
|
|---|