| 1 | /* $Id: win32wbase.cpp,v 1.47 1999-10-16 14:51:42 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 Window Base Class for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
|---|
| 7 | *
|
|---|
| 8 | * Parts based on Wine Windows code (windows\win.c)
|
|---|
| 9 | *
|
|---|
| 10 | * Copyright 1993, 1994 Alexandre Julliard
|
|---|
| 11 | *
|
|---|
| 12 | * TODO: Not thread/process safe
|
|---|
| 13 | *
|
|---|
| 14 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 15 | *
|
|---|
| 16 | */
|
|---|
| 17 | #include <os2win.h>
|
|---|
| 18 | #include <win.h>
|
|---|
| 19 | #include <stdlib.h>
|
|---|
| 20 | #include <string.h>
|
|---|
| 21 | #include <stdarg.h>
|
|---|
| 22 | #include <assert.h>
|
|---|
| 23 | #include <misc.h>
|
|---|
| 24 | #include <heapstring.h>
|
|---|
| 25 | #include <win32wbase.h>
|
|---|
| 26 | #include <winres.h>
|
|---|
| 27 | #include <spy.h>
|
|---|
| 28 | #include "wndmsg.h"
|
|---|
| 29 | #include "hooks.h"
|
|---|
| 30 | #include "oslibwin.h"
|
|---|
| 31 | #include "oslibutil.h"
|
|---|
| 32 | #include "oslibgdi.h"
|
|---|
| 33 | #include "oslibres.h"
|
|---|
| 34 | #include "oslibmenu.h"
|
|---|
| 35 | #include "oslibdos.h"
|
|---|
| 36 | #include "syscolor.h"
|
|---|
| 37 | #include "win32wndhandle.h"
|
|---|
| 38 | #include "heapshared.h"
|
|---|
| 39 | #include "dc.h"
|
|---|
| 40 | #include "pmframe.h"
|
|---|
| 41 | #include "win32wdesktop.h"
|
|---|
| 42 | #include <wprocess.h>
|
|---|
| 43 |
|
|---|
| 44 | #define HAS_DLGFRAME(style,exStyle) \
|
|---|
| 45 | (((exStyle) & WS_EX_DLGMODALFRAME) || \
|
|---|
| 46 | (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
|
|---|
| 47 |
|
|---|
| 48 | #define HAS_THICKFRAME(style,exStyle) \
|
|---|
| 49 | (((style) & WS_THICKFRAME) && \
|
|---|
| 50 | !((exStyle) & WS_EX_DLGMODALFRAME))
|
|---|
| 51 |
|
|---|
| 52 | #define HAS_THINFRAME(style) \
|
|---|
| 53 | (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
|
|---|
| 54 |
|
|---|
| 55 | #define HAS_BIGFRAME(style,exStyle) \
|
|---|
| 56 | (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
|
|---|
| 57 | ((exStyle) & WS_EX_DLGMODALFRAME))
|
|---|
| 58 |
|
|---|
| 59 | #define HAS_ANYFRAME(style,exStyle) \
|
|---|
| 60 | (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
|
|---|
| 61 | ((exStyle) & WS_EX_DLGMODALFRAME) || \
|
|---|
| 62 | !((style) & (WS_CHILD | WS_POPUP)))
|
|---|
| 63 |
|
|---|
| 64 | #define HAS_3DFRAME(exStyle) \
|
|---|
| 65 | ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
|
|---|
| 66 |
|
|---|
| 67 | #define HAS_BORDER(style, exStyle) \
|
|---|
| 68 | ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
|
|---|
| 69 |
|
|---|
| 70 | #define IS_OVERLAPPED(style) \
|
|---|
| 71 | !(style & (WS_CHILD | WS_POPUP))
|
|---|
| 72 |
|
|---|
| 73 | /* bits in the dwKeyData */
|
|---|
| 74 | #define KEYDATA_ALT 0x2000
|
|---|
| 75 | #define KEYDATA_PREVSTATE 0x4000
|
|---|
| 76 |
|
|---|
| 77 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
|
|---|
| 78 |
|
|---|
| 79 | //******************************************************************************
|
|---|
| 80 | //******************************************************************************
|
|---|
| 81 | Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType)
|
|---|
| 82 | {
|
|---|
| 83 | Init();
|
|---|
| 84 | }
|
|---|
| 85 | //******************************************************************************
|
|---|
| 86 | //******************************************************************************
|
|---|
| 87 | Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
|
|---|
| 88 | : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
|
|---|
| 89 | {
|
|---|
| 90 | Init();
|
|---|
| 91 | this->isUnicode = isUnicode;
|
|---|
| 92 | CreateWindowExA(lpCreateStructA, classAtom);
|
|---|
| 93 | }
|
|---|
| 94 | //******************************************************************************
|
|---|
| 95 | //******************************************************************************
|
|---|
| 96 | void Win32BaseWindow::Init()
|
|---|
| 97 | {
|
|---|
| 98 | isUnicode = FALSE;
|
|---|
| 99 | fFirstShow = TRUE;
|
|---|
| 100 | fIsDialog = FALSE;
|
|---|
| 101 | fInternalMsg = FALSE;
|
|---|
| 102 | fNoSizeMsg = FALSE;
|
|---|
| 103 | fIsDestroyed = FALSE;
|
|---|
| 104 |
|
|---|
| 105 | windowNameA = NULL;
|
|---|
| 106 | windowNameW = NULL;
|
|---|
| 107 | wndNameLength = 0;
|
|---|
| 108 |
|
|---|
| 109 | userWindowLong = NULL;;
|
|---|
| 110 | nrUserWindowLong = 0;
|
|---|
| 111 |
|
|---|
| 112 | magic = WIN32PM_MAGIC;
|
|---|
| 113 | OS2Hwnd = 0;
|
|---|
| 114 | OS2HwndFrame = 0;
|
|---|
| 115 | OS2HwndMenu = 0;
|
|---|
| 116 | Win32Hwnd = 0;
|
|---|
| 117 |
|
|---|
| 118 | if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
|
|---|
| 119 | {
|
|---|
| 120 | dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
|
|---|
| 121 | DebugInt3();
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | posx = posy = 0;
|
|---|
| 125 | width = height = 0;
|
|---|
| 126 |
|
|---|
| 127 | dwExStyle = 0;
|
|---|
| 128 | dwStyle = 0;
|
|---|
| 129 | win32wndproc = 0;
|
|---|
| 130 | hInstance = 0;
|
|---|
| 131 | windowId = 0xFFFFFFFF; //default = -1
|
|---|
| 132 | userData = 0;
|
|---|
| 133 |
|
|---|
| 134 | pOldFrameProc = NULL;
|
|---|
| 135 | borderWidth = 0;
|
|---|
| 136 | borderHeight = 0;
|
|---|
| 137 |
|
|---|
| 138 | hwndLinkAfter = HWND_BOTTOM;
|
|---|
| 139 | flags = 0;
|
|---|
| 140 | isIcon = FALSE;
|
|---|
| 141 | lastHitTestVal = 0;
|
|---|
| 142 | owner = NULL;
|
|---|
| 143 | windowClass = 0;
|
|---|
| 144 |
|
|---|
| 145 | acceltableResource = NULL;
|
|---|
| 146 | iconResource = NULL;
|
|---|
| 147 |
|
|---|
| 148 | EraseBkgndFlag = TRUE;
|
|---|
| 149 | PSEraseFlag = FALSE;
|
|---|
| 150 | SupressEraseFlag = FALSE;
|
|---|
| 151 |
|
|---|
| 152 | horzScrollInfo = NULL;
|
|---|
| 153 | vertScrollInfo = NULL;
|
|---|
| 154 | hwndHorzScroll = 0;
|
|---|
| 155 | hwndVertScroll = 0;
|
|---|
| 156 |
|
|---|
| 157 | ownDC = 0;
|
|---|
| 158 | }
|
|---|
| 159 | //******************************************************************************
|
|---|
| 160 | //todo get rid of resources (menu, accel, icon etc)
|
|---|
| 161 | //******************************************************************************
|
|---|
| 162 | Win32BaseWindow::~Win32BaseWindow()
|
|---|
| 163 | {
|
|---|
| 164 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
|
|---|
| 165 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
|
|---|
| 166 |
|
|---|
| 167 | if(getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
|
|---|
| 168 | {
|
|---|
| 169 | //if we're the last child that's being destroyed and our
|
|---|
| 170 | //parent window was also destroyed, then we delete the parent object
|
|---|
| 171 | if(getParent()->IsWindowDestroyed())
|
|---|
| 172 | {
|
|---|
| 173 | dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
|
|---|
| 174 | delete getParent();
|
|---|
| 175 | setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
|
|---|
| 176 | }
|
|---|
| 177 | }
|
|---|
| 178 | if (isOwnDC())
|
|---|
| 179 | releaseOwnDC (ownDC);
|
|---|
| 180 |
|
|---|
| 181 | if(Win32Hwnd)
|
|---|
| 182 | HwFreeWindowHandle(Win32Hwnd);
|
|---|
| 183 |
|
|---|
| 184 | if(userWindowLong)
|
|---|
| 185 | free(userWindowLong);
|
|---|
| 186 | if(windowNameA) {
|
|---|
| 187 | free(windowNameA);
|
|---|
| 188 | windowNameA = NULL;
|
|---|
| 189 | }
|
|---|
| 190 | if(windowNameW) {
|
|---|
| 191 | free(windowNameW);
|
|---|
| 192 | windowNameW = NULL;
|
|---|
| 193 | }
|
|---|
| 194 | if(vertScrollInfo) {
|
|---|
| 195 | free(vertScrollInfo);
|
|---|
| 196 | vertScrollInfo = NULL;
|
|---|
| 197 | }
|
|---|
| 198 | if(horzScrollInfo) {
|
|---|
| 199 | free(horzScrollInfo);
|
|---|
| 200 | horzScrollInfo = NULL;
|
|---|
| 201 | }
|
|---|
| 202 | //TODO: Destroy windows if they're not associated with our window anymore (showwindow false)?
|
|---|
| 203 | // hwndHorzScroll
|
|---|
| 204 | // hwndVertScroll
|
|---|
| 205 |
|
|---|
| 206 | }
|
|---|
| 207 | //******************************************************************************
|
|---|
| 208 | //******************************************************************************
|
|---|
| 209 | BOOL Win32BaseWindow::isChild()
|
|---|
| 210 | {
|
|---|
| 211 | return ((dwStyle & WS_CHILD) != 0);
|
|---|
| 212 | }
|
|---|
| 213 | //******************************************************************************
|
|---|
| 214 | //******************************************************************************
|
|---|
| 215 | BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
|
|---|
| 216 | {
|
|---|
| 217 | char buffer[256];
|
|---|
| 218 | POINT maxSize, maxPos, minTrack, maxTrack;
|
|---|
| 219 |
|
|---|
| 220 | #ifdef DEBUG
|
|---|
| 221 | PrintWindowStyle(cs->style, cs->dwExStyle);
|
|---|
| 222 | #endif
|
|---|
| 223 |
|
|---|
| 224 | sw = SW_SHOW;
|
|---|
| 225 | SetLastError(0);
|
|---|
| 226 |
|
|---|
| 227 | /* Find the parent window */
|
|---|
| 228 | if (cs->hwndParent)
|
|---|
| 229 | {
|
|---|
| 230 | Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
|
|---|
| 231 | if(!window) {
|
|---|
| 232 | dprintf(("Bad parent %04x\n", cs->hwndParent ));
|
|---|
| 233 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 234 | return FALSE;
|
|---|
| 235 | }
|
|---|
| 236 | /* Make sure parent is valid */
|
|---|
| 237 | if (!window->IsWindow() )
|
|---|
| 238 | {
|
|---|
| 239 | dprintf(("Bad parent %04x\n", cs->hwndParent ));
|
|---|
| 240 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 241 | return FALSE;
|
|---|
| 242 | }
|
|---|
| 243 | }
|
|---|
| 244 | else
|
|---|
| 245 | if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
|
|---|
| 246 | dprintf(("No parent for child window\n" ));
|
|---|
| 247 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 248 | return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | /* Find the window class */
|
|---|
| 252 | windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
|
|---|
| 253 | if (!windowClass)
|
|---|
| 254 | {
|
|---|
| 255 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
|---|
| 256 | dprintf(("Bad class '%s'\n", buffer ));
|
|---|
| 257 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 258 | return 0;
|
|---|
| 259 | }
|
|---|
| 260 | #ifdef DEBUG
|
|---|
| 261 | if(HIWORD(cs->lpszClass))
|
|---|
| 262 | {
|
|---|
| 263 | char *astring;
|
|---|
| 264 |
|
|---|
| 265 | if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass);
|
|---|
| 266 | else astring = (char *)cs->lpszClass;
|
|---|
| 267 |
|
|---|
| 268 | dprintf(("Window class %s", astring));
|
|---|
| 269 | if(isUnicode) FreeAsciiString(astring);
|
|---|
| 270 | }
|
|---|
| 271 | else dprintf(("Window class %x", cs->lpszClass));
|
|---|
| 272 | #endif
|
|---|
| 273 |
|
|---|
| 274 | /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
|
|---|
| 275 | * with an atom as the class name, put some programs expect to have a *REAL* string in
|
|---|
| 276 | * lpszClass when the CREATESTRUCT is sent with WM_CREATE
|
|---|
| 277 | */
|
|---|
| 278 | if (!HIWORD(cs->lpszClass) ) {
|
|---|
| 279 | if (isUnicode) {
|
|---|
| 280 | GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
|
|---|
| 281 | }
|
|---|
| 282 | else {
|
|---|
| 283 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
|---|
| 284 | }
|
|---|
| 285 | cs->lpszClass = buffer;
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | /* Fix the coordinates */
|
|---|
| 289 | if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
|
|---|
| 290 | {
|
|---|
| 291 | // PDB *pdb = PROCESS_Current();
|
|---|
| 292 |
|
|---|
| 293 | /* Never believe Microsoft's documentation... CreateWindowEx doc says
|
|---|
| 294 | * that if an overlapped window is created with WS_VISIBLE style bit
|
|---|
| 295 | * set and the x parameter is set to CW_USEDEFAULT, the system ignores
|
|---|
| 296 | * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
|
|---|
| 297 | * reveals that
|
|---|
| 298 | *
|
|---|
| 299 | * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
|
|---|
| 300 | * 2) it does not ignore the y parameter as the docs claim; instead, it
|
|---|
| 301 | * uses it as second parameter to ShowWindow() unless y is either
|
|---|
| 302 | * CW_USEDEFAULT or CW_USEDEFAULT16.
|
|---|
| 303 | *
|
|---|
| 304 | * The fact that we didn't do 2) caused bogus windows pop up when wine
|
|---|
| 305 | * was running apps that were using this obscure feature. Example -
|
|---|
| 306 | * calc.exe that comes with Win98 (only Win98, it's different from
|
|---|
| 307 | * the one that comes with Win95 and NT)
|
|---|
| 308 | */
|
|---|
| 309 | if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
|
|---|
| 310 |
|
|---|
| 311 | /* We have saved cs->y, now we can trash it */
|
|---|
| 312 | #if 0
|
|---|
| 313 | if ( !(cs->style & (WS_CHILD | WS_POPUP))
|
|---|
| 314 | && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
|
|---|
| 315 | {
|
|---|
| 316 | cs->x = pdb->env_db->startup_info->dwX;
|
|---|
| 317 | cs->y = pdb->env_db->startup_info->dwY;
|
|---|
| 318 | }
|
|---|
| 319 | #endif
|
|---|
| 320 | cs->x = 0;
|
|---|
| 321 | cs->y = 0;
|
|---|
| 322 | // }
|
|---|
| 323 | }
|
|---|
| 324 | if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
|
|---|
| 325 | {
|
|---|
| 326 | #if 0
|
|---|
| 327 | PDB *pdb = PROCESS_Current();
|
|---|
| 328 | if ( !(cs->style & (WS_CHILD | WS_POPUP))
|
|---|
| 329 | && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
|
|---|
| 330 | {
|
|---|
| 331 | cs->cx = pdb->env_db->startup_info->dwXSize;
|
|---|
| 332 | cs->cy = pdb->env_db->startup_info->dwYSize;
|
|---|
| 333 | }
|
|---|
| 334 | else
|
|---|
| 335 | {
|
|---|
| 336 | #endif
|
|---|
| 337 | cs->cx = 600; /* FIXME */
|
|---|
| 338 | cs->cy = 400;
|
|---|
| 339 | // }
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | if (cs->x < 0) cs->x = 0;
|
|---|
| 343 | if (cs->y < 0) cs->y = 0;
|
|---|
| 344 |
|
|---|
| 345 | //Allocate window words
|
|---|
| 346 | nrUserWindowLong = windowClass->getExtraWndWords();
|
|---|
| 347 | if(nrUserWindowLong) {
|
|---|
| 348 | userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
|
|---|
| 349 | memset(userWindowLong, 0, nrUserWindowLong);
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | if ((cs->style & WS_CHILD) && cs->hwndParent)
|
|---|
| 353 | {
|
|---|
| 354 | SetParent(cs->hwndParent);
|
|---|
| 355 | owner = GetWindowFromHandle(cs->hwndParent);
|
|---|
| 356 | if(owner == NULL)
|
|---|
| 357 | {
|
|---|
| 358 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
|
|---|
| 359 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 360 | return FALSE;
|
|---|
| 361 | }
|
|---|
| 362 | }
|
|---|
| 363 | else
|
|---|
| 364 | {
|
|---|
| 365 | if (!cs->hwndParent) {
|
|---|
| 366 | owner = NULL;
|
|---|
| 367 | }
|
|---|
| 368 | else
|
|---|
| 369 | {
|
|---|
| 370 | owner = GetWindowFromHandle(cs->hwndParent);
|
|---|
| 371 | if(owner == NULL)
|
|---|
| 372 | {
|
|---|
| 373 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
|
|---|
| 374 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 375 | return FALSE;
|
|---|
| 376 | }
|
|---|
| 377 | }
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | setWindowProc(windowClass->getWindowProc());
|
|---|
| 381 | hInstance = cs->hInstance;
|
|---|
| 382 | dwStyle = cs->style & ~WS_VISIBLE;
|
|---|
| 383 | dwExStyle = cs->dwExStyle;
|
|---|
| 384 |
|
|---|
| 385 | #if 1
|
|---|
| 386 | //SvL: Messes up Z-order of dialog controls
|
|---|
| 387 | hwndLinkAfter = HWND_TOP;
|
|---|
| 388 | #else
|
|---|
| 389 | hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
|
|---|
| 390 | ? HWND_BOTTOM : HWND_TOP;
|
|---|
| 391 | #endif
|
|---|
| 392 |
|
|---|
| 393 | #if 0
|
|---|
| 394 | //TODO
|
|---|
| 395 | /* Call the WH_CBT hook */
|
|---|
| 396 |
|
|---|
| 397 | if (HOOK_IsHooked( WH_CBT ))
|
|---|
| 398 | {
|
|---|
| 399 | CBT_CREATEWNDA cbtc;
|
|---|
| 400 | LRESULT ret;
|
|---|
| 401 |
|
|---|
| 402 | cbtc.lpcs = cs;
|
|---|
| 403 | cbtc.hwndInsertAfter = hwndLinkAfter;
|
|---|
| 404 | ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
|
|---|
| 405 | : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
|
|---|
| 406 | if (ret)
|
|---|
| 407 | {
|
|---|
| 408 | TRACE_(win)("CBT-hook returned 0\n");
|
|---|
| 409 | wndPtr->pDriver->pFinalize(wndPtr);
|
|---|
| 410 | retvalue = 0;
|
|---|
| 411 | goto end;
|
|---|
| 412 | }
|
|---|
| 413 | }
|
|---|
| 414 | #endif
|
|---|
| 415 |
|
|---|
| 416 | /* Increment class window counter */
|
|---|
| 417 | windowClass->IncreaseWindowCount();
|
|---|
| 418 |
|
|---|
| 419 | /* Correct the window style */
|
|---|
| 420 | if (!(cs->style & WS_CHILD))
|
|---|
| 421 | {
|
|---|
| 422 | dwStyle |= WS_CLIPSIBLINGS;
|
|---|
| 423 | if (!(cs->style & WS_POPUP))
|
|---|
| 424 | {
|
|---|
| 425 | dwStyle |= WS_CAPTION;
|
|---|
| 426 | flags |= WIN_NEED_SIZE;
|
|---|
| 427 | }
|
|---|
| 428 | }
|
|---|
| 429 | if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
|
|---|
| 430 |
|
|---|
| 431 | //TODO?
|
|---|
| 432 | #if 0
|
|---|
| 433 | /* Get class or window DC if needed */
|
|---|
| 434 | if (classPtr->style & CS_OWNDC) dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC);
|
|---|
| 435 | else if (classPtr->style & CS_CLASSDC) wndPtr->dce = classPtr->dce;
|
|---|
| 436 | else wndPtr->dce = NULL;
|
|---|
| 437 | #endif
|
|---|
| 438 |
|
|---|
| 439 | if (cs->style & WS_HSCROLL)
|
|---|
| 440 | {
|
|---|
| 441 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
|---|
| 442 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
|
|---|
| 443 | horzScrollInfo->MaxVal = 100;
|
|---|
| 444 | horzScrollInfo->flags = ESB_ENABLE_BOTH;
|
|---|
| 445 | }
|
|---|
| 446 |
|
|---|
| 447 | if (cs->style & WS_VSCROLL)
|
|---|
| 448 | {
|
|---|
| 449 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
|---|
| 450 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
|
|---|
| 451 | vertScrollInfo->MaxVal = 100;
|
|---|
| 452 | vertScrollInfo->flags = ESB_ENABLE_BOTH;
|
|---|
| 453 | }
|
|---|
| 454 |
|
|---|
| 455 | /* Send the WM_GETMINMAXINFO message and fix the size if needed */
|
|---|
| 456 | if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
|
|---|
| 457 | {
|
|---|
| 458 | GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
|
|---|
| 459 | if (maxSize.x < cs->cx) cs->cx = maxSize.x;
|
|---|
| 460 | if (maxSize.y < cs->cy) cs->cy = maxSize.y;
|
|---|
| 461 | if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
|
|---|
| 462 | if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
|
|---|
| 463 | }
|
|---|
| 464 |
|
|---|
| 465 | if(cs->style & WS_CHILD)
|
|---|
| 466 | {
|
|---|
| 467 | if(cs->cx < 0) cs->cx = 0;
|
|---|
| 468 | if(cs->cy < 0) cs->cy = 0;
|
|---|
| 469 | }
|
|---|
| 470 | else
|
|---|
| 471 | {
|
|---|
| 472 | if (cs->cx <= 0) cs->cx = 1;
|
|---|
| 473 | if (cs->cy <= 0) cs->cy = 1;
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | DWORD dwOSWinStyle, dwOSFrameStyle;
|
|---|
| 477 |
|
|---|
| 478 | OSLibWinConvertStyle(cs->style, &cs->dwExStyle, &dwOSWinStyle, &dwOSFrameStyle, &borderWidth, &borderHeight);
|
|---|
| 479 | dwExStyle = cs->dwExStyle;
|
|---|
| 480 |
|
|---|
| 481 | rectWindow.left = cs->x;
|
|---|
| 482 | rectWindow.top = cs->y;
|
|---|
| 483 | rectWindow.right = cs->x + cs->cx;
|
|---|
| 484 | rectWindow.bottom = cs->y + cs->cy;
|
|---|
| 485 | rectClient = rectWindow;
|
|---|
| 486 |
|
|---|
| 487 | if(HIWORD(cs->lpszName))
|
|---|
| 488 | {
|
|---|
| 489 | if(isUnicode)
|
|---|
| 490 | SetWindowTextW((LPWSTR)cs->lpszName);
|
|---|
| 491 | else SetWindowTextA((LPSTR)cs->lpszName);
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 | //copy pointer of CREATESTRUCT for usage in MsgCreate method
|
|---|
| 495 | tmpcs = cs;
|
|---|
| 496 |
|
|---|
| 497 | //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
|
|---|
| 498 | THDB *thdb = GetThreadTHDB();
|
|---|
| 499 |
|
|---|
| 500 | if(thdb == NULL) {
|
|---|
| 501 | dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
|
|---|
| 502 | ExitProcess(666);
|
|---|
| 503 | return FALSE;
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | thdb->newWindow = (ULONG)this;
|
|---|
| 507 |
|
|---|
| 508 | OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
|
|---|
| 509 | dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
|
|---|
| 510 | (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
|
|---|
| 511 | (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
|
|---|
| 512 | &OS2HwndFrame, 0);
|
|---|
| 513 |
|
|---|
| 514 | if(OS2Hwnd == 0) {
|
|---|
| 515 | dprintf(("Window creation failed!!"));
|
|---|
| 516 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 517 | return FALSE;
|
|---|
| 518 | }
|
|---|
| 519 | SetLastError(0);
|
|---|
| 520 | return TRUE;
|
|---|
| 521 | }
|
|---|
| 522 | //******************************************************************************
|
|---|
| 523 | //******************************************************************************
|
|---|
| 524 | BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
|
|---|
| 525 | {
|
|---|
| 526 | POINT maxPos;
|
|---|
| 527 | CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
|
|---|
| 528 |
|
|---|
| 529 | OS2Hwnd = hwndClient;
|
|---|
| 530 | OS2HwndFrame = hwndFrame;
|
|---|
| 531 | // if(!isFrameWindow())
|
|---|
| 532 | // OS2HwndFrame = hwndClient;
|
|---|
| 533 |
|
|---|
| 534 | fNoSizeMsg = TRUE;
|
|---|
| 535 |
|
|---|
| 536 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
|
|---|
| 537 | dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
|
|---|
| 538 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 539 | return FALSE;
|
|---|
| 540 | }
|
|---|
| 541 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
|
|---|
| 542 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
|
|---|
| 543 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 544 | return FALSE;
|
|---|
| 545 | }
|
|---|
| 546 | //SvL: Need to store the shared memory base, or else other apps can map it into their memory space
|
|---|
| 547 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) {
|
|---|
| 548 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
|
|---|
| 549 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 550 | return FALSE;
|
|---|
| 551 | }
|
|---|
| 552 | #if 0
|
|---|
| 553 | if(OS2Hwnd != OS2HwndFrame) {
|
|---|
| 554 | if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
|
|---|
| 555 | dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
|
|---|
| 556 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 557 | return FALSE;
|
|---|
| 558 | }
|
|---|
| 559 | if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
|
|---|
| 560 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
|
|---|
| 561 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 562 | return FALSE;
|
|---|
| 563 | }
|
|---|
| 564 | //SvL: Need to store the shared memory base, or else other apps can map it into their memory space
|
|---|
| 565 | if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) {
|
|---|
| 566 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
|
|---|
| 567 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 568 | return FALSE;
|
|---|
| 569 | }
|
|---|
| 570 | }
|
|---|
| 571 | #endif
|
|---|
| 572 |
|
|---|
| 573 | OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);
|
|---|
| 574 |
|
|---|
| 575 | if (dwStyle & WS_HSCROLL)
|
|---|
| 576 | {
|
|---|
| 577 | hwndHorzScroll = OSLibWinQueryScrollBarHandle(OS2HwndFrame, OSLIB_HSCROLL);
|
|---|
| 578 | // OSLibWinShowScrollBar(OS2HwndFrame, hwndHorzScroll, OSLIB_HSCROLL, FALSE, TRUE);
|
|---|
| 579 | }
|
|---|
| 580 |
|
|---|
| 581 | if (dwStyle & WS_VSCROLL) {
|
|---|
| 582 | hwndVertScroll = OSLibWinQueryScrollBarHandle(OS2HwndFrame, OSLIB_VSCROLL);
|
|---|
| 583 | // OSLibWinShowScrollBar(OS2HwndFrame, hwndVertScroll, OSLIB_VSCROLL, FALSE, TRUE);
|
|---|
| 584 | }
|
|---|
| 585 |
|
|---|
| 586 | fakeWinBase.hwndThis = OS2Hwnd;
|
|---|
| 587 | fakeWinBase.pWindowClass = windowClass;
|
|---|
| 588 | // SetFakeOpen32();
|
|---|
| 589 |
|
|---|
| 590 | //Set icon from class
|
|---|
| 591 | if(windowClass->getIcon())
|
|---|
| 592 | SetIcon(windowClass->getIcon());
|
|---|
| 593 |
|
|---|
| 594 | /* Set the window menu */
|
|---|
| 595 | if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
|
|---|
| 596 | {
|
|---|
| 597 | if (cs->hMenu) SetMenu(cs->hMenu);
|
|---|
| 598 | else
|
|---|
| 599 | {
|
|---|
| 600 | if (windowClass->getMenuNameA()) {
|
|---|
| 601 | cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
|
|---|
| 602 | if (cs->hMenu) SetMenu(cs->hMenu );
|
|---|
| 603 | }
|
|---|
| 604 | }
|
|---|
| 605 | }
|
|---|
| 606 | else
|
|---|
| 607 | {
|
|---|
| 608 | setWindowId((DWORD)cs->hMenu);
|
|---|
| 609 | }
|
|---|
| 610 |
|
|---|
| 611 | //Subclass frame
|
|---|
| 612 | // if(isFrameWindow() && (HAS_3DFRAME(dwExStyle) ||
|
|---|
| 613 | // (!HAS_DLGFRAME(dwStyle, dwExStyle) && (dwStyle & (WS_DLGFRAME|WS_BORDER|WS_THICKFRAME)) == WS_BORDER)))
|
|---|
| 614 | // {
|
|---|
| 615 | pOldFrameProc = FrameSubclassFrameWindow(this);
|
|---|
| 616 | if (isChild()) FrameSetBorderSize(this,TRUE);
|
|---|
| 617 | // }
|
|---|
| 618 |
|
|---|
| 619 | /* Send the WM_CREATE message
|
|---|
| 620 | * Perhaps we shouldn't allow width/height changes as well.
|
|---|
| 621 | * See p327 in "Internals".
|
|---|
| 622 | */
|
|---|
| 623 | maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
|
|---|
| 624 |
|
|---|
| 625 | if(getParent()) {
|
|---|
| 626 | SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
|
|---|
| 627 | rectClient.right-rectClient.left,
|
|---|
| 628 | rectClient.bottom-rectClient.top,
|
|---|
| 629 | SWP_NOACTIVATE | SWP_NOZORDER );
|
|---|
| 630 | }
|
|---|
| 631 | else {
|
|---|
| 632 | SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
|
|---|
| 633 | rectClient.right-rectClient.left,
|
|---|
| 634 | rectClient.bottom-rectClient.top,
|
|---|
| 635 | SWP_NOACTIVATE);
|
|---|
| 636 | }
|
|---|
| 637 | fNoSizeMsg = FALSE;
|
|---|
| 638 |
|
|---|
| 639 | if(SendMessageA(WM_NCCREATE, 0, (LPARAM)cs) )
|
|---|
| 640 | {
|
|---|
| 641 | SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
|
|---|
| 642 |
|
|---|
| 643 | // OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
|
|---|
| 644 | dprintf(("Sending WM_CREATE"));
|
|---|
| 645 | if( (SendMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
|
|---|
| 646 | {
|
|---|
| 647 | if(!(flags & WIN_NEED_SIZE)) {
|
|---|
| 648 | SendMessageA(WM_SIZE, SIZE_RESTORED,
|
|---|
| 649 | MAKELONG(rectClient.right-rectClient.left,
|
|---|
| 650 | rectClient.bottom-rectClient.top));
|
|---|
| 651 | SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 | if (cs->style & WS_VISIBLE) ShowWindow( sw );
|
|---|
| 655 |
|
|---|
| 656 | #if 0
|
|---|
| 657 | /* Call WH_SHELL hook */
|
|---|
| 658 |
|
|---|
| 659 | if (!(dwStyle & WS_CHILD) && !owner)
|
|---|
| 660 | HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
|
|---|
| 661 | #endif
|
|---|
| 662 | SetLastError(0);
|
|---|
| 663 | return TRUE;
|
|---|
| 664 | }
|
|---|
| 665 | }
|
|---|
| 666 | dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
|
|---|
| 667 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
|---|
| 668 | return FALSE;
|
|---|
| 669 | }
|
|---|
| 670 | //******************************************************************************
|
|---|
| 671 | //******************************************************************************
|
|---|
| 672 | ULONG Win32BaseWindow::MsgQuit()
|
|---|
| 673 | {
|
|---|
| 674 | return SendInternalMessageA(WM_QUIT, 0, 0);
|
|---|
| 675 | }
|
|---|
| 676 | //******************************************************************************
|
|---|
| 677 | //******************************************************************************
|
|---|
| 678 | ULONG Win32BaseWindow::MsgClose()
|
|---|
| 679 | {
|
|---|
| 680 | if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) {
|
|---|
| 681 | return 0; //app handles this message
|
|---|
| 682 | }
|
|---|
| 683 | return 1;
|
|---|
| 684 | }
|
|---|
| 685 | //******************************************************************************
|
|---|
| 686 | //******************************************************************************
|
|---|
| 687 | ULONG Win32BaseWindow::MsgDestroy()
|
|---|
| 688 | {
|
|---|
| 689 | ULONG rc;
|
|---|
| 690 | Win32BaseWindow *child;
|
|---|
| 691 |
|
|---|
| 692 | //According to the SDK, WM_PARENTNOTIFY messages are sent to the parent (this window)
|
|---|
| 693 | //before any window destruction has begun
|
|---|
| 694 | child = (Win32BaseWindow *)getFirstChild();
|
|---|
| 695 | while(child) {
|
|---|
| 696 | child->NotifyParent(WM_DESTROY, 0, 0);
|
|---|
| 697 |
|
|---|
| 698 | child = (Win32BaseWindow *)child->getNextChild();
|
|---|
| 699 | }
|
|---|
| 700 | SendInternalMessageA(WM_DESTROY, 0, 0);
|
|---|
| 701 |
|
|---|
| 702 | fIsDestroyed = TRUE;
|
|---|
| 703 | if(getFirstChild() == NULL) {
|
|---|
| 704 | delete this;
|
|---|
| 705 | }
|
|---|
| 706 | return 1;
|
|---|
| 707 | }
|
|---|
| 708 | //******************************************************************************
|
|---|
| 709 | //******************************************************************************
|
|---|
| 710 | ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
|
|---|
| 711 | {
|
|---|
| 712 | if(fEnable) {
|
|---|
| 713 | dwStyle &= ~WS_DISABLED;
|
|---|
| 714 | }
|
|---|
| 715 | else dwStyle |= WS_DISABLED;
|
|---|
| 716 |
|
|---|
| 717 | return SendInternalMessageA(WM_ENABLE, fEnable, 0);
|
|---|
| 718 | }
|
|---|
| 719 | //******************************************************************************
|
|---|
| 720 | //TODO: SW_PARENTCLOSING/OPENING flag (lParam)
|
|---|
| 721 | //******************************************************************************
|
|---|
| 722 | ULONG Win32BaseWindow::MsgShow(BOOL fShow)
|
|---|
| 723 | {
|
|---|
| 724 | if(fNoSizeMsg) {
|
|---|
| 725 | return 1;
|
|---|
| 726 | }
|
|---|
| 727 |
|
|---|
| 728 | if(fShow) {
|
|---|
| 729 | setStyle(getStyle() | WS_VISIBLE);
|
|---|
| 730 | }
|
|---|
| 731 | else setStyle(getStyle() & ~WS_VISIBLE);
|
|---|
| 732 |
|
|---|
| 733 | return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
|
|---|
| 734 | }
|
|---|
| 735 | //******************************************************************************
|
|---|
| 736 | //******************************************************************************
|
|---|
| 737 | ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
|
|---|
| 738 | {
|
|---|
| 739 | if(fNoSizeMsg)
|
|---|
| 740 | return 1;
|
|---|
| 741 |
|
|---|
| 742 | return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
|
|---|
| 743 | }
|
|---|
| 744 | //******************************************************************************
|
|---|
| 745 | //******************************************************************************
|
|---|
| 746 | ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
|
|---|
| 747 | {
|
|---|
| 748 | if(fNoSizeMsg)
|
|---|
| 749 | return 1;
|
|---|
| 750 |
|
|---|
| 751 | return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
|
|---|
| 752 | }
|
|---|
| 753 | //******************************************************************************
|
|---|
| 754 | //******************************************************************************
|
|---|
| 755 | ULONG Win32BaseWindow::MsgMove(ULONG x, ULONG y)
|
|---|
| 756 | {
|
|---|
| 757 | dprintf(("MsgMove to (%d,%d)", x, y));
|
|---|
| 758 | if(fNoSizeMsg)
|
|---|
| 759 | return 1;
|
|---|
| 760 |
|
|---|
| 761 | return SendInternalMessageA(WM_MOVE, 0, MAKELONG((USHORT)x, (USHORT)y));
|
|---|
| 762 | }
|
|---|
| 763 | //******************************************************************************
|
|---|
| 764 | //******************************************************************************
|
|---|
| 765 | ULONG Win32BaseWindow::MsgTimer(ULONG TimerID)
|
|---|
| 766 | {
|
|---|
| 767 | // TODO: call TIMERPROC if not NULL
|
|---|
| 768 | return SendInternalMessageA(WM_TIMER, TimerID, 0);
|
|---|
| 769 | }
|
|---|
| 770 | //******************************************************************************
|
|---|
| 771 | //******************************************************************************
|
|---|
| 772 | ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
|
|---|
| 773 | {
|
|---|
| 774 | //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
|
|---|
| 775 | //window scrollbars send these messages
|
|---|
| 776 | return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
|
|---|
| 777 | }
|
|---|
| 778 | //******************************************************************************
|
|---|
| 779 | //******************************************************************************
|
|---|
| 780 | ULONG Win32BaseWindow::MsgCommand(ULONG cmd, ULONG Id, HWND hwnd)
|
|---|
| 781 | {
|
|---|
| 782 | switch(cmd) {
|
|---|
| 783 | case CMD_MENU:
|
|---|
| 784 | return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
|
|---|
| 785 | case CMD_CONTROL:
|
|---|
| 786 | return 0; //todo
|
|---|
| 787 | case CMD_ACCELERATOR:
|
|---|
| 788 | // this fit not really windows behavior.
|
|---|
| 789 | // maybe TranslateAccelerator() is better
|
|---|
| 790 | dprintf(("accelerator command"));
|
|---|
| 791 | return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
|
|---|
| 792 | }
|
|---|
| 793 | return 0;
|
|---|
| 794 | }
|
|---|
| 795 | //******************************************************************************
|
|---|
| 796 | //******************************************************************************
|
|---|
| 797 | ULONG Win32BaseWindow::MsgHitTest(ULONG x, ULONG y)
|
|---|
| 798 | {
|
|---|
| 799 | lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)x, (USHORT)y));
|
|---|
| 800 | return 1; //TODO: May need to change this
|
|---|
| 801 | }
|
|---|
| 802 | //******************************************************************************
|
|---|
| 803 | //TODO: Send WM_NCCALCSIZE message here and correct size if necessary
|
|---|
| 804 | //******************************************************************************
|
|---|
| 805 | ULONG Win32BaseWindow::MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize)
|
|---|
| 806 | {
|
|---|
| 807 | WORD fwSizeType = 0;
|
|---|
| 808 |
|
|---|
| 809 | if(fMinimize) {
|
|---|
| 810 | fwSizeType = SIZE_MINIMIZED;
|
|---|
| 811 | }
|
|---|
| 812 | else
|
|---|
| 813 | if(fMaximize) {
|
|---|
| 814 | fwSizeType = SIZE_MAXIMIZED;
|
|---|
| 815 | }
|
|---|
| 816 | else fwSizeType = SIZE_RESTORED;
|
|---|
| 817 |
|
|---|
| 818 | return SendInternalMessageA(WM_SIZE, fwSizeType, MAKELONG((USHORT)width, (USHORT)height));
|
|---|
| 819 | }
|
|---|
| 820 | //******************************************************************************
|
|---|
| 821 | //******************************************************************************
|
|---|
| 822 | ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd)
|
|---|
| 823 | {
|
|---|
| 824 | ULONG rc, curprocid, procidhwnd = -1, threadidhwnd = 0;
|
|---|
| 825 |
|
|---|
| 826 | //According to SDK docs, if app returns FALSE & window is being deactivated,
|
|---|
| 827 | //default processing is cancelled
|
|---|
| 828 | //TODO: According to Wine we should proceed anyway if window is sysmodal
|
|---|
| 829 | if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
|
|---|
| 830 | {
|
|---|
| 831 | return 0;
|
|---|
| 832 | }
|
|---|
| 833 | rc = SendInternalMessageA(WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
|
|---|
| 834 |
|
|---|
| 835 | curprocid = GetCurrentProcessId();
|
|---|
| 836 | if(hwnd) {
|
|---|
| 837 | threadidhwnd = GetWindowThreadProcessId(hwnd, &procidhwnd);
|
|---|
| 838 | }
|
|---|
| 839 |
|
|---|
| 840 | if(curprocid != procidhwnd && fActivate) {
|
|---|
| 841 | SendInternalMessageA(WM_ACTIVATEAPP, 1, threadidhwnd);
|
|---|
| 842 | }
|
|---|
| 843 | return rc;
|
|---|
| 844 | }
|
|---|
| 845 | //******************************************************************************
|
|---|
| 846 | //******************************************************************************
|
|---|
| 847 | ULONG Win32BaseWindow::MsgSysCommand(ULONG win32sc, ULONG x, ULONG y)
|
|---|
| 848 | {
|
|---|
| 849 | return SendInternalMessageA(WM_SYSCOMMAND, win32sc, MAKELONG((USHORT)x, (USHORT)y));
|
|---|
| 850 | }
|
|---|
| 851 | //******************************************************************************
|
|---|
| 852 | //TODO: Is this correct and complete?
|
|---|
| 853 | //Add print screen, break & numlock
|
|---|
| 854 | //******************************************************************************
|
|---|
| 855 | void Win32BaseWindow::setExtendedKey(ULONG virtualkey, ULONG *lParam)
|
|---|
| 856 | {
|
|---|
| 857 | switch(virtualkey) {
|
|---|
| 858 | case VK_DOWN:
|
|---|
| 859 | case VK_UP:
|
|---|
| 860 | case VK_PRIOR:
|
|---|
| 861 | case VK_NEXT:
|
|---|
| 862 | case VK_END:
|
|---|
| 863 | case VK_DIVIDE:
|
|---|
| 864 | case VK_DELETE:
|
|---|
| 865 | case VK_EXECUTE: //Numeric enter key?
|
|---|
| 866 | case VK_HOME:
|
|---|
| 867 | case VK_INSERT:
|
|---|
| 868 | case VK_RCONTROL:
|
|---|
| 869 | case VK_RMENU: //is this the right alt???
|
|---|
| 870 | *lParam = *lParam | (1<<24);
|
|---|
| 871 | }
|
|---|
| 872 | }
|
|---|
| 873 | //******************************************************************************
|
|---|
| 874 | //TODO: virtual key & (possibly) scancode translation, extended keyboard bit & Unicode
|
|---|
| 875 | //******************************************************************************
|
|---|
| 876 | ULONG Win32BaseWindow::MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags)
|
|---|
| 877 | {
|
|---|
| 878 | ULONG lParam = 0;
|
|---|
| 879 |
|
|---|
| 880 | lParam = repeatcnt;
|
|---|
| 881 | lParam |= (scancode << 16);
|
|---|
| 882 | setExtendedKey(vkey, &lParam);
|
|---|
| 883 |
|
|---|
| 884 | if(keyflags & KEY_ALTDOWN)
|
|---|
| 885 | lParam |= (1<<29);
|
|---|
| 886 | if(keyflags & KEY_PREVDOWN)
|
|---|
| 887 | lParam |= (1<<30);
|
|---|
| 888 | if(keyflags & KEY_UP)
|
|---|
| 889 | lParam |= (1<<31);
|
|---|
| 890 | if(keyflags & KEY_DEADKEY) {
|
|---|
| 891 | dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
|
|---|
| 892 | return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
|
|---|
| 893 | }
|
|---|
| 894 | else {
|
|---|
| 895 | dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
|
|---|
| 896 | return SendInternalMessageA(WM_CHAR, cmd, lParam);
|
|---|
| 897 | }
|
|---|
| 898 | }
|
|---|
| 899 | //******************************************************************************
|
|---|
| 900 | //******************************************************************************
|
|---|
| 901 | ULONG Win32BaseWindow::MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey)
|
|---|
| 902 | {
|
|---|
| 903 | ULONG lParam=0;
|
|---|
| 904 |
|
|---|
| 905 | lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
|
|---|
| 906 | lParam |= (scancode & 0x0FF) << 16; // bit 16-23, scancode
|
|---|
| 907 | // bit 24, 1=extended key
|
|---|
| 908 | // bit 25-28, reserved
|
|---|
| 909 | lParam |= 0 << 29; // bit 29, key is released, always 0 for WM_KEYUP ?? <- conflict according to the MS docs
|
|---|
| 910 | lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
|
|---|
| 911 | lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
|
|---|
| 912 |
|
|---|
| 913 | dprintf(("WM_KEYUP: vkey:(%x) param:(%x)", virtualKey, lParam));
|
|---|
| 914 |
|
|---|
| 915 | setExtendedKey(virtualKey, &lParam);
|
|---|
| 916 | return SendInternalMessageA (WM_KEYUP, virtualKey, lParam);
|
|---|
| 917 | }
|
|---|
| 918 | //******************************************************************************
|
|---|
| 919 | //******************************************************************************
|
|---|
| 920 | ULONG Win32BaseWindow::MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed)
|
|---|
| 921 | {
|
|---|
| 922 | ULONG lParam=0;
|
|---|
| 923 |
|
|---|
| 924 | lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
|
|---|
| 925 | lParam |= (scancode & 0x0FF) << 16; // bit 16-23, scancode
|
|---|
| 926 | // bit 24, 1=extended key
|
|---|
| 927 | // bit 25-28, reserved
|
|---|
| 928 | // bit 29, key is pressed, always 0 for WM_KEYDOWN ?? <- conflict according to the MS docs
|
|---|
| 929 | if (keyWasPressed)
|
|---|
| 930 | lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
|
|---|
| 931 | // bit 31, transition state, always 0 for WM_KEYDOWN
|
|---|
| 932 |
|
|---|
| 933 | setExtendedKey(virtualKey, &lParam);
|
|---|
| 934 |
|
|---|
| 935 | dprintf(("WM_KEYDOWN: vkey:(%x) param:(%x)", virtualKey, lParam));
|
|---|
| 936 |
|
|---|
| 937 | return SendInternalMessageA (WM_KEYDOWN, virtualKey, lParam);
|
|---|
| 938 | }
|
|---|
| 939 | //******************************************************************************
|
|---|
| 940 | //******************************************************************************
|
|---|
| 941 | ULONG Win32BaseWindow::MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey)
|
|---|
| 942 | {
|
|---|
| 943 | ULONG lParam=0;
|
|---|
| 944 |
|
|---|
| 945 | lParam = repeatCount & 0x0FFFF; // bit 0-15,repeatcount
|
|---|
| 946 | lParam |= (scancode & 0x0FF) << 16; // bit 16-23, scancode
|
|---|
| 947 | // bit 24, 1=extended key
|
|---|
| 948 | // bit 25-28, reserved
|
|---|
| 949 | lParam |= 0 << 29; // bit 29, key is released, always 1 for WM_SYSKEYUP ?? <- conflict according to the MS docs
|
|---|
| 950 | lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
|
|---|
| 951 | lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
|
|---|
| 952 |
|
|---|
| 953 | setExtendedKey(virtualKey, &lParam);
|
|---|
| 954 | dprintf(("WM_SYSKEYUP: vkey:(%x) param:(%x)", virtualKey, lParam));
|
|---|
| 955 |
|
|---|
| 956 | return SendInternalMessageA (WM_SYSKEYUP, virtualKey, lParam);
|
|---|
| 957 | }
|
|---|
| 958 | //******************************************************************************
|
|---|
| 959 | //******************************************************************************
|
|---|
| 960 | ULONG Win32BaseWindow::MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed)
|
|---|
| 961 | {
|
|---|
| 962 | ULONG lParam=0;
|
|---|
| 963 |
|
|---|
| 964 | lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
|
|---|
| 965 | lParam |= (scancode & 0x0FF) << 16; // bit 16-23, scancode
|
|---|
| 966 | // bit 24, 1=extended key
|
|---|
| 967 | // bit 25-28, reserved
|
|---|
| 968 | // bit 29, key is released, always 1 for WM_SYSKEYUP ?? <- conflict according to the MS docs
|
|---|
| 969 | if (keyWasPressed)
|
|---|
| 970 | lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
|
|---|
| 971 | // bit 31, transition state, always 0 for WM_KEYDOWN
|
|---|
| 972 |
|
|---|
| 973 | setExtendedKey(virtualKey, &lParam);
|
|---|
| 974 | dprintf(("WM_SYSKEYDOWN: vkey:(%x) param:(%x)", virtualKey, lParam));
|
|---|
| 975 |
|
|---|
| 976 | return SendInternalMessageA (WM_SYSKEYDOWN, virtualKey, lParam);
|
|---|
| 977 | }
|
|---|
| 978 | //******************************************************************************
|
|---|
| 979 | //******************************************************************************
|
|---|
| 980 | ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
|
|---|
| 981 | {
|
|---|
| 982 | return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
|
|---|
| 983 | }
|
|---|
| 984 | //******************************************************************************
|
|---|
| 985 | //******************************************************************************
|
|---|
| 986 | ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
|
|---|
| 987 | {
|
|---|
| 988 | return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
|
|---|
| 989 | }
|
|---|
| 990 | //******************************************************************************
|
|---|
| 991 | //******************************************************************************
|
|---|
| 992 | //******************************************************************************
|
|---|
| 993 | ULONG Win32BaseWindow::MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly)
|
|---|
| 994 | {
|
|---|
| 995 | ULONG win32msg;
|
|---|
| 996 | ULONG win32ncmsg;
|
|---|
| 997 |
|
|---|
| 998 | dprintf(("MsgButton to (%d,%d)", ncx, ncy));
|
|---|
| 999 | switch(msg) {
|
|---|
| 1000 | case BUTTON_LEFTDOWN:
|
|---|
| 1001 | win32msg = WM_LBUTTONDOWN;
|
|---|
| 1002 | win32ncmsg = WM_NCLBUTTONDOWN;
|
|---|
| 1003 | break;
|
|---|
| 1004 | case BUTTON_LEFTUP:
|
|---|
| 1005 | win32msg = WM_LBUTTONUP;
|
|---|
| 1006 | win32ncmsg = WM_NCLBUTTONUP;
|
|---|
| 1007 | break;
|
|---|
| 1008 | case BUTTON_LEFTDBLCLICK:
|
|---|
| 1009 | if (windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
|
|---|
| 1010 | {
|
|---|
| 1011 | win32msg = WM_LBUTTONDBLCLK;
|
|---|
| 1012 | win32ncmsg = WM_NCLBUTTONDBLCLK;
|
|---|
| 1013 | } else
|
|---|
| 1014 | {
|
|---|
| 1015 | MsgButton(BUTTON_LEFTDOWN,ncx,ncy,clx,cly);
|
|---|
| 1016 | return MsgButton(BUTTON_LEFTUP,ncx,ncy,clx,cly);
|
|---|
| 1017 | }
|
|---|
| 1018 | break;
|
|---|
| 1019 | case BUTTON_RIGHTUP:
|
|---|
| 1020 | win32msg = WM_RBUTTONUP;
|
|---|
| 1021 | win32ncmsg = WM_NCRBUTTONUP;
|
|---|
| 1022 | break;
|
|---|
| 1023 | case BUTTON_RIGHTDOWN:
|
|---|
| 1024 | win32msg = WM_RBUTTONDOWN;
|
|---|
| 1025 | win32ncmsg = WM_NCRBUTTONDOWN;
|
|---|
| 1026 | break;
|
|---|
| 1027 | case BUTTON_RIGHTDBLCLICK:
|
|---|
| 1028 | if (windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
|
|---|
| 1029 | {
|
|---|
| 1030 | win32msg = WM_RBUTTONDBLCLK;
|
|---|
| 1031 | win32ncmsg = WM_NCRBUTTONDBLCLK;
|
|---|
| 1032 | } else
|
|---|
| 1033 | {
|
|---|
| 1034 | MsgButton(BUTTON_RIGHTDOWN,ncx,ncy,clx,cly);
|
|---|
| 1035 | return MsgButton(BUTTON_RIGHTUP,ncx,ncy,clx,cly);
|
|---|
| 1036 | }
|
|---|
| 1037 | break;
|
|---|
| 1038 | case BUTTON_MIDDLEUP:
|
|---|
| 1039 | win32msg = WM_MBUTTONUP;
|
|---|
| 1040 | win32ncmsg = WM_NCMBUTTONUP;
|
|---|
| 1041 | break;
|
|---|
| 1042 | case BUTTON_MIDDLEDOWN:
|
|---|
| 1043 | win32msg = WM_MBUTTONDOWN;
|
|---|
| 1044 | win32ncmsg = WM_NCMBUTTONDOWN;
|
|---|
| 1045 | break;
|
|---|
| 1046 | case BUTTON_MIDDLEDBLCLICK:
|
|---|
| 1047 | if (windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)
|
|---|
| 1048 | {
|
|---|
| 1049 | win32msg = WM_MBUTTONDBLCLK;
|
|---|
| 1050 | win32ncmsg = WM_NCMBUTTONDBLCLK;
|
|---|
| 1051 | } else
|
|---|
| 1052 | {
|
|---|
| 1053 | MsgButton(BUTTON_MIDDLEDOWN,ncx,ncy,clx,cly);
|
|---|
| 1054 | return MsgButton(BUTTON_MIDDLEUP,ncx,ncy,clx,cly);
|
|---|
| 1055 | }
|
|---|
| 1056 | break;
|
|---|
| 1057 | default:
|
|---|
| 1058 | dprintf(("Win32BaseWindow::Button: invalid msg!!!!"));
|
|---|
| 1059 | return 1;
|
|---|
| 1060 | }
|
|---|
| 1061 |
|
|---|
| 1062 | SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, win32ncmsg));
|
|---|
| 1063 |
|
|---|
| 1064 | //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
|
|---|
| 1065 | if(lastHitTestVal != HTCLIENT) {
|
|---|
| 1066 | return SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
|
|---|
| 1067 | }
|
|---|
| 1068 | return SendInternalMessageA(win32msg, 0, MAKELONG(clx, cly));
|
|---|
| 1069 | }
|
|---|
| 1070 | //******************************************************************************
|
|---|
| 1071 | //******************************************************************************
|
|---|
| 1072 | ULONG Win32BaseWindow::MsgMouseMove(ULONG keystate, ULONG x, ULONG y)
|
|---|
| 1073 | {
|
|---|
| 1074 | ULONG winstate = 0;
|
|---|
| 1075 | ULONG setcursormsg = WM_MOUSEMOVE;
|
|---|
| 1076 |
|
|---|
| 1077 | if(keystate & WMMOVE_LBUTTON)
|
|---|
| 1078 | winstate |= MK_LBUTTON;
|
|---|
| 1079 | if(keystate & WMMOVE_RBUTTON)
|
|---|
| 1080 | winstate |= MK_RBUTTON;
|
|---|
| 1081 | if(keystate & WMMOVE_MBUTTON)
|
|---|
| 1082 | winstate |= MK_MBUTTON;
|
|---|
| 1083 | if(keystate & WMMOVE_SHIFT)
|
|---|
| 1084 | winstate |= MK_SHIFT;
|
|---|
| 1085 | if(keystate & WMMOVE_CTRL)
|
|---|
| 1086 | winstate |= MK_CONTROL;
|
|---|
| 1087 |
|
|---|
| 1088 | if(lastHitTestVal != HTCLIENT) {
|
|---|
| 1089 | setcursormsg = WM_NCMOUSEMOVE;
|
|---|
| 1090 | }
|
|---|
| 1091 | //TODO: hiword should be 0 if window enters menu mode (SDK docs)
|
|---|
| 1092 | SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, setcursormsg));
|
|---|
| 1093 |
|
|---|
| 1094 | //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
|
|---|
| 1095 | if(lastHitTestVal != HTCLIENT) {
|
|---|
| 1096 | SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y));
|
|---|
| 1097 | }
|
|---|
| 1098 | return SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y));
|
|---|
| 1099 | }
|
|---|
| 1100 | //******************************************************************************
|
|---|
| 1101 | //******************************************************************************
|
|---|
| 1102 | ULONG Win32BaseWindow::MsgPaint(ULONG tmp1, BOOL select)
|
|---|
| 1103 | {
|
|---|
| 1104 | if (select && isIcon)
|
|---|
| 1105 | return SendInternalMessageA(WM_PAINTICON, 0, 0);
|
|---|
| 1106 | else
|
|---|
| 1107 | return SendInternalMessageA(WM_PAINT, 0, 0);
|
|---|
| 1108 | }
|
|---|
| 1109 | //******************************************************************************
|
|---|
| 1110 | //TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
|
|---|
| 1111 | // (or are we simply erasing too much here)
|
|---|
| 1112 | //******************************************************************************
|
|---|
| 1113 | ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
|
|---|
| 1114 | {
|
|---|
| 1115 | ULONG rc;
|
|---|
| 1116 | HDC hdcErase = hdc;
|
|---|
| 1117 |
|
|---|
| 1118 | if (hdcErase == 0)
|
|---|
| 1119 | hdcErase = O32_GetDC(OS2Hwnd);
|
|---|
| 1120 |
|
|---|
| 1121 | if(isIcon)
|
|---|
| 1122 | rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
|
|---|
| 1123 | else
|
|---|
| 1124 | rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
|
|---|
| 1125 | if (hdc == 0)
|
|---|
| 1126 | O32_ReleaseDC(OS2Hwnd, hdcErase);
|
|---|
| 1127 | return (rc);
|
|---|
| 1128 | }
|
|---|
| 1129 | //******************************************************************************
|
|---|
| 1130 | //******************************************************************************
|
|---|
| 1131 | ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
|
|---|
| 1132 | {
|
|---|
| 1133 | if(isUnicode) {
|
|---|
| 1134 | return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
|
|---|
| 1135 | }
|
|---|
| 1136 | else return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
|
|---|
| 1137 | }
|
|---|
| 1138 | //******************************************************************************
|
|---|
| 1139 | //TODO: in- or excluding terminating 0?
|
|---|
| 1140 | //******************************************************************************
|
|---|
| 1141 | ULONG Win32BaseWindow::MsgGetTextLength()
|
|---|
| 1142 | {
|
|---|
| 1143 | return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
|
|---|
| 1144 | }
|
|---|
| 1145 | //******************************************************************************
|
|---|
| 1146 | //******************************************************************************
|
|---|
| 1147 | char *Win32BaseWindow::MsgGetText()
|
|---|
| 1148 | {
|
|---|
| 1149 | if(isUnicode) {
|
|---|
| 1150 | SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW);
|
|---|
| 1151 | }
|
|---|
| 1152 | else {
|
|---|
| 1153 | SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
|
|---|
| 1154 | }
|
|---|
| 1155 | return windowNameA;
|
|---|
| 1156 | }
|
|---|
| 1157 | //******************************************************************************
|
|---|
| 1158 | //******************************************************************************
|
|---|
| 1159 | BOOL Win32BaseWindow::isMDIClient()
|
|---|
| 1160 | {
|
|---|
| 1161 | return FALSE;
|
|---|
| 1162 | }
|
|---|
| 1163 | //******************************************************************************
|
|---|
| 1164 | //******************************************************************************
|
|---|
| 1165 | BOOL Win32BaseWindow::isMDIChild()
|
|---|
| 1166 | {
|
|---|
| 1167 | return FALSE;
|
|---|
| 1168 | }
|
|---|
| 1169 | //******************************************************************************
|
|---|
| 1170 | //TODO: Not complete
|
|---|
| 1171 | //******************************************************************************
|
|---|
| 1172 | BOOL Win32BaseWindow::isFrameWindow()
|
|---|
| 1173 | {
|
|---|
| 1174 | // if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
|
|---|
| 1175 | if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL))
|
|---|
| 1176 | return TRUE;
|
|---|
| 1177 |
|
|---|
| 1178 | return FALSE;
|
|---|
| 1179 | }
|
|---|
| 1180 | //******************************************************************************
|
|---|
| 1181 | //TODO: Not complete (flags)
|
|---|
| 1182 | //******************************************************************************
|
|---|
| 1183 | SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
|
|---|
| 1184 | {
|
|---|
| 1185 | switch(nBar) {
|
|---|
| 1186 | case SB_HORZ:
|
|---|
| 1187 | if(horzScrollInfo) {
|
|---|
| 1188 | horzScrollInfo->CurVal = OSLibWinGetScrollPos(OS2HwndFrame, hwndHorzScroll);
|
|---|
| 1189 | return horzScrollInfo;
|
|---|
| 1190 | }
|
|---|
| 1191 | break;
|
|---|
| 1192 | case SB_VERT:
|
|---|
| 1193 | if(vertScrollInfo) {
|
|---|
| 1194 | vertScrollInfo->CurVal = OSLibWinGetScrollPos(OS2HwndFrame, hwndVertScroll);
|
|---|
| 1195 | return vertScrollInfo;
|
|---|
| 1196 | }
|
|---|
| 1197 | break;
|
|---|
| 1198 | }
|
|---|
| 1199 | return NULL;
|
|---|
| 1200 | }
|
|---|
| 1201 | //******************************************************************************
|
|---|
| 1202 | //TODO: Not complete
|
|---|
| 1203 | //******************************************************************************
|
|---|
| 1204 | LONG Win32BaseWindow::setScrollInfo(int nBar, SCROLLINFO *info, int fRedraw)
|
|---|
| 1205 | {
|
|---|
| 1206 | SCROLLBAR_INFO *infoPtr;
|
|---|
| 1207 | HWND hwndScroll;
|
|---|
| 1208 | ULONG scrollType;
|
|---|
| 1209 | int new_flags;
|
|---|
| 1210 |
|
|---|
| 1211 | switch(nBar) {
|
|---|
| 1212 | case SB_HORZ:
|
|---|
| 1213 | if(!horzScrollInfo) {
|
|---|
| 1214 | return 0;
|
|---|
| 1215 | }
|
|---|
| 1216 | infoPtr = horzScrollInfo;
|
|---|
| 1217 | hwndScroll = hwndHorzScroll;
|
|---|
| 1218 | scrollType = OSLIB_HSCROLL;
|
|---|
| 1219 | break;
|
|---|
| 1220 | case SB_VERT:
|
|---|
| 1221 | if(!vertScrollInfo) {
|
|---|
| 1222 | return 0;
|
|---|
| 1223 | }
|
|---|
| 1224 | infoPtr = vertScrollInfo;
|
|---|
| 1225 | hwndScroll = hwndVertScroll;
|
|---|
| 1226 | scrollType = OSLIB_VSCROLL;
|
|---|
| 1227 | break;
|
|---|
| 1228 | default:
|
|---|
| 1229 | return 0;
|
|---|
| 1230 | }
|
|---|
| 1231 |
|
|---|
| 1232 | if (info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) return 0;
|
|---|
| 1233 | if ((info->cbSize != sizeof(*info)) &&
|
|---|
| 1234 | (info->cbSize != sizeof(*info)-sizeof(info->nTrackPos))) return 0;
|
|---|
| 1235 |
|
|---|
| 1236 | /* Set the page size */
|
|---|
| 1237 | if (info->fMask & SIF_PAGE)
|
|---|
| 1238 | {
|
|---|
| 1239 | if( infoPtr->Page != info->nPage )
|
|---|
| 1240 | {
|
|---|
| 1241 | infoPtr->Page = info->nPage;
|
|---|
| 1242 | dprintf(("SetScrollInfo: Set pagesize to %d", info->nPage));
|
|---|
| 1243 | OSLibWinSetScrollPageSize(OS2HwndFrame, hwndScroll, info->nPage, infoPtr->MaxVal, fRedraw);
|
|---|
| 1244 | }
|
|---|
| 1245 | }
|
|---|
| 1246 |
|
|---|
| 1247 | /* Set the scroll pos */
|
|---|
| 1248 | if (info->fMask & SIF_POS)
|
|---|
| 1249 | {
|
|---|
| 1250 | if( infoPtr->CurVal != info->nPos )
|
|---|
| 1251 | {
|
|---|
| 1252 | infoPtr->CurVal = info->nPos;
|
|---|
| 1253 | dprintf(("SetScrollInfo: Set scroll position to %d", info->nPos));
|
|---|
| 1254 | OSLibWinSetScrollPos(OS2HwndFrame, hwndScroll, info->nPos, fRedraw);
|
|---|
| 1255 | }
|
|---|
| 1256 | }
|
|---|
| 1257 |
|
|---|
| 1258 | /* Set the scroll range */
|
|---|
| 1259 | if (info->fMask & SIF_RANGE)
|
|---|
| 1260 | {
|
|---|
| 1261 | /* Invalid range -> range is set to (0,0) */
|
|---|
| 1262 | if ((info->nMin > info->nMax) ||
|
|---|
| 1263 | ((UINT)(info->nMax - info->nMin) >= 0x80000000))
|
|---|
| 1264 | {
|
|---|
| 1265 | infoPtr->MinVal = 0;
|
|---|
| 1266 | infoPtr->MaxVal = 0;
|
|---|
| 1267 | }
|
|---|
| 1268 | else
|
|---|
| 1269 | {
|
|---|
| 1270 | if( infoPtr->MinVal != info->nMin ||
|
|---|
| 1271 | infoPtr->MaxVal != info->nMax )
|
|---|
| 1272 | {
|
|---|
| 1273 | infoPtr->MinVal = info->nMin;
|
|---|
| 1274 | infoPtr->MaxVal = info->nMax;
|
|---|
| 1275 |
|
|---|
| 1276 | dprintf(("SetScrollInfo: Set scroll range to (%d,%d)", info->nMin, info->nMax));
|
|---|
| 1277 | OSLibWinSetScrollRange(OS2HwndFrame, hwndScroll, info->nMin, info->nMax, fRedraw);
|
|---|
| 1278 | }
|
|---|
| 1279 | }
|
|---|
| 1280 | }
|
|---|
| 1281 |
|
|---|
| 1282 | /* Make sure the page size is valid */
|
|---|
| 1283 | if (infoPtr->Page < 0) infoPtr->Page = 0;
|
|---|
| 1284 | else if (infoPtr->Page > infoPtr->MaxVal - infoPtr->MinVal + 1 )
|
|---|
| 1285 | infoPtr->Page = infoPtr->MaxVal - infoPtr->MinVal + 1;
|
|---|
| 1286 |
|
|---|
| 1287 | /* Make sure the pos is inside the range */
|
|---|
| 1288 | if (infoPtr->CurVal < infoPtr->MinVal)
|
|---|
| 1289 | infoPtr->CurVal = infoPtr->MinVal;
|
|---|
| 1290 | else if (infoPtr->CurVal > infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 ))
|
|---|
| 1291 | infoPtr->CurVal = infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 );
|
|---|
| 1292 |
|
|---|
| 1293 | /* Check if the scrollbar should be hidden or disabled */
|
|---|
| 1294 | if (info->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL))
|
|---|
| 1295 | {
|
|---|
| 1296 | new_flags = infoPtr->flags;
|
|---|
| 1297 | if (infoPtr->MinVal >= infoPtr->MaxVal - MAX( infoPtr->Page-1, 0 ))
|
|---|
| 1298 | {
|
|---|
| 1299 | /* Hide or disable scroll-bar */
|
|---|
| 1300 | if (info->fMask & SIF_DISABLENOSCROLL)
|
|---|
| 1301 | {
|
|---|
| 1302 | new_flags = ESB_DISABLE_BOTH;
|
|---|
| 1303 | // *action |= SA_SSI_REFRESH;
|
|---|
| 1304 | }
|
|---|
| 1305 | else if (nBar != SB_CTL)
|
|---|
| 1306 | {
|
|---|
| 1307 | // *action = SA_SSI_HIDE;
|
|---|
| 1308 | goto done;
|
|---|
| 1309 | }
|
|---|
| 1310 | }
|
|---|
| 1311 | else /* Show and enable scroll-bar */
|
|---|
| 1312 | {
|
|---|
| 1313 | new_flags = 0;
|
|---|
| 1314 | // if (nBar != SB_CTL)
|
|---|
| 1315 | // *action |= SA_SSI_SHOW;
|
|---|
| 1316 | }
|
|---|
| 1317 |
|
|---|
| 1318 | if (infoPtr->flags != new_flags) /* check arrow flags */
|
|---|
| 1319 | {
|
|---|
| 1320 | infoPtr->flags = new_flags;
|
|---|
| 1321 | }
|
|---|
| 1322 | }
|
|---|
| 1323 |
|
|---|
| 1324 | done:
|
|---|
| 1325 | /* Return current position */
|
|---|
| 1326 |
|
|---|
| 1327 | return infoPtr->CurVal;
|
|---|
| 1328 | }
|
|---|
| 1329 | /***********************************************************************
|
|---|
| 1330 | * NC_HandleSysCommand
|
|---|
| 1331 | *
|
|---|
| 1332 | * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
|
|---|
| 1333 | *
|
|---|
| 1334 | * TODO: Not done (see #if 0)
|
|---|
| 1335 | */
|
|---|
| 1336 | LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam, POINT *pt32)
|
|---|
| 1337 | {
|
|---|
| 1338 | UINT uCommand = wParam & 0xFFF0;
|
|---|
| 1339 |
|
|---|
| 1340 | if (getStyle() & WS_CHILD && uCommand != SC_KEYMENU )
|
|---|
| 1341 | ScreenToClient(getParent()->getWindowHandle(), pt32 );
|
|---|
| 1342 |
|
|---|
| 1343 | switch (uCommand)
|
|---|
| 1344 | {
|
|---|
| 1345 | #if 0
|
|---|
| 1346 | case SC_SIZE:
|
|---|
| 1347 | case SC_MOVE:
|
|---|
| 1348 | NC_DoSizeMove( hwnd, wParam );
|
|---|
| 1349 | break;
|
|---|
| 1350 | #endif
|
|---|
| 1351 |
|
|---|
| 1352 | case SC_MINIMIZE:
|
|---|
| 1353 | ShowWindow(SW_MINIMIZE);
|
|---|
| 1354 | break;
|
|---|
| 1355 |
|
|---|
| 1356 | case SC_MAXIMIZE:
|
|---|
| 1357 | ShowWindow(SW_MAXIMIZE);
|
|---|
| 1358 | break;
|
|---|
| 1359 |
|
|---|
| 1360 | case SC_RESTORE:
|
|---|
| 1361 | ShowWindow(SW_RESTORE);
|
|---|
| 1362 | break;
|
|---|
| 1363 |
|
|---|
| 1364 | case SC_CLOSE:
|
|---|
| 1365 | return SendMessageA(WM_CLOSE, 0, 0);
|
|---|
| 1366 |
|
|---|
| 1367 | #if 0
|
|---|
| 1368 | case SC_VSCROLL:
|
|---|
| 1369 | case SC_HSCROLL:
|
|---|
| 1370 | NC_TrackScrollBar( hwnd, wParam, pt32 );
|
|---|
| 1371 | break;
|
|---|
| 1372 |
|
|---|
| 1373 | case SC_MOUSEMENU:
|
|---|
| 1374 | MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt32 );
|
|---|
| 1375 | break;
|
|---|
| 1376 |
|
|---|
| 1377 | case SC_KEYMENU:
|
|---|
| 1378 | MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
|
|---|
| 1379 | break;
|
|---|
| 1380 |
|
|---|
| 1381 | case SC_TASKLIST:
|
|---|
| 1382 | WinExec( "taskman.exe", SW_SHOWNORMAL );
|
|---|
| 1383 | break;
|
|---|
| 1384 |
|
|---|
| 1385 | case SC_SCREENSAVE:
|
|---|
| 1386 | if (wParam == SC_ABOUTWINE)
|
|---|
| 1387 | ShellAboutA(hwnd, "Odin", WINE_RELEASE_INFO, 0);
|
|---|
| 1388 | else
|
|---|
| 1389 | if (wParam == SC_PUTMARK)
|
|---|
| 1390 | dprintf(("Mark requested by user\n"));
|
|---|
| 1391 | break;
|
|---|
| 1392 |
|
|---|
| 1393 | case SC_HOTKEY:
|
|---|
| 1394 | case SC_ARRANGE:
|
|---|
| 1395 | case SC_NEXTWINDOW:
|
|---|
| 1396 | case SC_PREVWINDOW:
|
|---|
| 1397 | break;
|
|---|
| 1398 | #endif
|
|---|
| 1399 | }
|
|---|
| 1400 | return 0;
|
|---|
| 1401 | }
|
|---|
| 1402 | //******************************************************************************
|
|---|
| 1403 | //******************************************************************************
|
|---|
| 1404 | LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
|
|---|
| 1405 | {
|
|---|
| 1406 | //SvL: Set background color to default button color (not window (white))
|
|---|
| 1407 | if(ctlType == CTLCOLOR_BTN)
|
|---|
| 1408 | {
|
|---|
| 1409 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
|---|
| 1410 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
|---|
| 1411 | return GetSysColorBrush(COLOR_BTNFACE);
|
|---|
| 1412 | }
|
|---|
| 1413 | //SvL: Set background color to default dialog color if window is dialog
|
|---|
| 1414 | if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
|
|---|
| 1415 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
|---|
| 1416 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
|---|
| 1417 | return GetSysColorBrush(COLOR_BTNFACE);
|
|---|
| 1418 | }
|
|---|
| 1419 |
|
|---|
| 1420 | if( ctlType == CTLCOLOR_SCROLLBAR)
|
|---|
| 1421 | {
|
|---|
| 1422 | HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
|
|---|
| 1423 | COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
|
|---|
| 1424 | SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
|
|---|
| 1425 | SetBkColor( hdc, bk);
|
|---|
| 1426 |
|
|---|
| 1427 | //TODO?
|
|---|
| 1428 | #if 0
|
|---|
| 1429 | /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
|
|---|
| 1430 | * we better use 0x55aa bitmap brush to make scrollbar's background
|
|---|
| 1431 | * look different from the window background.
|
|---|
| 1432 | */
|
|---|
| 1433 | if (bk == GetSysColor(COLOR_WINDOW)) {
|
|---|
| 1434 | return CACHE_GetPattern55AABrush();
|
|---|
| 1435 | }
|
|---|
| 1436 | #endif
|
|---|
| 1437 | UnrealizeObject( hb );
|
|---|
| 1438 | return (LRESULT)hb;
|
|---|
| 1439 | }
|
|---|
| 1440 |
|
|---|
| 1441 | SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
|
|---|
| 1442 |
|
|---|
| 1443 | if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
|
|---|
| 1444 | {
|
|---|
| 1445 | SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
|
|---|
| 1446 | }
|
|---|
| 1447 | else
|
|---|
| 1448 | {
|
|---|
| 1449 | SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
|
|---|
| 1450 | return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
|
|---|
| 1451 | }
|
|---|
| 1452 | return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
|
|---|
| 1453 | }
|
|---|
| 1454 | //******************************************************************************
|
|---|
| 1455 | //******************************************************************************
|
|---|
| 1456 | LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1457 | {
|
|---|
| 1458 | switch(Msg)
|
|---|
| 1459 | {
|
|---|
| 1460 | case WM_CLOSE:
|
|---|
| 1461 | DestroyWindow();
|
|---|
| 1462 | return 0;
|
|---|
| 1463 |
|
|---|
| 1464 | case WM_GETTEXTLENGTH:
|
|---|
| 1465 | return wndNameLength;
|
|---|
| 1466 |
|
|---|
| 1467 | case WM_GETTEXT: //TODO: SS_ICON controls
|
|---|
| 1468 | strncpy((LPSTR)lParam, windowNameA, wParam);
|
|---|
| 1469 | return min(wndNameLength, wParam);
|
|---|
| 1470 |
|
|---|
| 1471 | case WM_SETTEXT:
|
|---|
| 1472 | if(!fInternalMsg) {
|
|---|
| 1473 | return SetWindowTextA((LPSTR)lParam);
|
|---|
| 1474 | }
|
|---|
| 1475 | else return 0;
|
|---|
| 1476 |
|
|---|
| 1477 | case WM_SETREDRAW:
|
|---|
| 1478 | if(wParam)
|
|---|
| 1479 | SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
|
|---|
| 1480 | else SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
|
|---|
| 1481 |
|
|---|
| 1482 | return 0; //TODO
|
|---|
| 1483 |
|
|---|
| 1484 | case WM_NCCREATE:
|
|---|
| 1485 | return(TRUE);
|
|---|
| 1486 |
|
|---|
| 1487 | case WM_NCCALCSIZE:
|
|---|
| 1488 | return NCHandleCalcSize(wParam, (NCCALCSIZE_PARAMS *)lParam);
|
|---|
| 1489 |
|
|---|
| 1490 | case WM_CTLCOLORMSGBOX:
|
|---|
| 1491 | case WM_CTLCOLOREDIT:
|
|---|
| 1492 | case WM_CTLCOLORLISTBOX:
|
|---|
| 1493 | case WM_CTLCOLORBTN:
|
|---|
| 1494 | case WM_CTLCOLORDLG:
|
|---|
| 1495 | case WM_CTLCOLORSTATIC:
|
|---|
| 1496 | case WM_CTLCOLORSCROLLBAR:
|
|---|
| 1497 | return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
|
|---|
| 1498 |
|
|---|
| 1499 | case WM_CTLCOLOR:
|
|---|
| 1500 | return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
|
|---|
| 1501 |
|
|---|
| 1502 | case WM_VKEYTOITEM:
|
|---|
| 1503 | case WM_CHARTOITEM:
|
|---|
| 1504 | return -1;
|
|---|
| 1505 |
|
|---|
| 1506 | case WM_PARENTNOTIFY:
|
|---|
| 1507 | return 0;
|
|---|
| 1508 |
|
|---|
| 1509 | case WM_MOUSEACTIVATE:
|
|---|
| 1510 | {
|
|---|
| 1511 | DWORD dwStyle = GetWindowLongA(GWL_STYLE);
|
|---|
| 1512 | DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
|
|---|
| 1513 | dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
|
|---|
| 1514 | if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
|
|---|
| 1515 | {
|
|---|
| 1516 | if(getParent()) {
|
|---|
| 1517 | LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
|
|---|
| 1518 | if(rc) return rc;
|
|---|
| 1519 | }
|
|---|
| 1520 | }
|
|---|
| 1521 | return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
|
|---|
| 1522 | }
|
|---|
| 1523 | case WM_SETCURSOR:
|
|---|
| 1524 | {
|
|---|
| 1525 | DWORD dwStyle = GetWindowLongA(GWL_STYLE);
|
|---|
| 1526 | DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
|
|---|
| 1527 | dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
|
|---|
| 1528 | if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
|
|---|
| 1529 | {
|
|---|
| 1530 | if(getParent()) {
|
|---|
| 1531 | LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
|
|---|
| 1532 | if(rc) return rc;
|
|---|
| 1533 | }
|
|---|
| 1534 | }
|
|---|
| 1535 | return 1;
|
|---|
| 1536 | }
|
|---|
| 1537 | case WM_MOUSEMOVE:
|
|---|
| 1538 | return 1; //Let OS/2 change the mouse cursor back to the default
|
|---|
| 1539 |
|
|---|
| 1540 | case WM_WINDOWPOSCHANGED:
|
|---|
| 1541 | {
|
|---|
| 1542 |
|
|---|
| 1543 | /* undocumented SWP flags - from SDK 3.1 */
|
|---|
| 1544 | #define SWP_NOCLIENTSIZE 0x0800
|
|---|
| 1545 | #define SWP_NOCLIENTMOVE 0x1000
|
|---|
| 1546 |
|
|---|
| 1547 | PWINDOWPOS wpos = (PWINDOWPOS)lParam;
|
|---|
| 1548 | WPARAM wp = SIZE_RESTORED;
|
|---|
| 1549 |
|
|---|
| 1550 | if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
|
|---|
| 1551 | SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
|
|---|
| 1552 |
|
|---|
| 1553 | if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
|
|---|
| 1554 | {
|
|---|
| 1555 | if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
|
|---|
| 1556 | else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
|
|---|
| 1557 |
|
|---|
| 1558 | SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
|
|---|
| 1559 | rectClient.bottom - rectClient.top));
|
|---|
| 1560 | }
|
|---|
| 1561 | return 0;
|
|---|
| 1562 | }
|
|---|
| 1563 | case WM_ERASEBKGND:
|
|---|
| 1564 | case WM_ICONERASEBKGND:
|
|---|
| 1565 | {
|
|---|
| 1566 | RECT rect;
|
|---|
| 1567 | int rc;
|
|---|
| 1568 |
|
|---|
| 1569 | if (!windowClass->getBackgroundBrush()) return 0;
|
|---|
| 1570 |
|
|---|
| 1571 | rc = GetClipBox( (HDC)wParam, &rect );
|
|---|
| 1572 | if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
|
|---|
| 1573 | FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
|
|---|
| 1574 |
|
|---|
| 1575 | return 1;
|
|---|
| 1576 | }
|
|---|
| 1577 | case WM_GETDLGCODE:
|
|---|
| 1578 | return 0;
|
|---|
| 1579 |
|
|---|
| 1580 | case WM_NCLBUTTONDOWN:
|
|---|
| 1581 | case WM_NCLBUTTONUP:
|
|---|
| 1582 | case WM_NCLBUTTONDBLCLK:
|
|---|
| 1583 | case WM_NCRBUTTONUP:
|
|---|
| 1584 | case WM_NCRBUTTONDOWN:
|
|---|
| 1585 | case WM_NCRBUTTONDBLCLK:
|
|---|
| 1586 | case WM_NCMBUTTONDOWN:
|
|---|
| 1587 | case WM_NCMBUTTONUP:
|
|---|
| 1588 | case WM_NCMBUTTONDBLCLK:
|
|---|
| 1589 | return 0; //TODO: Send WM_SYSCOMMAND if required
|
|---|
| 1590 |
|
|---|
| 1591 | case WM_NCHITTEST: //TODO: Calculate position of
|
|---|
| 1592 | return HTCLIENT;
|
|---|
| 1593 |
|
|---|
| 1594 | case WM_SYSCOMMAND:
|
|---|
| 1595 | {
|
|---|
| 1596 | POINT point;
|
|---|
| 1597 |
|
|---|
| 1598 | point.x = LOWORD(lParam);
|
|---|
| 1599 | point.y = HIWORD(lParam);
|
|---|
| 1600 | return HandleSysCommand(wParam, &point);
|
|---|
| 1601 | }
|
|---|
| 1602 |
|
|---|
| 1603 | case WM_SYSKEYDOWN:
|
|---|
| 1604 | if(HIWORD(lParam) & KEYDATA_ALT)
|
|---|
| 1605 | {
|
|---|
| 1606 | if(wParam == VK_F4) /* try to close the window */
|
|---|
| 1607 | {
|
|---|
| 1608 | Win32BaseWindow *window = GetTopParent();
|
|---|
| 1609 | if(window && !(window->getClass()->getStyle() & CS_NOCLOSE) )
|
|---|
| 1610 | window->PostMessageA(WM_SYSCOMMAND, SC_CLOSE, 0);
|
|---|
| 1611 | }
|
|---|
| 1612 | }
|
|---|
| 1613 | return 0;
|
|---|
| 1614 |
|
|---|
| 1615 | case WM_QUERYOPEN:
|
|---|
| 1616 | case WM_QUERYENDSESSION:
|
|---|
| 1617 | return 1;
|
|---|
| 1618 |
|
|---|
| 1619 | case WM_NOTIFYFORMAT:
|
|---|
| 1620 | if (IsUnicode()) return NFR_UNICODE;
|
|---|
| 1621 | else return NFR_ANSI;
|
|---|
| 1622 |
|
|---|
| 1623 | case WM_SETICON:
|
|---|
| 1624 | case WM_GETICON:
|
|---|
| 1625 | {
|
|---|
| 1626 | LRESULT result = 0;
|
|---|
| 1627 | int index = GCL_HICON;
|
|---|
| 1628 |
|
|---|
| 1629 | if (wParam == ICON_SMALL)
|
|---|
| 1630 | index = GCL_HICONSM;
|
|---|
| 1631 |
|
|---|
| 1632 | result = windowClass->getClassLongA(index);
|
|---|
| 1633 |
|
|---|
| 1634 | if (Msg == WM_SETICON)
|
|---|
| 1635 | windowClass->setClassLongA(index, lParam);
|
|---|
| 1636 |
|
|---|
| 1637 | return result;
|
|---|
| 1638 | }
|
|---|
| 1639 |
|
|---|
| 1640 | default:
|
|---|
| 1641 | return 1;
|
|---|
| 1642 | }
|
|---|
| 1643 | }
|
|---|
| 1644 | //******************************************************************************
|
|---|
| 1645 | //******************************************************************************
|
|---|
| 1646 | LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1647 | {
|
|---|
| 1648 | switch(Msg)
|
|---|
| 1649 | {
|
|---|
| 1650 | case WM_GETTEXTLENGTH:
|
|---|
| 1651 | return wndNameLength;
|
|---|
| 1652 |
|
|---|
| 1653 | case WM_GETTEXT: //TODO: SS_ICON controls
|
|---|
| 1654 | lstrcpynW((LPWSTR)lParam, windowNameW, wParam);
|
|---|
| 1655 | return min(wndNameLength, wParam);
|
|---|
| 1656 |
|
|---|
| 1657 | case WM_SETTEXT:
|
|---|
| 1658 | if(!fInternalMsg) {
|
|---|
| 1659 | return SetWindowTextW((LPWSTR)lParam);
|
|---|
| 1660 | }
|
|---|
| 1661 | else return 0;
|
|---|
| 1662 |
|
|---|
| 1663 | default:
|
|---|
| 1664 | return DefWindowProcA(Msg, wParam, lParam);
|
|---|
| 1665 | }
|
|---|
| 1666 | }
|
|---|
| 1667 | //******************************************************************************
|
|---|
| 1668 | //******************************************************************************
|
|---|
| 1669 | LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1670 | {
|
|---|
| 1671 | LRESULT rc;
|
|---|
| 1672 | BOOL fInternalMsgBackup = fInternalMsg;
|
|---|
| 1673 |
|
|---|
| 1674 | if(Msg != WM_GETDLGCODE && Msg != WM_ENTERIDLE) {//sent *very* often
|
|---|
| 1675 | if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
|
|---|
| 1676 | dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
|
|---|
| 1677 | }
|
|---|
| 1678 |
|
|---|
| 1679 | if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
|
|---|
| 1680 | return(0);
|
|---|
| 1681 | }
|
|---|
| 1682 | fInternalMsg = FALSE;
|
|---|
| 1683 | switch(Msg)
|
|---|
| 1684 | {
|
|---|
| 1685 | case WM_CREATE:
|
|---|
| 1686 | {
|
|---|
| 1687 | if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
|
|---|
| 1688 | dprintf(("WM_CREATE returned -1\n"));
|
|---|
| 1689 | rc = -1; //don't create window
|
|---|
| 1690 | break;
|
|---|
| 1691 | }
|
|---|
| 1692 | NotifyParent(Msg, wParam, lParam);
|
|---|
| 1693 |
|
|---|
| 1694 | rc = 0;
|
|---|
| 1695 | break;
|
|---|
| 1696 | }
|
|---|
| 1697 | case WM_SETTEXT:
|
|---|
| 1698 | rc = win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
|
|---|
| 1699 | break;
|
|---|
| 1700 |
|
|---|
| 1701 | case WM_LBUTTONDOWN:
|
|---|
| 1702 | case WM_MBUTTONDOWN:
|
|---|
| 1703 | case WM_RBUTTONDOWN:
|
|---|
| 1704 | NotifyParent(Msg, wParam, lParam);
|
|---|
| 1705 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
|---|
| 1706 | break;
|
|---|
| 1707 |
|
|---|
| 1708 | case WM_DESTROY:
|
|---|
| 1709 | win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
|
|---|
| 1710 | rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
|
|---|
| 1711 | break;
|
|---|
| 1712 |
|
|---|
| 1713 | default:
|
|---|
| 1714 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
|---|
| 1715 | break;
|
|---|
| 1716 | }
|
|---|
| 1717 | fInternalMsg = fInternalMsgBackup;
|
|---|
| 1718 | return rc;
|
|---|
| 1719 | }
|
|---|
| 1720 | //******************************************************************************
|
|---|
| 1721 | //******************************************************************************
|
|---|
| 1722 | LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1723 | {
|
|---|
| 1724 | LRESULT rc;
|
|---|
| 1725 | BOOL fInternalMsgBackup = fInternalMsg;
|
|---|
| 1726 |
|
|---|
| 1727 | if(Msg != WM_GETDLGCODE && Msg != WM_ENTERIDLE) {//sent *very* often
|
|---|
| 1728 | if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
|
|---|
| 1729 | dprintf(("SendMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
|
|---|
| 1730 | }
|
|---|
| 1731 |
|
|---|
| 1732 | if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
|
|---|
| 1733 | return(0);
|
|---|
| 1734 | }
|
|---|
| 1735 | fInternalMsg = FALSE;
|
|---|
| 1736 | switch(Msg)
|
|---|
| 1737 | {
|
|---|
| 1738 | case WM_CREATE:
|
|---|
| 1739 | {
|
|---|
| 1740 | if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
|
|---|
| 1741 | dprintf(("WM_CREATE returned -1\n"));
|
|---|
| 1742 | rc = -1; //don't create window
|
|---|
| 1743 | break;
|
|---|
| 1744 | }
|
|---|
| 1745 | NotifyParent(Msg, wParam, lParam);
|
|---|
| 1746 |
|
|---|
| 1747 | rc = 0;
|
|---|
| 1748 | break;
|
|---|
| 1749 | }
|
|---|
| 1750 | case WM_SETTEXT:
|
|---|
| 1751 | rc = win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
|
|---|
| 1752 | break;
|
|---|
| 1753 |
|
|---|
| 1754 | case WM_LBUTTONDOWN:
|
|---|
| 1755 | case WM_MBUTTONDOWN:
|
|---|
| 1756 | case WM_RBUTTONDOWN:
|
|---|
| 1757 | NotifyParent(Msg, wParam, lParam);
|
|---|
| 1758 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
|---|
| 1759 | break;
|
|---|
| 1760 |
|
|---|
| 1761 | case WM_DESTROY:
|
|---|
| 1762 | win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
|
|---|
| 1763 | rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
|
|---|
| 1764 | break;
|
|---|
| 1765 |
|
|---|
| 1766 | default:
|
|---|
| 1767 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
|---|
| 1768 | break;
|
|---|
| 1769 | }
|
|---|
| 1770 | fInternalMsg = fInternalMsgBackup;
|
|---|
| 1771 | return rc;
|
|---|
| 1772 | }
|
|---|
| 1773 | //******************************************************************************
|
|---|
| 1774 | //Called as a result of an OS/2 message
|
|---|
| 1775 | //******************************************************************************
|
|---|
| 1776 | LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1777 | {
|
|---|
| 1778 | LRESULT rc;
|
|---|
| 1779 | BOOL fInternalMsgBackup = fInternalMsg;
|
|---|
| 1780 |
|
|---|
| 1781 | if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
|
|---|
| 1782 | dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
|
|---|
| 1783 |
|
|---|
| 1784 | if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
|
|---|
| 1785 | return(0);
|
|---|
| 1786 | }
|
|---|
| 1787 | fInternalMsg = TRUE;
|
|---|
| 1788 | switch(Msg)
|
|---|
| 1789 | {
|
|---|
| 1790 | case WM_CREATE:
|
|---|
| 1791 | {
|
|---|
| 1792 | if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
|
|---|
| 1793 | dprintf(("WM_CREATE returned -1\n"));
|
|---|
| 1794 | rc = -1; //don't create window
|
|---|
| 1795 | break;
|
|---|
| 1796 | }
|
|---|
| 1797 | NotifyParent(Msg, wParam, lParam);
|
|---|
| 1798 | rc = 0;
|
|---|
| 1799 | break;
|
|---|
| 1800 | }
|
|---|
| 1801 | case WM_LBUTTONDOWN:
|
|---|
| 1802 | case WM_MBUTTONDOWN:
|
|---|
| 1803 | case WM_RBUTTONDOWN:
|
|---|
| 1804 | NotifyParent(Msg, wParam, lParam);
|
|---|
| 1805 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
|---|
| 1806 | break;
|
|---|
| 1807 |
|
|---|
| 1808 | case WM_DESTROY:
|
|---|
| 1809 | win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
|
|---|
| 1810 | rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
|
|---|
| 1811 | break;
|
|---|
| 1812 | default:
|
|---|
| 1813 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
|---|
| 1814 | break;
|
|---|
| 1815 | }
|
|---|
| 1816 | fInternalMsg = fInternalMsgBackup;
|
|---|
| 1817 | return rc;
|
|---|
| 1818 | }
|
|---|
| 1819 | //******************************************************************************
|
|---|
| 1820 | //Called as a result of an OS/2 message
|
|---|
| 1821 | //todo, unicode msgs (WM_SETTEXT etc)
|
|---|
| 1822 | //******************************************************************************
|
|---|
| 1823 | LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1824 | {
|
|---|
| 1825 | LRESULT rc;
|
|---|
| 1826 | BOOL fInternalMsgBackup = fInternalMsg;
|
|---|
| 1827 |
|
|---|
| 1828 | if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
|
|---|
| 1829 | dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
|
|---|
| 1830 |
|
|---|
| 1831 | if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
|
|---|
| 1832 | return(0);
|
|---|
| 1833 | }
|
|---|
| 1834 | fInternalMsg = TRUE;
|
|---|
| 1835 | switch(Msg)
|
|---|
| 1836 | {
|
|---|
| 1837 | case WM_CREATE:
|
|---|
| 1838 | {
|
|---|
| 1839 | if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
|
|---|
| 1840 | dprintf(("WM_CREATE returned -1\n"));
|
|---|
| 1841 | rc = -1; //don't create window
|
|---|
| 1842 | break;
|
|---|
| 1843 | }
|
|---|
| 1844 | NotifyParent(Msg, wParam, lParam);
|
|---|
| 1845 | rc = 0;
|
|---|
| 1846 | break;
|
|---|
| 1847 | }
|
|---|
| 1848 | case WM_LBUTTONDOWN:
|
|---|
| 1849 | case WM_MBUTTONDOWN:
|
|---|
| 1850 | case WM_RBUTTONDOWN:
|
|---|
| 1851 | NotifyParent(Msg, wParam, lParam);
|
|---|
| 1852 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
|---|
| 1853 | break;
|
|---|
| 1854 |
|
|---|
| 1855 | case WM_DESTROY:
|
|---|
| 1856 | win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
|
|---|
| 1857 | rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
|
|---|
| 1858 | break;
|
|---|
| 1859 | default:
|
|---|
| 1860 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
|---|
| 1861 | break;
|
|---|
| 1862 | }
|
|---|
| 1863 | fInternalMsg = fInternalMsgBackup;
|
|---|
| 1864 | return rc;
|
|---|
| 1865 | }
|
|---|
| 1866 | //******************************************************************************
|
|---|
| 1867 | //******************************************************************************
|
|---|
| 1868 | BOOL Win32BaseWindow::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1869 | {
|
|---|
| 1870 | return OSLibPostMessage(OS2Hwnd, WIN32APP_USERMSGBASE+msg, wParam, lParam);
|
|---|
| 1871 | }
|
|---|
| 1872 | //******************************************************************************
|
|---|
| 1873 | //******************************************************************************
|
|---|
| 1874 | BOOL Win32BaseWindow::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1875 | {
|
|---|
| 1876 | return OSLibPostMessage(OS2Hwnd, WIN32APP_USERMSGBASE+msg, wParam, lParam);
|
|---|
| 1877 | }
|
|---|
| 1878 | //******************************************************************************
|
|---|
| 1879 | //TODO: do we need to inform the parent of the parent (etc) of the child window?
|
|---|
| 1880 | //******************************************************************************
|
|---|
| 1881 | void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 1882 | {
|
|---|
| 1883 | Win32BaseWindow *window = this;
|
|---|
| 1884 | Win32BaseWindow *parentwindow;
|
|---|
| 1885 |
|
|---|
| 1886 | while(window)
|
|---|
| 1887 | {
|
|---|
| 1888 | if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
|---|
| 1889 | {
|
|---|
| 1890 | /* Notify the parent window only */
|
|---|
| 1891 | parentwindow = window->getParent();
|
|---|
| 1892 | if(parentwindow) {
|
|---|
| 1893 | if(Msg == WM_CREATE || Msg == WM_DESTROY) {
|
|---|
| 1894 | parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
|
|---|
| 1895 | }
|
|---|
| 1896 | else parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
|
|---|
| 1897 | }
|
|---|
| 1898 | }
|
|---|
| 1899 | else break;
|
|---|
| 1900 |
|
|---|
| 1901 | window = parentwindow;
|
|---|
| 1902 | }
|
|---|
| 1903 | }
|
|---|
| 1904 | //******************************************************************************
|
|---|
| 1905 | //******************************************************************************
|
|---|
| 1906 | Win32BaseWindow *Win32BaseWindow::getTopParent()
|
|---|
| 1907 | {
|
|---|
| 1908 | Win32BaseWindow *tmpWnd = this;
|
|---|
| 1909 |
|
|---|
| 1910 | while( tmpWnd && (tmpWnd->getStyle() & WS_CHILD))
|
|---|
| 1911 | {
|
|---|
| 1912 | tmpWnd = tmpWnd->getParent();
|
|---|
| 1913 | }
|
|---|
| 1914 | return tmpWnd;
|
|---|
| 1915 | }
|
|---|
| 1916 | //******************************************************************************
|
|---|
| 1917 | //******************************************************************************
|
|---|
| 1918 | BOOL Win32BaseWindow::SetMenu(HMENU hMenu)
|
|---|
| 1919 | {
|
|---|
| 1920 |
|
|---|
| 1921 | dprintf(("SetMenu %x", hMenu));
|
|---|
| 1922 | OS2HwndMenu = OSLibWinSetMenu(OS2HwndFrame, hMenu);
|
|---|
| 1923 | if(OS2HwndMenu == 0) {
|
|---|
| 1924 | dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
|
|---|
| 1925 | return FALSE;
|
|---|
| 1926 | }
|
|---|
| 1927 | return TRUE;
|
|---|
| 1928 | }
|
|---|
| 1929 | //******************************************************************************
|
|---|
| 1930 | //******************************************************************************
|
|---|
| 1931 | BOOL Win32BaseWindow::SetAccelTable(HACCEL hAccel)
|
|---|
| 1932 | {
|
|---|
| 1933 | Win32Resource *winres = (Win32Resource *)hAccel;
|
|---|
| 1934 | HANDLE accelhandle;
|
|---|
| 1935 |
|
|---|
| 1936 | if(HIWORD(hAccel) == 0) {
|
|---|
| 1937 | dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
|
|---|
| 1938 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 1939 | return FALSE;
|
|---|
| 1940 | }
|
|---|
| 1941 | acceltableResource = winres;
|
|---|
| 1942 | accelhandle = OSLibWinSetAccelTable(OS2HwndFrame, winres->getOS2Handle(), winres->lockOS2Resource());
|
|---|
| 1943 | winres->setOS2Handle(accelhandle);
|
|---|
| 1944 | return(accelhandle != 0);
|
|---|
| 1945 | }
|
|---|
| 1946 | //******************************************************************************
|
|---|
| 1947 | //******************************************************************************
|
|---|
| 1948 | BOOL Win32BaseWindow::SetIcon(HICON hIcon)
|
|---|
| 1949 | {
|
|---|
| 1950 | dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
|
|---|
| 1951 | if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
|
|---|
| 1952 | SendMessageA(WM_SETICON, hIcon, 0);
|
|---|
| 1953 | return TRUE;
|
|---|
| 1954 | }
|
|---|
| 1955 | return FALSE;
|
|---|
| 1956 | }
|
|---|
| 1957 | //******************************************************************************
|
|---|
| 1958 | //******************************************************************************
|
|---|
| 1959 | BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
|
|---|
| 1960 | {
|
|---|
| 1961 | ULONG showstate = 0;
|
|---|
| 1962 |
|
|---|
| 1963 | dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
|
|---|
| 1964 | if(fFirstShow) {
|
|---|
| 1965 | if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) {
|
|---|
| 1966 | SendMessageA(WM_SIZE, SIZE_RESTORED,
|
|---|
| 1967 | MAKELONG(rectClient.right-rectClient.left,
|
|---|
| 1968 | rectClient.bottom-rectClient.top));
|
|---|
| 1969 | SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
|
|---|
| 1970 |
|
|---|
| 1971 | }
|
|---|
| 1972 | fFirstShow = FALSE;
|
|---|
| 1973 | }
|
|---|
| 1974 | switch(nCmdShow)
|
|---|
| 1975 | {
|
|---|
| 1976 | case SW_SHOW:
|
|---|
| 1977 | case SW_SHOWDEFAULT: //todo
|
|---|
| 1978 | showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
|
|---|
| 1979 | break;
|
|---|
| 1980 | case SW_HIDE:
|
|---|
| 1981 | showstate = SWPOS_HIDE;
|
|---|
| 1982 | break;
|
|---|
| 1983 | case SW_RESTORE:
|
|---|
| 1984 | showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
|
|---|
| 1985 | break;
|
|---|
| 1986 | case SW_MINIMIZE:
|
|---|
| 1987 | showstate = SWPOS_MINIMIZE;
|
|---|
| 1988 | break;
|
|---|
| 1989 | case SW_SHOWMAXIMIZED:
|
|---|
| 1990 | showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
|
|---|
| 1991 | break;
|
|---|
| 1992 | case SW_SHOWMINIMIZED:
|
|---|
| 1993 | showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
|
|---|
| 1994 | break;
|
|---|
| 1995 | case SW_SHOWMINNOACTIVE:
|
|---|
| 1996 | showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
|
|---|
| 1997 | break;
|
|---|
| 1998 | case SW_SHOWNA:
|
|---|
| 1999 | showstate = SWPOS_SHOW;
|
|---|
| 2000 | break;
|
|---|
| 2001 | case SW_SHOWNOACTIVATE:
|
|---|
| 2002 | showstate = SWPOS_SHOW;
|
|---|
| 2003 | break;
|
|---|
| 2004 | case SW_SHOWNORMAL:
|
|---|
| 2005 | showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
|
|---|
| 2006 | break;
|
|---|
| 2007 | }
|
|---|
| 2008 |
|
|---|
| 2009 | #if 0
|
|---|
| 2010 | if(showstate & SWPOS_SHOW && (getStyle() & WS_VISIBLE) == 0) {
|
|---|
| 2011 | SetWindowLongA(GWL_STYLE, getStyle() | WS_VISIBLE);
|
|---|
| 2012 | }
|
|---|
| 2013 | #endif
|
|---|
| 2014 | BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
|
|---|
| 2015 | return rc;
|
|---|
| 2016 | }
|
|---|
| 2017 | //******************************************************************************
|
|---|
| 2018 | //******************************************************************************
|
|---|
| 2019 | BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
|
|---|
| 2020 | {
|
|---|
| 2021 | BOOL rc = FALSE;
|
|---|
| 2022 | Win32BaseWindow *window;
|
|---|
| 2023 | HWND hParent = 0;
|
|---|
| 2024 |
|
|---|
| 2025 | dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
|
|---|
| 2026 |
|
|---|
| 2027 | if (fuFlags &
|
|---|
| 2028 | ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
|
|---|
| 2029 | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
|
|---|
| 2030 | SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
|
|---|
| 2031 | SWP_NOOWNERZORDER))
|
|---|
| 2032 | {
|
|---|
| 2033 | return FALSE;
|
|---|
| 2034 | }
|
|---|
| 2035 |
|
|---|
| 2036 | WINDOWPOS wpos;
|
|---|
| 2037 | SWP swp, swpOld;
|
|---|
| 2038 |
|
|---|
| 2039 | wpos.flags = fuFlags;
|
|---|
| 2040 | wpos.cy = cy;
|
|---|
| 2041 | wpos.cx = cx;
|
|---|
| 2042 | wpos.x = x;
|
|---|
| 2043 | wpos.y = y;
|
|---|
| 2044 | wpos.hwndInsertAfter = hwndInsertAfter;
|
|---|
| 2045 | wpos.hwnd = getWindowHandle();
|
|---|
| 2046 |
|
|---|
| 2047 | if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
|
|---|
| 2048 | {
|
|---|
| 2049 | if (isChild())
|
|---|
| 2050 | {
|
|---|
| 2051 | hParent = getParent()->getOS2WindowHandle();
|
|---|
| 2052 | }
|
|---|
| 2053 | OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
|
|---|
| 2054 | }
|
|---|
| 2055 |
|
|---|
| 2056 | OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
|
|---|
| 2057 | if (swp.fl == 0)
|
|---|
| 2058 | return TRUE;
|
|---|
| 2059 |
|
|---|
| 2060 | // if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
|
|---|
| 2061 | if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
|
|---|
| 2062 | {
|
|---|
| 2063 | Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
|
|---|
| 2064 | if(wndBehind) {
|
|---|
| 2065 | swp.hwndInsertBehind = wndBehind->getOS2WindowHandle();
|
|---|
| 2066 | }
|
|---|
| 2067 | else {
|
|---|
| 2068 | dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
|
|---|
| 2069 | swp.hwndInsertBehind = 0;
|
|---|
| 2070 | }
|
|---|
| 2071 | }
|
|---|
| 2072 | #if 0
|
|---|
| 2073 | if (isFrameWindow())
|
|---|
| 2074 | {
|
|---|
| 2075 | if (!isChild())
|
|---|
| 2076 | {
|
|---|
| 2077 | POINT maxSize, maxPos, minTrack, maxTrack;
|
|---|
| 2078 |
|
|---|
| 2079 | GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
|
|---|
| 2080 |
|
|---|
| 2081 | if (swp.cx > maxTrack.x) swp.cx = maxTrack.x;
|
|---|
| 2082 | if (swp.cy > maxTrack.y) swp.cy = maxTrack.y;
|
|---|
| 2083 | if (swp.cx < minTrack.x) swp.cx = minTrack.x;
|
|---|
| 2084 | if (swp.cy < minTrack.y) swp.cy = minTrack.y;
|
|---|
| 2085 | }
|
|---|
| 2086 | swp.hwnd = OS2HwndFrame;
|
|---|
| 2087 | }
|
|---|
| 2088 | else
|
|---|
| 2089 | #endif
|
|---|
| 2090 | swp.hwnd = OS2HwndFrame;
|
|---|
| 2091 |
|
|---|
| 2092 | dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
|
|---|
| 2093 |
|
|---|
| 2094 | rc = OSLibWinSetMultWindowPos(&swp, 1);
|
|---|
| 2095 |
|
|---|
| 2096 | if (rc == FALSE)
|
|---|
| 2097 | {
|
|---|
| 2098 | dprintf(("OSLibWinSetMultWindowPos failed!"));
|
|---|
| 2099 | }
|
|---|
| 2100 | else
|
|---|
| 2101 | {
|
|---|
| 2102 | if (fuFlags & SWP_FRAMECHANGED_W)
|
|---|
| 2103 | OSLibSendMessage (OS2HwndFrame, 0x42 /*WM_UPDATEFRAME*/, -1, 0);
|
|---|
| 2104 | }
|
|---|
| 2105 |
|
|---|
| 2106 | return (rc);
|
|---|
| 2107 | }
|
|---|
| 2108 | //******************************************************************************
|
|---|
| 2109 | //Also destroys all the child windows (destroy parent, destroy children)
|
|---|
| 2110 | //******************************************************************************
|
|---|
| 2111 | BOOL Win32BaseWindow::DestroyWindow()
|
|---|
| 2112 | {
|
|---|
| 2113 | return OSLibWinDestroyWindow(OS2HwndFrame);
|
|---|
| 2114 | }
|
|---|
| 2115 | //******************************************************************************
|
|---|
| 2116 | //******************************************************************************
|
|---|
| 2117 | HWND Win32BaseWindow::GetParent()
|
|---|
| 2118 | {
|
|---|
| 2119 | if(getParent()) {
|
|---|
| 2120 | return getParent()->getWindowHandle();
|
|---|
| 2121 | }
|
|---|
| 2122 | else return 0;
|
|---|
| 2123 | }
|
|---|
| 2124 | //******************************************************************************
|
|---|
| 2125 | //******************************************************************************
|
|---|
| 2126 | HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
|
|---|
| 2127 | {
|
|---|
| 2128 | HWND oldhwnd;
|
|---|
| 2129 | Win32BaseWindow *newparent;
|
|---|
| 2130 |
|
|---|
| 2131 | if(getParent()) {
|
|---|
| 2132 | oldhwnd = getParent()->getWindowHandle();
|
|---|
| 2133 | getParent()->RemoveChild(this);
|
|---|
| 2134 | }
|
|---|
| 2135 | else oldhwnd = 0;
|
|---|
| 2136 |
|
|---|
| 2137 | if(hwndNewParent == 0) {//desktop window = parent
|
|---|
| 2138 | setParent(NULL);
|
|---|
| 2139 | OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
|
|---|
| 2140 | return oldhwnd;
|
|---|
| 2141 | }
|
|---|
| 2142 | newparent = GetWindowFromHandle(hwndNewParent);
|
|---|
| 2143 | if(newparent)
|
|---|
| 2144 | {
|
|---|
| 2145 | setParent(newparent);
|
|---|
| 2146 | getParent()->AddChild(this);
|
|---|
| 2147 | OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
|
|---|
| 2148 | return oldhwnd;
|
|---|
| 2149 | }
|
|---|
| 2150 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2151 | return 0;
|
|---|
| 2152 | }
|
|---|
| 2153 | //******************************************************************************
|
|---|
| 2154 | //******************************************************************************
|
|---|
| 2155 | BOOL Win32BaseWindow::IsChild(HWND hwndParent)
|
|---|
| 2156 | {
|
|---|
| 2157 | if(getParent()) {
|
|---|
| 2158 | return getParent()->getWindowHandle() == hwndParent;
|
|---|
| 2159 | }
|
|---|
| 2160 | else return 0;
|
|---|
| 2161 | }
|
|---|
| 2162 | //******************************************************************************
|
|---|
| 2163 | //******************************************************************************
|
|---|
| 2164 | HWND Win32BaseWindow::GetTopWindow()
|
|---|
| 2165 | {
|
|---|
| 2166 | return GetWindow(GW_CHILD);
|
|---|
| 2167 | }
|
|---|
| 2168 | //******************************************************************************
|
|---|
| 2169 | // Get the top-level parent for a child window.
|
|---|
| 2170 | //******************************************************************************
|
|---|
| 2171 | Win32BaseWindow *Win32BaseWindow::GetTopParent()
|
|---|
| 2172 | {
|
|---|
| 2173 | Win32BaseWindow *window = this;
|
|---|
| 2174 |
|
|---|
| 2175 | while(window && (window->getStyle() & WS_CHILD))
|
|---|
| 2176 | {
|
|---|
| 2177 | window = window->getParent();
|
|---|
| 2178 | }
|
|---|
| 2179 | return window;
|
|---|
| 2180 | }
|
|---|
| 2181 | //******************************************************************************
|
|---|
| 2182 | //Don't call WinUpdateWindow as that one also updates the child windows
|
|---|
| 2183 | //Also need to send WM_PAINT directly to the window procedure, which doesn't
|
|---|
| 2184 | //always happen with WinUpdateWindow (could be posted if thread doesn't own window)
|
|---|
| 2185 | //******************************************************************************
|
|---|
| 2186 | BOOL Win32BaseWindow::UpdateWindow()
|
|---|
| 2187 | {
|
|---|
| 2188 | RECT rect;
|
|---|
| 2189 |
|
|---|
| 2190 | if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
|
|---|
| 2191 | {//update region not empty
|
|---|
| 2192 | HDC hdc;
|
|---|
| 2193 |
|
|---|
| 2194 | hdc = O32_GetDC(OS2Hwnd);
|
|---|
| 2195 | if (isIcon)
|
|---|
| 2196 | {
|
|---|
| 2197 | SendMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
|
|---|
| 2198 | SendMessageA(WM_PAINTICON, 0, 0);
|
|---|
| 2199 | } else
|
|---|
| 2200 | {
|
|---|
| 2201 | SendMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
|
|---|
| 2202 | SendMessageA(WM_PAINT, 0, 0);
|
|---|
| 2203 | }
|
|---|
| 2204 | O32_ReleaseDC(OS2Hwnd, hdc);
|
|---|
| 2205 | }
|
|---|
| 2206 | return TRUE;
|
|---|
| 2207 | }
|
|---|
| 2208 | //******************************************************************************
|
|---|
| 2209 | //******************************************************************************
|
|---|
| 2210 | BOOL Win32BaseWindow::IsIconic()
|
|---|
| 2211 | {
|
|---|
| 2212 | return OSLibWinIsIconic(OS2Hwnd);
|
|---|
| 2213 | }
|
|---|
| 2214 | //******************************************************************************
|
|---|
| 2215 | //TODO:
|
|---|
| 2216 | //We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
|
|---|
| 2217 | //the current process owns them.
|
|---|
| 2218 | //******************************************************************************
|
|---|
| 2219 | HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
|
|---|
| 2220 | BOOL fUnicode)
|
|---|
| 2221 | {
|
|---|
| 2222 | Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
|
|---|
| 2223 | Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
|
|---|
| 2224 |
|
|---|
| 2225 | if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
|
|---|
| 2226 | (hwndChildAfter != 0 && !child) ||
|
|---|
| 2227 | (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
|
|---|
| 2228 | {
|
|---|
| 2229 | dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
|
|---|
| 2230 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 2231 | return 0;
|
|---|
| 2232 | }
|
|---|
| 2233 | if(hwndParent != OSLIB_HWND_DESKTOP)
|
|---|
| 2234 | {//if the current process owns the window, just do a quick search
|
|---|
| 2235 | child = (Win32BaseWindow *)parent->getFirstChild();
|
|---|
| 2236 | if(hwndChildAfter != 0)
|
|---|
| 2237 | {
|
|---|
| 2238 | while(child)
|
|---|
| 2239 | {
|
|---|
| 2240 | if(child->getWindowHandle() == hwndChildAfter)
|
|---|
| 2241 | {
|
|---|
| 2242 | child = (Win32BaseWindow *)child->getNextChild();
|
|---|
| 2243 | break;
|
|---|
| 2244 | }
|
|---|
| 2245 | child = (Win32BaseWindow *)child->getNextChild();
|
|---|
| 2246 | }
|
|---|
| 2247 | }
|
|---|
| 2248 | while(child)
|
|---|
| 2249 | {
|
|---|
| 2250 | if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
|
|---|
| 2251 | (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
|
|---|
| 2252 | {
|
|---|
| 2253 | dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
|
|---|
| 2254 | return child->getWindowHandle();
|
|---|
| 2255 | }
|
|---|
| 2256 | child = (Win32BaseWindow *)child->getNextChild();
|
|---|
| 2257 | }
|
|---|
| 2258 | }
|
|---|
| 2259 | else {
|
|---|
| 2260 | Win32BaseWindow *wnd;
|
|---|
| 2261 | HWND henum, hwnd;
|
|---|
| 2262 |
|
|---|
| 2263 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
|
|---|
| 2264 | hwnd = OSLibWinGetNextWindow(henum);
|
|---|
| 2265 |
|
|---|
| 2266 | while(hwnd)
|
|---|
| 2267 | {
|
|---|
| 2268 | wnd = GetWindowFromOS2Handle(hwnd);
|
|---|
| 2269 | if(wnd == NULL) {
|
|---|
| 2270 | hwnd = OSLibWinQueryClientWindow(hwnd);
|
|---|
| 2271 | if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
|
|---|
| 2272 | }
|
|---|
| 2273 |
|
|---|
| 2274 | if(wnd) {
|
|---|
| 2275 | LPVOID sharedmembase = (LPVOID)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_SHAREDMEM);
|
|---|
| 2276 |
|
|---|
| 2277 | if(OSLibDosGetSharedMem(sharedmembase, MAX_HEAPSIZE, OSLIB_PAG_READ) != 0) {
|
|---|
| 2278 | dprintf(("OSLibDosGetSharedMem returned error for %x", wnd));
|
|---|
| 2279 | break;
|
|---|
| 2280 | }
|
|---|
| 2281 | if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
|
|---|
| 2282 | (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
|
|---|
| 2283 | {
|
|---|
| 2284 | OSLibWinEndEnumWindows(henum);
|
|---|
| 2285 | dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
|
|---|
| 2286 | return wnd->getWindowHandle();
|
|---|
| 2287 | }
|
|---|
| 2288 | }
|
|---|
| 2289 | hwnd = OSLibWinGetNextWindow(henum);
|
|---|
| 2290 | }
|
|---|
| 2291 | OSLibWinEndEnumWindows(henum);
|
|---|
| 2292 | }
|
|---|
| 2293 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
|
|---|
| 2294 | return 0;
|
|---|
| 2295 | }
|
|---|
| 2296 | //******************************************************************************
|
|---|
| 2297 | //TODO: not complete nor correct (distinction be tween top-level, top-most & child windows)
|
|---|
| 2298 | //******************************************************************************
|
|---|
| 2299 | HWND Win32BaseWindow::GetWindow(UINT uCmd)
|
|---|
| 2300 | {
|
|---|
| 2301 | Win32BaseWindow *win32wnd;
|
|---|
| 2302 | ULONG magic;
|
|---|
| 2303 | ULONG getcmd = 0;
|
|---|
| 2304 | HWND hwndRelated, hwnd;
|
|---|
| 2305 |
|
|---|
| 2306 | dprintf(("GetWindow %x %d NOT COMPLETE", getWindowHandle(), uCmd));
|
|---|
| 2307 | hwnd = OS2Hwnd;
|
|---|
| 2308 | switch(uCmd)
|
|---|
| 2309 | {
|
|---|
| 2310 | case GW_CHILD:
|
|---|
| 2311 | getcmd = QWOS_TOP;
|
|---|
| 2312 | break;
|
|---|
| 2313 | case GW_HWNDFIRST:
|
|---|
| 2314 | if(getParent()) {
|
|---|
| 2315 | hwnd = getParent()->getOS2WindowHandle();
|
|---|
| 2316 | getcmd = QWOS_TOP; //top of child windows
|
|---|
| 2317 | }
|
|---|
| 2318 | else getcmd = QWOS_TOP; //TODO
|
|---|
| 2319 | break;
|
|---|
| 2320 | case GW_HWNDLAST:
|
|---|
| 2321 | if(getParent()) {
|
|---|
| 2322 | hwnd = getParent()->getOS2WindowHandle();
|
|---|
| 2323 | getcmd = QWOS_BOTTOM; //bottom of child windows
|
|---|
| 2324 | }
|
|---|
| 2325 | else getcmd = QWOS_BOTTOM; //TODO
|
|---|
| 2326 | break;
|
|---|
| 2327 | case GW_HWNDNEXT:
|
|---|
| 2328 | getcmd = QWOS_NEXT;
|
|---|
| 2329 | break;
|
|---|
| 2330 | case GW_HWNDPREV:
|
|---|
| 2331 | getcmd = QWOS_PREV;
|
|---|
| 2332 | break;
|
|---|
| 2333 | case GW_OWNER:
|
|---|
| 2334 | if(owner) {
|
|---|
| 2335 | return owner->getWindowHandle();
|
|---|
| 2336 | }
|
|---|
| 2337 | else return 0;
|
|---|
| 2338 | }
|
|---|
| 2339 | hwndRelated = OSLibWinQueryWindow(hwnd, getcmd);
|
|---|
| 2340 | if(hwndRelated)
|
|---|
| 2341 | {
|
|---|
| 2342 | win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
|
|---|
| 2343 | magic = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
|
|---|
| 2344 | if(CheckMagicDword(magic) && win32wnd)
|
|---|
| 2345 | {
|
|---|
| 2346 | return win32wnd->getWindowHandle();
|
|---|
| 2347 | }
|
|---|
| 2348 |
|
|---|
| 2349 | hwndRelated = OSLibWinWindowFromID(hwndRelated, OSLIB_FID_CLIENT);
|
|---|
| 2350 | win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
|
|---|
| 2351 | magic = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
|
|---|
| 2352 | if(CheckMagicDword(magic) && win32wnd)
|
|---|
| 2353 | {
|
|---|
| 2354 | return win32wnd->getWindowHandle();
|
|---|
| 2355 | }
|
|---|
| 2356 | }
|
|---|
| 2357 | return 0;
|
|---|
| 2358 | }
|
|---|
| 2359 | //******************************************************************************
|
|---|
| 2360 | //******************************************************************************
|
|---|
| 2361 | HWND Win32BaseWindow::SetActiveWindow()
|
|---|
| 2362 | {
|
|---|
| 2363 | return OSLibWinSetActiveWindow(OS2Hwnd);
|
|---|
| 2364 | }
|
|---|
| 2365 | //******************************************************************************
|
|---|
| 2366 | //WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
|
|---|
| 2367 | //******************************************************************************
|
|---|
| 2368 | BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
|
|---|
| 2369 | {
|
|---|
| 2370 | return OSLibWinEnableWindow(OS2Hwnd, fEnable);
|
|---|
| 2371 | }
|
|---|
| 2372 | //******************************************************************************
|
|---|
| 2373 | //******************************************************************************
|
|---|
| 2374 | BOOL Win32BaseWindow::CloseWindow()
|
|---|
| 2375 | {
|
|---|
| 2376 | return OSLibWinMinimizeWindow(OS2Hwnd);
|
|---|
| 2377 | }
|
|---|
| 2378 | //******************************************************************************
|
|---|
| 2379 | //******************************************************************************
|
|---|
| 2380 | HWND Win32BaseWindow::GetActiveWindow()
|
|---|
| 2381 | {
|
|---|
| 2382 | HWND hwndActive;
|
|---|
| 2383 | Win32BaseWindow *win32wnd;
|
|---|
| 2384 | ULONG magic;
|
|---|
| 2385 |
|
|---|
| 2386 | hwndActive = OSLibWinQueryActiveWindow();
|
|---|
| 2387 |
|
|---|
| 2388 | win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
|
|---|
| 2389 | magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
|
|---|
| 2390 | if(CheckMagicDword(magic) && win32wnd)
|
|---|
| 2391 | {
|
|---|
| 2392 | return win32wnd->getWindowHandle();
|
|---|
| 2393 | }
|
|---|
| 2394 | return hwndActive;
|
|---|
| 2395 | }
|
|---|
| 2396 | //******************************************************************************
|
|---|
| 2397 | //******************************************************************************
|
|---|
| 2398 | BOOL Win32BaseWindow::IsWindowEnabled()
|
|---|
| 2399 | {
|
|---|
| 2400 | return OSLibWinIsWindowEnabled(OS2Hwnd);
|
|---|
| 2401 | }
|
|---|
| 2402 | //******************************************************************************
|
|---|
| 2403 | //******************************************************************************
|
|---|
| 2404 | BOOL Win32BaseWindow::IsWindowVisible()
|
|---|
| 2405 | {
|
|---|
| 2406 | return OSLibWinIsWindowVisible(OS2Hwnd);
|
|---|
| 2407 | }
|
|---|
| 2408 | //******************************************************************************
|
|---|
| 2409 | //******************************************************************************
|
|---|
| 2410 | BOOL Win32BaseWindow::GetWindowRect(PRECT pRect)
|
|---|
| 2411 | {
|
|---|
| 2412 | return OSLibWinQueryWindowRect(OS2HwndFrame, pRect, RELATIVE_TO_SCREEN);
|
|---|
| 2413 | }
|
|---|
| 2414 | //******************************************************************************
|
|---|
| 2415 | //******************************************************************************
|
|---|
| 2416 | BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
|
|---|
| 2417 | {
|
|---|
| 2418 | if(fUnicode) {
|
|---|
| 2419 | return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0);
|
|---|
| 2420 | }
|
|---|
| 2421 | else return (strcmp(windowNameA, wndname) == 0);
|
|---|
| 2422 | }
|
|---|
| 2423 | //******************************************************************************
|
|---|
| 2424 | //******************************************************************************
|
|---|
| 2425 | int Win32BaseWindow::GetWindowTextLength()
|
|---|
| 2426 | {
|
|---|
| 2427 | return wndNameLength;
|
|---|
| 2428 | }
|
|---|
| 2429 | //******************************************************************************
|
|---|
| 2430 | //******************************************************************************
|
|---|
| 2431 | int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
|
|---|
| 2432 | {
|
|---|
| 2433 | strncpy(lpsz, windowNameA, cch);
|
|---|
| 2434 | return wndNameLength;
|
|---|
| 2435 | }
|
|---|
| 2436 | //******************************************************************************
|
|---|
| 2437 | //******************************************************************************
|
|---|
| 2438 | int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
|
|---|
| 2439 | {
|
|---|
| 2440 | lstrcpynW((LPWSTR)lpsz, windowNameW, cch);
|
|---|
| 2441 | return wndNameLength;
|
|---|
| 2442 | }
|
|---|
| 2443 | //******************************************************************************
|
|---|
| 2444 | //******************************************************************************
|
|---|
| 2445 | BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
|
|---|
| 2446 | {
|
|---|
| 2447 | if(lpsz == NULL)
|
|---|
| 2448 | return FALSE;
|
|---|
| 2449 |
|
|---|
| 2450 | if(windowNameA) free(windowNameA);
|
|---|
| 2451 | if(windowNameW) free(windowNameW);
|
|---|
| 2452 |
|
|---|
| 2453 | windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
|
|---|
| 2454 | strcpy(windowNameA, lpsz);
|
|---|
| 2455 | windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
|
|---|
| 2456 | lstrcpyAtoW(windowNameW, windowNameA);
|
|---|
| 2457 | wndNameLength = strlen(windowNameA)+1; //including 0 terminator
|
|---|
| 2458 |
|
|---|
| 2459 | if(OS2HwndFrame)
|
|---|
| 2460 | return OSLibWinSetWindowText(OS2HwndFrame, (LPSTR)windowNameA);
|
|---|
| 2461 |
|
|---|
| 2462 | return TRUE;
|
|---|
| 2463 | }
|
|---|
| 2464 | //******************************************************************************
|
|---|
| 2465 | //******************************************************************************
|
|---|
| 2466 | BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
|
|---|
| 2467 | {
|
|---|
| 2468 | if(lpsz == NULL)
|
|---|
| 2469 | return FALSE;
|
|---|
| 2470 |
|
|---|
| 2471 | if(windowNameA) free(windowNameA);
|
|---|
| 2472 | if(windowNameW) free(windowNameW);
|
|---|
| 2473 |
|
|---|
| 2474 | windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR));
|
|---|
| 2475 | lstrcpyW(windowNameW, (LPWSTR)lpsz);
|
|---|
| 2476 | windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1);
|
|---|
| 2477 | lstrcpyWtoA(windowNameA, windowNameW);
|
|---|
| 2478 | wndNameLength = strlen(windowNameA)+1; //including 0 terminator
|
|---|
| 2479 |
|
|---|
| 2480 | if(OS2HwndFrame)
|
|---|
| 2481 | return OSLibWinSetWindowText(OS2HwndFrame, (LPSTR)windowNameA);
|
|---|
| 2482 |
|
|---|
| 2483 | return TRUE;
|
|---|
| 2484 | }
|
|---|
| 2485 | //******************************************************************************
|
|---|
| 2486 | //******************************************************************************
|
|---|
| 2487 | LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value)
|
|---|
| 2488 | {
|
|---|
| 2489 | LONG oldval;
|
|---|
| 2490 |
|
|---|
| 2491 | switch(index) {
|
|---|
| 2492 | case GWL_EXSTYLE:
|
|---|
| 2493 | {
|
|---|
| 2494 | STYLESTRUCT ss;
|
|---|
| 2495 |
|
|---|
| 2496 | ss.styleOld = dwExStyle;
|
|---|
| 2497 | ss.styleNew = value;
|
|---|
| 2498 | SendMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
|
|---|
| 2499 | setExStyle(ss.styleNew);
|
|---|
| 2500 | SendMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
|
|---|
| 2501 | return ss.styleOld;
|
|---|
| 2502 | }
|
|---|
| 2503 | case GWL_STYLE:
|
|---|
| 2504 | {
|
|---|
| 2505 | STYLESTRUCT ss;
|
|---|
| 2506 |
|
|---|
| 2507 | ss.styleOld = dwStyle;
|
|---|
| 2508 | ss.styleNew = value;
|
|---|
| 2509 | SendMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
|
|---|
| 2510 | setStyle(ss.styleNew);
|
|---|
| 2511 | OSLibSetWindowStyle(OS2HwndFrame, dwStyle);
|
|---|
| 2512 | SendMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
|
|---|
| 2513 | return ss.styleOld;
|
|---|
| 2514 | }
|
|---|
| 2515 | case GWL_WNDPROC:
|
|---|
| 2516 | oldval = (LONG)getWindowProc();
|
|---|
| 2517 | setWindowProc((WNDPROC)value);
|
|---|
| 2518 | return oldval;
|
|---|
| 2519 | case GWL_HINSTANCE:
|
|---|
| 2520 | oldval = hInstance;
|
|---|
| 2521 | hInstance = value;
|
|---|
| 2522 | return oldval;
|
|---|
| 2523 | case GWL_HWNDPARENT:
|
|---|
| 2524 | return SetParent((HWND)value);
|
|---|
| 2525 | case GWL_ID:
|
|---|
| 2526 | oldval = getWindowId();
|
|---|
| 2527 | setWindowId(value);
|
|---|
| 2528 | return oldval;
|
|---|
| 2529 | case GWL_USERDATA:
|
|---|
| 2530 | oldval = userData;
|
|---|
| 2531 | userData = value;
|
|---|
| 2532 | return oldval;
|
|---|
| 2533 | default:
|
|---|
| 2534 | if(index >= 0 && index/4 < nrUserWindowLong)
|
|---|
| 2535 | {
|
|---|
| 2536 | oldval = userWindowLong[index/4];
|
|---|
| 2537 | userWindowLong[index/4] = value;
|
|---|
| 2538 | return oldval;
|
|---|
| 2539 | }
|
|---|
| 2540 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2541 | return 0;
|
|---|
| 2542 | }
|
|---|
| 2543 | }
|
|---|
| 2544 | //******************************************************************************
|
|---|
| 2545 | //******************************************************************************
|
|---|
| 2546 | ULONG Win32BaseWindow::GetWindowLongA(int index)
|
|---|
| 2547 | {
|
|---|
| 2548 | switch(index) {
|
|---|
| 2549 | case GWL_EXSTYLE:
|
|---|
| 2550 | return dwExStyle;
|
|---|
| 2551 | case GWL_STYLE:
|
|---|
| 2552 | return dwStyle;
|
|---|
| 2553 | case GWL_WNDPROC:
|
|---|
| 2554 | return (ULONG)getWindowProc();
|
|---|
| 2555 | case GWL_HINSTANCE:
|
|---|
| 2556 | return hInstance;
|
|---|
| 2557 | case GWL_HWNDPARENT:
|
|---|
| 2558 | if(getParent()) {
|
|---|
| 2559 | return getParent()->getWindowHandle();
|
|---|
| 2560 | }
|
|---|
| 2561 | else return 0;
|
|---|
| 2562 | case GWL_ID:
|
|---|
| 2563 | return getWindowId();
|
|---|
| 2564 | case GWL_USERDATA:
|
|---|
| 2565 | return userData;
|
|---|
| 2566 | default:
|
|---|
| 2567 | if(index >= 0 && index/4 < nrUserWindowLong)
|
|---|
| 2568 | {
|
|---|
| 2569 | return userWindowLong[index/4];
|
|---|
| 2570 | }
|
|---|
| 2571 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2572 | return 0;
|
|---|
| 2573 | }
|
|---|
| 2574 | }
|
|---|
| 2575 | //******************************************************************************
|
|---|
| 2576 | //******************************************************************************
|
|---|
| 2577 | WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
|
|---|
| 2578 | {
|
|---|
| 2579 | WORD oldval;
|
|---|
| 2580 |
|
|---|
| 2581 | if(index >= 0 && index/4 < nrUserWindowLong)
|
|---|
| 2582 | {
|
|---|
| 2583 | oldval = ((WORD *)userWindowLong)[index/2];
|
|---|
| 2584 | ((WORD *)userWindowLong)[index/2] = value;
|
|---|
| 2585 | return oldval;
|
|---|
| 2586 | }
|
|---|
| 2587 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2588 | return 0;
|
|---|
| 2589 | }
|
|---|
| 2590 | //******************************************************************************
|
|---|
| 2591 | //******************************************************************************
|
|---|
| 2592 | WORD Win32BaseWindow::GetWindowWord(int index)
|
|---|
| 2593 | {
|
|---|
| 2594 | if(index >= 0 && index/4 < nrUserWindowLong)
|
|---|
| 2595 | {
|
|---|
| 2596 | return ((WORD *)userWindowLong)[index/2];
|
|---|
| 2597 | }
|
|---|
| 2598 | SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 2599 | return 0;
|
|---|
| 2600 | }
|
|---|
| 2601 | //******************************************************************************
|
|---|
| 2602 | //******************************************************************************
|
|---|
| 2603 | void Win32BaseWindow::setWindowId(DWORD id)
|
|---|
| 2604 | {
|
|---|
| 2605 | windowId = id;
|
|---|
| 2606 | OSLibSetWindowID(OS2HwndFrame, id);
|
|---|
| 2607 | }
|
|---|
| 2608 | //******************************************************************************
|
|---|
| 2609 | //******************************************************************************
|
|---|
| 2610 | Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
|
|---|
| 2611 | {
|
|---|
| 2612 | Win32BaseWindow *window;
|
|---|
| 2613 |
|
|---|
| 2614 | if(hwnd == NULL && windowDesktop)
|
|---|
| 2615 | return windowDesktop;
|
|---|
| 2616 |
|
|---|
| 2617 | if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
|
|---|
| 2618 | return window;
|
|---|
| 2619 | }
|
|---|
| 2620 | else return NULL;
|
|---|
| 2621 | }
|
|---|
| 2622 | //******************************************************************************
|
|---|
| 2623 | //******************************************************************************
|
|---|
| 2624 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
|
|---|
| 2625 | {
|
|---|
| 2626 | Win32BaseWindow *win32wnd;
|
|---|
| 2627 | DWORD magic;
|
|---|
| 2628 |
|
|---|
| 2629 | win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
|
|---|
| 2630 | magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
|
|---|
| 2631 |
|
|---|
| 2632 | if(win32wnd && CheckMagicDword(magic)) {
|
|---|
| 2633 | return win32wnd;
|
|---|
| 2634 | }
|
|---|
| 2635 | return 0;
|
|---|
| 2636 | }
|
|---|
| 2637 | //******************************************************************************
|
|---|
| 2638 | //******************************************************************************
|
|---|
| 2639 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
|
|---|
| 2640 | {
|
|---|
| 2641 | return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
|
|---|
| 2642 | }
|
|---|
| 2643 | //******************************************************************************
|
|---|
| 2644 | //******************************************************************************
|
|---|
| 2645 | HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
|
|---|
| 2646 | {
|
|---|
| 2647 | Win32BaseWindow *window = GetWindowFromHandle(hwnd);
|
|---|
| 2648 |
|
|---|
| 2649 | if(window) {
|
|---|
| 2650 | return window->getOS2WindowHandle();
|
|---|
| 2651 | }
|
|---|
| 2652 | else return hwnd;
|
|---|
| 2653 | }
|
|---|
| 2654 | //******************************************************************************
|
|---|
| 2655 | //******************************************************************************
|
|---|
| 2656 | HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
|
|---|
| 2657 | {
|
|---|
| 2658 | Win32BaseWindow *window = GetWindowFromHandle(hwnd);
|
|---|
| 2659 |
|
|---|
| 2660 | if(window) {
|
|---|
| 2661 | return window->getOS2FrameWindowHandle();
|
|---|
| 2662 | }
|
|---|
| 2663 | else return hwnd;
|
|---|
| 2664 | }
|
|---|
| 2665 | //******************************************************************************
|
|---|
| 2666 | //******************************************************************************
|
|---|
| 2667 | HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
|
|---|
| 2668 | {
|
|---|
| 2669 | Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
|
|---|
| 2670 |
|
|---|
| 2671 | if(window) {
|
|---|
| 2672 | return window->getWindowHandle();
|
|---|
| 2673 | }
|
|---|
| 2674 | window = GetWindowFromOS2FrameHandle(hwnd);
|
|---|
| 2675 | if(window) {
|
|---|
| 2676 | return window->getWindowHandle();
|
|---|
| 2677 | }
|
|---|
| 2678 | else return hwnd; //OS/2 window handle
|
|---|
| 2679 | }
|
|---|
| 2680 | //******************************************************************************
|
|---|
| 2681 | //******************************************************************************
|
|---|
| 2682 | #ifdef DEBUG
|
|---|
| 2683 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
|
|---|
| 2684 | {
|
|---|
| 2685 | char style[256] = "";
|
|---|
| 2686 | char exstyle[256] = "";
|
|---|
| 2687 |
|
|---|
| 2688 | /* Window styles */
|
|---|
| 2689 | if(dwStyle & WS_CHILD)
|
|---|
| 2690 | strcat(style, "WS_CHILD ");
|
|---|
| 2691 | if(dwStyle & WS_POPUP)
|
|---|
| 2692 | strcat(style, "WS_POPUP ");
|
|---|
| 2693 | if(dwStyle & WS_VISIBLE)
|
|---|
| 2694 | strcat(style, "WS_VISIBLE ");
|
|---|
| 2695 | if(dwStyle & WS_DISABLED)
|
|---|
| 2696 | strcat(style, "WS_DISABLED ");
|
|---|
| 2697 | if(dwStyle & WS_CLIPSIBLINGS)
|
|---|
| 2698 | strcat(style, "WS_CLIPSIBLINGS ");
|
|---|
| 2699 | if(dwStyle & WS_CLIPCHILDREN)
|
|---|
| 2700 | strcat(style, "WS_CLIPCHILDREN ");
|
|---|
| 2701 | if(dwStyle & WS_MAXIMIZE)
|
|---|
| 2702 | strcat(style, "WS_MAXIMIZE ");
|
|---|
| 2703 | if(dwStyle & WS_MINIMIZE)
|
|---|
| 2704 | strcat(style, "WS_MINIMIZE ");
|
|---|
| 2705 | if(dwStyle & WS_GROUP)
|
|---|
| 2706 | strcat(style, "WS_GROUP ");
|
|---|
| 2707 | if(dwStyle & WS_TABSTOP)
|
|---|
| 2708 | strcat(style, "WS_TABSTOP ");
|
|---|
| 2709 |
|
|---|
| 2710 | if((dwStyle & WS_CAPTION) == WS_CAPTION)
|
|---|
| 2711 | strcat(style, "WS_CAPTION ");
|
|---|
| 2712 | if(dwStyle & WS_DLGFRAME)
|
|---|
| 2713 | strcat(style, "WS_DLGFRAME ");
|
|---|
| 2714 | if(dwStyle & WS_BORDER)
|
|---|
| 2715 | strcat(style, "WS_BORDER ");
|
|---|
| 2716 |
|
|---|
| 2717 | if(dwStyle & WS_VSCROLL)
|
|---|
| 2718 | strcat(style, "WS_VSCROLL ");
|
|---|
| 2719 | if(dwStyle & WS_HSCROLL)
|
|---|
| 2720 | strcat(style, "WS_HSCROLL ");
|
|---|
| 2721 | if(dwStyle & WS_SYSMENU)
|
|---|
| 2722 | strcat(style, "WS_SYSMENU ");
|
|---|
| 2723 | if(dwStyle & WS_THICKFRAME)
|
|---|
| 2724 | strcat(style, "WS_THICKFRAME ");
|
|---|
| 2725 | if(dwStyle & WS_MINIMIZEBOX)
|
|---|
| 2726 | strcat(style, "WS_MINIMIZEBOX ");
|
|---|
| 2727 | if(dwStyle & WS_MAXIMIZEBOX)
|
|---|
| 2728 | strcat(style, "WS_MAXIMIZEBOX ");
|
|---|
| 2729 |
|
|---|
| 2730 | if(dwExStyle & WS_EX_DLGMODALFRAME)
|
|---|
| 2731 | strcat(exstyle, "WS_EX_DLGMODALFRAME ");
|
|---|
| 2732 | if(dwExStyle & WS_EX_ACCEPTFILES)
|
|---|
| 2733 | strcat(exstyle, "WS_EX_ACCEPTFILES ");
|
|---|
| 2734 | if(dwExStyle & WS_EX_NOPARENTNOTIFY)
|
|---|
| 2735 | strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
|
|---|
| 2736 | if(dwExStyle & WS_EX_TOPMOST)
|
|---|
| 2737 | strcat(exstyle, "WS_EX_TOPMOST ");
|
|---|
| 2738 | if(dwExStyle & WS_EX_TRANSPARENT)
|
|---|
| 2739 | strcat(exstyle, "WS_EX_TRANSPARENT ");
|
|---|
| 2740 |
|
|---|
| 2741 | if(dwExStyle & WS_EX_MDICHILD)
|
|---|
| 2742 | strcat(exstyle, "WS_EX_MDICHILD ");
|
|---|
| 2743 | if(dwExStyle & WS_EX_TOOLWINDOW)
|
|---|
| 2744 | strcat(exstyle, "WS_EX_TOOLWINDOW ");
|
|---|
| 2745 | if(dwExStyle & WS_EX_WINDOWEDGE)
|
|---|
| 2746 | strcat(exstyle, "WS_EX_WINDOWEDGE ");
|
|---|
| 2747 | if(dwExStyle & WS_EX_CLIENTEDGE)
|
|---|
| 2748 | strcat(exstyle, "WS_EX_CLIENTEDGE ");
|
|---|
| 2749 | if(dwExStyle & WS_EX_CONTEXTHELP)
|
|---|
| 2750 | strcat(exstyle, "WS_EX_CONTEXTHELP ");
|
|---|
| 2751 | if(dwExStyle & WS_EX_RIGHT)
|
|---|
| 2752 | strcat(exstyle, "WS_EX_RIGHT ");
|
|---|
| 2753 | if(dwExStyle & WS_EX_LEFT)
|
|---|
| 2754 | strcat(exstyle, "WS_EX_LEFT ");
|
|---|
| 2755 | if(dwExStyle & WS_EX_RTLREADING)
|
|---|
| 2756 | strcat(exstyle, "WS_EX_RTLREADING ");
|
|---|
| 2757 | if(dwExStyle & WS_EX_LTRREADING)
|
|---|
| 2758 | strcat(exstyle, "WS_EX_LTRREADING ");
|
|---|
| 2759 | if(dwExStyle & WS_EX_LEFTSCROLLBAR)
|
|---|
| 2760 | strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
|
|---|
| 2761 | if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
|
|---|
| 2762 | strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
|
|---|
| 2763 | if(dwExStyle & WS_EX_CONTROLPARENT)
|
|---|
| 2764 | strcat(exstyle, "WS_EX_CONTROLPARENT ");
|
|---|
| 2765 | if(dwExStyle & WS_EX_STATICEDGE)
|
|---|
| 2766 | strcat(exstyle, "WS_EX_STATICEDGE ");
|
|---|
| 2767 | if(dwExStyle & WS_EX_APPWINDOW)
|
|---|
| 2768 | strcat(exstyle, "WS_EX_APPWINDOW ");
|
|---|
| 2769 |
|
|---|
| 2770 | dprintf(("Window style: %x %s", dwStyle, style));
|
|---|
| 2771 | dprintf(("Window exStyle: %x %s", dwExStyle, exstyle));
|
|---|
| 2772 | }
|
|---|
| 2773 | #endif
|
|---|
| 2774 | //******************************************************************************
|
|---|
| 2775 | //******************************************************************************
|
|---|
| 2776 |
|
|---|
| 2777 | GenericObject *Win32BaseWindow::windows = NULL;
|
|---|