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