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