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