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