| 1 | /* $Id: pmwindow.cpp,v 1.225 2003-11-15 12:28:47 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 Window Managment Code for OS/2
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 | #define INCL_WIN
|
|---|
| 13 | #define INCL_GPI
|
|---|
| 14 | #define INCL_DEV /* Device Function definitions */
|
|---|
| 15 | #define INCL_GPICONTROL /* GPI control Functions */
|
|---|
| 16 | #define INCL_DOSPROCESS
|
|---|
| 17 | #define INCL_DOSMODULEMGR
|
|---|
| 18 | #define INCL_DOSDEVICES
|
|---|
| 19 | #define INCL_DOSDEVIOCTL
|
|---|
| 20 | #define INCL_WINTRACKRECT
|
|---|
| 21 | #define INCL_BASE
|
|---|
| 22 |
|
|---|
| 23 | #include <os2wrap.h>
|
|---|
| 24 | #include <odinwrap.h>
|
|---|
| 25 | #include <stdlib.h>
|
|---|
| 26 | #include <string.h>
|
|---|
| 27 | #include <win32type.h>
|
|---|
| 28 | #include <win32api.h>
|
|---|
| 29 | #include <winconst.h>
|
|---|
| 30 | #include <winuser32.h>
|
|---|
| 31 | #include <wprocess.h>
|
|---|
| 32 | #include <dbglog.h>
|
|---|
| 33 | #include <win32wbase.h>
|
|---|
| 34 | #include <win32wfake.h>
|
|---|
| 35 | #include <win32dlg.h>
|
|---|
| 36 | #include "win32wdesktop.h"
|
|---|
| 37 | #include "pmwindow.h"
|
|---|
| 38 | #include "oslibwin.h"
|
|---|
| 39 | #include "oslibutil.h"
|
|---|
| 40 | #include "oslibgdi.h"
|
|---|
| 41 | #include "oslibmsg.h"
|
|---|
| 42 | #define INCLUDED_BY_DC
|
|---|
| 43 | #include "dc.h"
|
|---|
| 44 | #include <thread.h>
|
|---|
| 45 | #include <wprocess.h>
|
|---|
| 46 | #include "caret.h"
|
|---|
| 47 | #include "timer.h"
|
|---|
| 48 | #include <codepage.h>
|
|---|
| 49 | #include "syscolor.h"
|
|---|
| 50 | #include "options.h"
|
|---|
| 51 | #include "menu.h"
|
|---|
| 52 | #include <pmkbdhk.h>
|
|---|
| 53 | #include <pmscan.h>
|
|---|
| 54 | #include <winscan.h>
|
|---|
| 55 | #include <oslibdnd.h>
|
|---|
| 56 | #include <custombuild.h>
|
|---|
| 57 | #include <win\dbt.h>
|
|---|
| 58 | #include "dragdrop.h"
|
|---|
| 59 | #include "menu.h"
|
|---|
| 60 | #include "user32api.h"
|
|---|
| 61 | #include <kbdhook.h>
|
|---|
| 62 |
|
|---|
| 63 | #define DBG_LOCALLOG DBG_pmwindow
|
|---|
| 64 | #include "dbglocal.h"
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 | #define ODIN_SetExceptionHandler(a)
|
|---|
| 68 | #define ODIN_UnsetExceptionHandler(a)
|
|---|
| 69 | #define hookInit(a)
|
|---|
| 70 |
|
|---|
| 71 | // Notification that focus change has completed (UNDOCUMENTED)
|
|---|
| 72 | #define WM_FOCUSCHANGED 0x000e
|
|---|
| 73 |
|
|---|
| 74 | //define this to use the new code for WM_CALCVALIDRECT handling
|
|---|
| 75 | //#define USE_CALCVALIDRECT
|
|---|
| 76 |
|
|---|
| 77 | HMQ hmq = 0; /* Message queue handle */
|
|---|
| 78 | HAB hab = 0;
|
|---|
| 79 | RECTL desktopRectl = {0};
|
|---|
| 80 | ULONG ScreenWidth = 0;
|
|---|
| 81 | ULONG ScreenHeight = 0;
|
|---|
| 82 | ULONG ScreenBitsPerPel = 0;
|
|---|
| 83 | BOOL fOS2Look = FALSE;
|
|---|
| 84 | BOOL fForceMonoCursor = FALSE;
|
|---|
| 85 | BOOL fDragDropActive = FALSE;
|
|---|
| 86 | BOOL fDragDropDisabled = FALSE;
|
|---|
| 87 |
|
|---|
| 88 | const char WIN32_CDCLASS[] = ODIN_WIN32_CDCLASS;
|
|---|
| 89 | char WIN32_STDCLASS[255] = ODIN_WIN32_STDCLASS;
|
|---|
| 90 |
|
|---|
| 91 | #define PMMENU_MINBUTTON 0
|
|---|
| 92 | #define PMMENU_MAXBUTTON 1
|
|---|
| 93 | #define PMMENU_RESTOREBUTTON 2
|
|---|
| 94 | #define PMMENU_CLOSEBUTTON 3
|
|---|
| 95 | #define PMMENU_MINBUTTONDOWN 4
|
|---|
| 96 | #define PMMENU_MAXBUTTONDOWN 5
|
|---|
| 97 | #define PMMENU_RESTOREBUTTONDOWN 6
|
|---|
| 98 | #define PMMENU_CLOSEBUTTONDOWN 7
|
|---|
| 99 |
|
|---|
| 100 | HBITMAP hbmFrameMenu[8] = {0};
|
|---|
| 101 |
|
|---|
| 102 | //Win32 bitmap handles of the OS/2 min, max and restore buttons
|
|---|
| 103 | HBITMAP hBmpMinButton = 0;
|
|---|
| 104 | HBITMAP hBmpMaxButton = 0;
|
|---|
| 105 | HBITMAP hBmpRestoreButton = 0;
|
|---|
| 106 | HBITMAP hBmpCloseButton = 0;
|
|---|
| 107 | HBITMAP hBmpMinButtonDown = 0;
|
|---|
| 108 | HBITMAP hBmpMaxButtonDown = 0;
|
|---|
| 109 | HBITMAP hBmpRestoreButtonDown = 0;
|
|---|
| 110 | HBITMAP hBmpCloseButtonDown = 0;
|
|---|
| 111 |
|
|---|
| 112 | PFNWP pfnFrameWndProc = NULL;
|
|---|
| 113 | static HWND hwndFocusChange = 0;
|
|---|
| 114 | HWND hwndCD = 0;
|
|---|
| 115 |
|
|---|
| 116 | // this holds the font height that the display driver returns using DevQueryCaps
|
|---|
| 117 | // 13 would be small fonts, 16 medium fonts and 20 large fonts
|
|---|
| 118 | LONG CapsCharHeight = 0;
|
|---|
| 119 |
|
|---|
| 120 | // Note:
|
|---|
| 121 | // For a "lonekey"-press of AltGr, we only receive WM_KEYUP
|
|---|
| 122 | // messages. If the key is pressed longer and starts to repeat,
|
|---|
| 123 | // WM_KEYDOWN messages come in properly.
|
|---|
| 124 | static BOOL fKeyAltGrDown = FALSE;
|
|---|
| 125 | static BOOL fEnableCDPolling = FALSE;
|
|---|
| 126 |
|
|---|
| 127 | static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes);
|
|---|
| 128 | static BOOL PMDragValidate(PDRAGINFO pDragInfo);
|
|---|
| 129 | static void QueryPMMenuBitmaps();
|
|---|
| 130 |
|
|---|
| 131 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 132 | MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 133 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
|---|
| 134 | void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
|
|---|
| 135 | HBITMAP hbmNew);
|
|---|
| 136 | void FrameSetFocus(HWND hwnd);
|
|---|
| 137 |
|
|---|
| 138 | VOID APIENTRY DspInitSystemDriverName(PSZ pszDriverName, ULONG lenDriverName);
|
|---|
| 139 |
|
|---|
| 140 | #ifdef DEBUG
|
|---|
| 141 | static char *DbgGetStringSWPFlags(ULONG flags);
|
|---|
| 142 | static char *DbgPrintQFCFlags(ULONG flags);
|
|---|
| 143 | #endif
|
|---|
| 144 |
|
|---|
| 145 | //******************************************************************************
|
|---|
| 146 | // Initialize PM; create hab, message queue and register special Win32 window classes
|
|---|
| 147 | //
|
|---|
| 148 | // This is called from the initterm, so we call it only once for each process.
|
|---|
| 149 | // We make sure PM is up and running for our purposes and init the existing
|
|---|
| 150 | // thread 0.
|
|---|
| 151 | //******************************************************************************
|
|---|
| 152 | BOOL InitPM()
|
|---|
| 153 | {
|
|---|
| 154 | hab = WinInitialize(0);
|
|---|
| 155 | dprintf(("Winitialize returned %x", hab));
|
|---|
| 156 | hmq = WinCreateMsgQueue(hab, 0);
|
|---|
| 157 |
|
|---|
| 158 | if(!hab || !hmq)
|
|---|
| 159 | {
|
|---|
| 160 | UINT error;
|
|---|
| 161 | //CB: only fail on real error
|
|---|
| 162 | error = WinGetLastError(hab) & 0xFFFF; //error code
|
|---|
| 163 | if (!hab || (error != PMERR_MSG_QUEUE_ALREADY_EXISTS))
|
|---|
| 164 | {
|
|---|
| 165 | dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
|
|---|
| 166 | dprintf((" Error = %x",error));
|
|---|
| 167 | if(error == PMERR_NOT_IN_A_PM_SESSION) return TRUE;
|
|---|
| 168 |
|
|---|
| 169 | return(FALSE);
|
|---|
| 170 | }
|
|---|
| 171 | else
|
|---|
| 172 | {
|
|---|
| 173 | if(!hab) {
|
|---|
| 174 | hab = WinQueryAnchorBlock(HWND_DESKTOP);
|
|---|
| 175 | dprintf(("WinQueryAnchorBlock returned %x", hab));
|
|---|
| 176 | }
|
|---|
| 177 | if(!hmq) {
|
|---|
| 178 | PTIB ptib;
|
|---|
| 179 | PPIB ppib;
|
|---|
| 180 |
|
|---|
| 181 | DosGetInfoBlocks(&ptib, &ppib);
|
|---|
| 182 |
|
|---|
| 183 | hmq = WinQueueFromID(hab, ppib->pib_ulpid, ptib->tib_ptib2->tib2_ultid);
|
|---|
| 184 | }
|
|---|
| 185 | }
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | // store our HAB and HMQ in the TEB - we need it quite often
|
|---|
| 189 | // and they don't map 1:1 to Windows entities
|
|---|
| 190 | SetThreadHAB(hab);
|
|---|
| 191 | dprintf(("InitPM: hmq = %x", hmq));
|
|---|
| 192 | SetThreadMessageQueue(hmq);
|
|---|
| 193 |
|
|---|
| 194 | //initialize keyboard hook for first thread
|
|---|
| 195 | hookInit(hab);
|
|---|
| 196 |
|
|---|
| 197 | BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
|
|---|
| 198 | dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
|
|---|
| 199 |
|
|---|
| 200 | //CD polling window class
|
|---|
| 201 | if(!WinRegisterClass( /* Register window class */
|
|---|
| 202 | hab, /* Anchor block handle */
|
|---|
| 203 | (PSZ)WIN32_CDCLASS, /* Window class name */
|
|---|
| 204 | (PFNWP)Win32CDWindowProc, /* Address of window procedure */
|
|---|
| 205 | 0,
|
|---|
| 206 | 0))
|
|---|
| 207 | {
|
|---|
| 208 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
|---|
| 209 | return(FALSE);
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | //Standard Odin window class
|
|---|
| 213 | if(!WinRegisterClass( /* Register window class */
|
|---|
| 214 | hab, /* Anchor block handle */
|
|---|
| 215 | (PSZ)WIN32_STDCLASS, /* Window class name */
|
|---|
| 216 | (PFNWP)Win32WindowProc, /* Address of window procedure */
|
|---|
| 217 | 0,
|
|---|
| 218 | NROF_WIN32WNDBYTES))
|
|---|
| 219 | {
|
|---|
| 220 | dprintf(("WinRegisterClass Win32BaseWindow failed"));
|
|---|
| 221 | return(FALSE);
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | //We no longer register our own frame window class as there is code in PM
|
|---|
| 225 | //that makes assumptions about frame window class names.
|
|---|
| 226 | //Instead we subclass the frame window right after creating it.
|
|---|
| 227 | CLASSINFO FrameClassInfo;
|
|---|
| 228 | if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
|
|---|
| 229 | dprintf (("WinQueryClassInfo WC_FRAME failed"));
|
|---|
| 230 | return (FALSE);
|
|---|
| 231 | }
|
|---|
| 232 | pfnFrameWndProc = FrameClassInfo.pfnWindowProc;
|
|---|
| 233 |
|
|---|
| 234 | dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
|
|---|
| 235 |
|
|---|
| 236 | // get the screen dimensions and store them
|
|---|
| 237 | WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
|
|---|
| 238 | ScreenWidth = desktopRectl.xRight;
|
|---|
| 239 | ScreenHeight = desktopRectl.yTop;
|
|---|
| 240 |
|
|---|
| 241 | HDC hdc; /* Device-context handle */
|
|---|
| 242 | /* context data structure */
|
|---|
| 243 | DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
|
|---|
| 244 | NULL, NULL, NULL};
|
|---|
| 245 |
|
|---|
| 246 | /* create memory device context - it's temporary to query some information */
|
|---|
| 247 | hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
|---|
| 248 |
|
|---|
| 249 | // check if we have the OS/2 Look and Feel enabled
|
|---|
| 250 | fOS2Look = PROFILE_GetOdinIniBool(ODINSYSTEM_SECTION, "OS2Look", TRUE);
|
|---|
| 251 | if(fOS2Look)
|
|---|
| 252 | {
|
|---|
| 253 | SYSCOLOR_Init(FALSE); //use OS/2 colors
|
|---|
| 254 | QueryPMMenuBitmaps();
|
|---|
| 255 | }
|
|---|
| 256 |
|
|---|
| 257 | // find out which colordepth we're running
|
|---|
| 258 | DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
|
|---|
| 259 |
|
|---|
| 260 | // query the font height to find out whether we have small or large fonts
|
|---|
| 261 | DevQueryCaps(hdc, CAPS_GRAPHICS_CHAR_HEIGHT, 1, (PLONG)&CapsCharHeight);
|
|---|
| 262 | dprintf(("CAPS_GRAPHICS_CHAR_HEIGHT = %d", CapsCharHeight));
|
|---|
| 263 | if(CapsCharHeight > 16) {
|
|---|
| 264 | CapsCharHeight = 16;
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | #ifdef DEBUG
|
|---|
| 268 | ULONG temp;
|
|---|
| 269 | DevQueryCaps(hdc, CAPS_GRAPHICS_CHAR_WIDTH, 1, (PLONG)&temp);
|
|---|
| 270 | dprintf(("CAPS_GRAPHICS_CHAR_WIDTH = %d", temp));
|
|---|
| 271 | DevQueryCaps(hdc, CAPS_CHAR_HEIGHT, 1, (PLONG)&temp);
|
|---|
| 272 | dprintf(("CAPS_CHAR_HEIGTH = %d", temp));
|
|---|
| 273 | DevQueryCaps(hdc, CAPS_CHAR_WIDTH, 1, (PLONG)&temp);
|
|---|
| 274 | dprintf(("CAPS_CHAR_WIDTH = %d", temp));
|
|---|
| 275 | DevQueryCaps(hdc, CAPS_SMALL_CHAR_HEIGHT, 1, (PLONG)&temp);
|
|---|
| 276 | dprintf(("CAPS_SMALL_CHAR_HEIGTH = %d", temp));
|
|---|
| 277 | DevQueryCaps(hdc, CAPS_SMALL_CHAR_WIDTH, 1, (PLONG)&temp);
|
|---|
| 278 | dprintf(("CAPS_SMALL_CHAR_WIDTH = %d", temp));
|
|---|
| 279 | DevQueryCaps(hdc, CAPS_VERTICAL_FONT_RES, 1,(PLONG)&temp);
|
|---|
| 280 | dprintf(("CAPS_VERTICAL_FONT_RES = %d", temp));
|
|---|
| 281 | DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 1,(PLONG)&temp);
|
|---|
| 282 | dprintf(("CAPS_HORIZONTAL_FONT_RES = %d", temp));
|
|---|
| 283 | #endif
|
|---|
| 284 |
|
|---|
| 285 | DevCloseDC(hdc);
|
|---|
| 286 |
|
|---|
| 287 | dprintf(("InitPM: Desktop (%d,%d) bpp %d font size %d", ScreenWidth, ScreenHeight, ScreenBitsPerPel, CapsCharHeight));
|
|---|
| 288 | return TRUE;
|
|---|
| 289 | } /* End of main */
|
|---|
| 290 | //******************************************************************************
|
|---|
| 291 | HBITMAP OPEN32API _O32_CreateBitmapFromPMHandle(HBITMAP hPMBitmap);
|
|---|
| 292 |
|
|---|
| 293 | inline HBITMAP O32_CreateBitmapFromPMHandle(HBITMAP hPMBitmap)
|
|---|
| 294 | {
|
|---|
| 295 | HBITMAP yyrc;
|
|---|
| 296 | USHORT sel = RestoreOS2FS();
|
|---|
| 297 |
|
|---|
| 298 | yyrc = _O32_CreateBitmapFromPMHandle(hPMBitmap);
|
|---|
| 299 | SetFS(sel);
|
|---|
| 300 |
|
|---|
| 301 | return yyrc;
|
|---|
| 302 | }
|
|---|
| 303 | //******************************************************************************
|
|---|
| 304 | static void QueryPMMenuBitmaps()
|
|---|
| 305 | {
|
|---|
| 306 | CHAR szDisplay[30];
|
|---|
| 307 | HMODULE hModDisplay;
|
|---|
| 308 |
|
|---|
| 309 | if(hbmFrameMenu[0] == 0)
|
|---|
| 310 | {
|
|---|
| 311 | CHAR szDisplay[30];
|
|---|
| 312 | HMODULE hModDisplay;
|
|---|
| 313 | HDC hdc; /* Device-context handle */
|
|---|
| 314 | DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
|
|---|
| 315 | NULL, NULL, NULL};
|
|---|
| 316 |
|
|---|
| 317 | /* create memory device context */
|
|---|
| 318 | hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
|
|---|
| 319 |
|
|---|
| 320 | DspInitSystemDriverName(szDisplay, sizeof(szDisplay));
|
|---|
| 321 | DosQueryModuleHandle(szDisplay, &hModDisplay);
|
|---|
| 322 |
|
|---|
| 323 | hbmFrameMenu[PMMENU_MINBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MINBUTTON, 0, 0);
|
|---|
| 324 | hbmFrameMenu[PMMENU_MINBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MINBUTTONDEP, 0, 0);
|
|---|
| 325 | hbmFrameMenu[PMMENU_MAXBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MAXBUTTON, 0, 0);
|
|---|
| 326 | hbmFrameMenu[PMMENU_MAXBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_MAXBUTTONDEP, 0, 0);
|
|---|
| 327 | hbmFrameMenu[PMMENU_RESTOREBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_RESTOREBUTTON, 0, 0);
|
|---|
| 328 | hbmFrameMenu[PMMENU_RESTOREBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_RESTOREBUTTONDEP, 0, 0);
|
|---|
| 329 | hbmFrameMenu[PMMENU_CLOSEBUTTON] = GpiLoadBitmap(hdc, hModDisplay, SBMP_CLOSE, 0, 0);
|
|---|
| 330 | hbmFrameMenu[PMMENU_CLOSEBUTTONDOWN] = GpiLoadBitmap(hdc, hModDisplay, SBMP_CLOSEDEP, 0, 0);
|
|---|
| 331 |
|
|---|
| 332 | //Create win32 bitmap handles of the OS/2 min, max and restore buttons
|
|---|
| 333 | hBmpMinButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MINBUTTON]);
|
|---|
| 334 | hBmpMinButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MINBUTTONDOWN]);
|
|---|
| 335 | hBmpMaxButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MAXBUTTON]);
|
|---|
| 336 | hBmpMaxButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_MAXBUTTONDOWN]);
|
|---|
| 337 | hBmpRestoreButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
|---|
| 338 | hBmpRestoreButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_RESTOREBUTTONDOWN]);
|
|---|
| 339 | hBmpCloseButton = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_CLOSEBUTTON]);
|
|---|
| 340 | hBmpCloseButtonDown = O32_CreateBitmapFromPMHandle(hbmFrameMenu[PMMENU_CLOSEBUTTONDOWN]);
|
|---|
| 341 | DevCloseDC(hdc);
|
|---|
| 342 | }
|
|---|
| 343 | }
|
|---|
| 344 | //******************************************************************************
|
|---|
| 345 | //******************************************************************************
|
|---|
| 346 | void WIN32API SetWindowAppearance(int fLooks)
|
|---|
| 347 | {
|
|---|
| 348 | if(fLooks == OS2_APPEARANCE || fLooks == OS2_APPEARANCE_SYSMENU)
|
|---|
| 349 | {
|
|---|
| 350 | SYSCOLOR_Init(FALSE); //use OS/2 colors
|
|---|
| 351 | QueryPMMenuBitmaps();
|
|---|
| 352 | }
|
|---|
| 353 | fOS2Look = fLooks;
|
|---|
| 354 | MENU_Init();
|
|---|
| 355 | }
|
|---|
| 356 | //******************************************************************************
|
|---|
| 357 | //******************************************************************************
|
|---|
| 358 | void WIN32API CustForceMonoCursor()
|
|---|
| 359 | {
|
|---|
| 360 | fForceMonoCursor = TRUE;
|
|---|
| 361 | }
|
|---|
| 362 | //******************************************************************************
|
|---|
| 363 | //******************************************************************************
|
|---|
| 364 | void WIN32API DisableDragDrop(BOOL fDisabled)
|
|---|
| 365 | {
|
|---|
| 366 | fDragDropDisabled = fDisabled;
|
|---|
| 367 | }
|
|---|
| 368 | //******************************************************************************
|
|---|
| 369 | // Turn on CD Polling (window with 2 second timer to check CD disk presence)
|
|---|
| 370 | //
|
|---|
| 371 | // NOTE: This can cause PM hangs when executing a program for a very long time
|
|---|
| 372 | // (block in IOCtl)
|
|---|
| 373 | //******************************************************************************
|
|---|
| 374 | void WIN32API CustEnableCDPolling()
|
|---|
| 375 | {
|
|---|
| 376 | fEnableCDPolling = TRUE;
|
|---|
| 377 | }
|
|---|
| 378 | //******************************************************************************
|
|---|
| 379 | //CD notification window class
|
|---|
| 380 | //******************************************************************************
|
|---|
| 381 | MRESULT EXPENTRY Win32CDWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 382 | {
|
|---|
| 383 | #pragma pack(1)
|
|---|
| 384 | typedef struct
|
|---|
| 385 | {
|
|---|
| 386 | BYTE ucCommandInfo;
|
|---|
| 387 | WORD usDriveUnit;
|
|---|
| 388 | } ParameterBlock;
|
|---|
| 389 | #pragma pack()
|
|---|
| 390 |
|
|---|
| 391 | MRESULT rc = 0;
|
|---|
| 392 | static ULONG drives[26] = {0};
|
|---|
| 393 | static int drivestatus[26] = {0};
|
|---|
| 394 |
|
|---|
| 395 | switch( msg )
|
|---|
| 396 | {
|
|---|
| 397 | //OS/2 msgs
|
|---|
| 398 | case WM_CREATE:
|
|---|
| 399 | {
|
|---|
| 400 | char drive[4];
|
|---|
| 401 |
|
|---|
| 402 | //skip floppy drives
|
|---|
| 403 | drive[0] = 'C';
|
|---|
| 404 | drive[1] = ':';
|
|---|
| 405 | drive[2] = '\0';
|
|---|
| 406 |
|
|---|
| 407 | for(int i=2;i<26;i++) {
|
|---|
| 408 | drives[i] = GetDriveTypeA(drive);
|
|---|
| 409 | if(drives[i] == DRIVE_CDROM_W)
|
|---|
| 410 | {
|
|---|
| 411 | DWORD parsize = sizeof(ParameterBlock);
|
|---|
| 412 | DWORD datasize = 2;
|
|---|
| 413 | WORD status = 0;
|
|---|
| 414 | DWORD rc;
|
|---|
| 415 | ParameterBlock parm;
|
|---|
| 416 |
|
|---|
| 417 | parm.ucCommandInfo = 0;
|
|---|
| 418 | parm.usDriveUnit = i;
|
|---|
| 419 | rc = DosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize,
|
|---|
| 420 | &status, sizeof(status), &datasize);
|
|---|
| 421 | if(rc != NO_ERROR) {
|
|---|
| 422 | dprintf(("DosDevIOCtl failed with rc %d", rc));
|
|---|
| 423 | drives[i] = 0;
|
|---|
| 424 | continue;
|
|---|
| 425 | }
|
|---|
| 426 | //if no disk present, return FALSE
|
|---|
| 427 | if(status & 4) {
|
|---|
| 428 | drivestatus[i] = status & 4;
|
|---|
| 429 | }
|
|---|
| 430 | }
|
|---|
| 431 | drive[0]++;
|
|---|
| 432 | }
|
|---|
| 433 | WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 32*60);
|
|---|
| 434 | //// WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 32*3);
|
|---|
| 435 | //// WinStartTimer(hab, hwnd, TIMERID_DRIVEPOLL, 5000);
|
|---|
| 436 | rc = (MRESULT)FALSE;
|
|---|
| 437 | break;
|
|---|
| 438 | }
|
|---|
| 439 | case WM_TIMER:
|
|---|
| 440 | {
|
|---|
| 441 | for(int i=0;i<26;i++)
|
|---|
| 442 | {
|
|---|
| 443 | //for now only cdrom/dvd drives
|
|---|
| 444 | if(drives[i] == DRIVE_CDROM_W)
|
|---|
| 445 | {
|
|---|
| 446 | DWORD parsize = sizeof(ParameterBlock);
|
|---|
| 447 | DWORD datasize = 2;
|
|---|
| 448 | WORD status = 0;
|
|---|
| 449 | DWORD rc;
|
|---|
| 450 | ParameterBlock parm;
|
|---|
| 451 |
|
|---|
| 452 | parm.ucCommandInfo = 0;
|
|---|
| 453 | parm.usDriveUnit = i;
|
|---|
| 454 | rc = DosDevIOCtl(-1, IOCTL_DISK, DSK_GETLOCKSTATUS, &parm, sizeof(parm), &parsize,
|
|---|
| 455 | &status, sizeof(status), &datasize);
|
|---|
| 456 | if(rc != NO_ERROR) {
|
|---|
| 457 | dprintf(("DosDevIOCtl failed with rc %d", rc));
|
|---|
| 458 | return FALSE;
|
|---|
| 459 | }
|
|---|
| 460 | //Send WM_DEVICECHANGE message when CD status changes
|
|---|
| 461 | if((status & 4) != drivestatus[i])
|
|---|
| 462 | {
|
|---|
| 463 | PID pidThis, pidTemp;
|
|---|
| 464 | HENUM henum;
|
|---|
| 465 | HWND hwndEnum;
|
|---|
| 466 | DEV_BROADCAST_VOLUME volchange;
|
|---|
| 467 |
|
|---|
| 468 | dprintf(("Disk status 0x%x", status));
|
|---|
| 469 |
|
|---|
| 470 | volchange.dbcv_size = sizeof(volchange);
|
|---|
| 471 | volchange.dbcv_devicetype = DBT_DEVTYP_VOLUME;
|
|---|
| 472 | volchange.dbcv_reserved = 0;
|
|---|
| 473 | volchange.dbcv_unitmask = (1 << i);
|
|---|
| 474 | volchange.dbcv_flags = DBTF_MEDIA;
|
|---|
| 475 |
|
|---|
| 476 | WinQueryWindowProcess(hwnd, &pidThis, NULL);
|
|---|
| 477 |
|
|---|
| 478 | //Iterate over all child windows of the desktop
|
|---|
| 479 | henum = WinBeginEnumWindows(HWND_DESKTOP);
|
|---|
| 480 |
|
|---|
| 481 | SetWin32TIB();
|
|---|
| 482 | while(hwndEnum = WinGetNextWindow(henum))
|
|---|
| 483 | {
|
|---|
| 484 | WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
|
|---|
| 485 | if(pidTemp == pidThis)
|
|---|
| 486 | {
|
|---|
| 487 | HWND hwndWin32 = OS2ToWin32Handle(hwndEnum);
|
|---|
| 488 | if(hwndWin32) {
|
|---|
| 489 | SendMessageA(hwndWin32,
|
|---|
| 490 | WM_DEVICECHANGE_W,
|
|---|
| 491 | (status & 4) ? DBT_DEVICEARRIVAL : DBT_DEVICEREMOVECOMPLETE,
|
|---|
| 492 | (LPARAM)&volchange);
|
|---|
| 493 | }
|
|---|
| 494 | }
|
|---|
| 495 | }
|
|---|
| 496 | RestoreOS2TIB();
|
|---|
| 497 | WinEndEnumWindows(henum);
|
|---|
| 498 |
|
|---|
| 499 | drivestatus[i] = (status & 4);
|
|---|
| 500 | }
|
|---|
| 501 | }
|
|---|
| 502 | }
|
|---|
| 503 | break;
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | case WM_DESTROY:
|
|---|
| 507 | dprintf(("WM_DESTROY for CD notification window"));
|
|---|
| 508 | WinStopTimer(hab, hwnd, TIMERID_DRIVEPOLL);
|
|---|
| 509 | break;
|
|---|
| 510 |
|
|---|
| 511 | default:
|
|---|
| 512 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 513 | }
|
|---|
| 514 | return (MRESULT)rc;
|
|---|
| 515 | }
|
|---|
| 516 | //******************************************************************************
|
|---|
| 517 | // Win32 window message handler
|
|---|
| 518 | // The PM window procedure for our client window class (non frame)
|
|---|
| 519 | //******************************************************************************
|
|---|
| 520 | MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 521 | {
|
|---|
| 522 | Win32BaseWindow *win32wnd;
|
|---|
| 523 | TEB *teb;
|
|---|
| 524 | MSG winMsg, *pWinMsg;
|
|---|
| 525 | MRESULT rc = 0;
|
|---|
| 526 | POSTMSG_PACKET *postmsg;
|
|---|
| 527 | OSLIBPOINT point, ClientPoint;
|
|---|
| 528 | EXCEPTIONREGISTRATIONRECORD exceptRegRec = {0,0};
|
|---|
| 529 |
|
|---|
| 530 | ODIN_SetExceptionHandler(&exceptRegRec);
|
|---|
| 531 | // restore our FS selector
|
|---|
| 532 | SetWin32TIB();
|
|---|
| 533 |
|
|---|
| 534 | #ifdef DEBUG
|
|---|
| 535 | dbg_ThreadPushCall("Win32WindowProc");
|
|---|
| 536 | #endif
|
|---|
| 537 |
|
|---|
| 538 | // BEGIN NOTE-------------->>>>>> If this is changed, also change Win32FrameWindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
|---|
| 539 | teb = GetThreadTEB();
|
|---|
| 540 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 541 |
|
|---|
| 542 | //// dprintf(("window %x msg %x", (win32wnd) ? win32wnd->getWindowHandle() : 0, msg));
|
|---|
| 543 |
|
|---|
| 544 | // do some sanity checking here:
|
|---|
| 545 | // - we need to have a TEB handle
|
|---|
| 546 | // - unless this is WM_CREATE (the very first message), there has to be
|
|---|
| 547 | // a USER32 window object for this window handle
|
|---|
| 548 | // - thread must not be suspended in WaitMessage
|
|---|
| 549 | if(!teb || (msg != WM_CREATE && win32wnd == NULL) || teb->o.odin.fWaitMessageSuspend) {
|
|---|
| 550 | if(teb && teb->o.odin.fWaitMessageSuspend)
|
|---|
| 551 | dprintf(("OS2: fWaitMessageSuspend window %x msg %x -> run default frame proc", hwnd, msg));
|
|---|
| 552 | else dprintf(("OS2: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
|---|
| 553 | goto RunDefWndProc;
|
|---|
| 554 | }
|
|---|
| 555 | //// if(teb->o.odin.fIgnoreMsgs) {
|
|---|
| 556 | //// goto RunDefWndProc;
|
|---|
| 557 | //// }
|
|---|
| 558 |
|
|---|
| 559 | // check if the message state counter in the TEB is odd
|
|---|
| 560 | // This means the message has been sent directly from PM to our message
|
|---|
| 561 | // handler (so it is the first time we know about this PM message).
|
|---|
| 562 | // If this is the case, we have to translate it here to a Win32
|
|---|
| 563 | // message first. The other case is that the message is the result of a
|
|---|
| 564 | // WinDispatchMsg call and therefore has already been translated.
|
|---|
| 565 | if((teb->o.odin.msgstate & 1) == 0)
|
|---|
| 566 | {
|
|---|
| 567 | // message that was sent directly to our window proc handler; translate it here
|
|---|
| 568 | QMSG qmsg;
|
|---|
| 569 |
|
|---|
| 570 | qmsg.msg = msg;
|
|---|
| 571 | qmsg.hwnd = hwnd;
|
|---|
| 572 | qmsg.mp1 = mp1;
|
|---|
| 573 | qmsg.mp2 = mp2;
|
|---|
| 574 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
|---|
| 575 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
|---|
| 576 | qmsg.reserved = 0;
|
|---|
| 577 |
|
|---|
| 578 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 579 | {//message was not translated
|
|---|
| 580 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 581 | }
|
|---|
| 582 | pWinMsg = &winMsg;
|
|---|
| 583 | }
|
|---|
| 584 | else {
|
|---|
| 585 | // message has already been translated before (GetMessage/PeekMessage).
|
|---|
| 586 | // Use the translated information. Flip the translation flag.
|
|---|
| 587 | pWinMsg = &teb->o.odin.msg;
|
|---|
| 588 | teb->o.odin.msgstate++;
|
|---|
| 589 | }
|
|---|
| 590 | // END NOTE-------------->>>>>> If this is changed, also change Win32FrameWindowProc!! <<<<<<<<<<<-------------------- END
|
|---|
| 591 |
|
|---|
| 592 | if(msg >= WIN32APP_POSTMSG) {
|
|---|
| 593 | //probably win32 app user message
|
|---|
| 594 | dprintf2(("Posted message %x->%x", msg, msg-WIN32APP_POSTMSG));
|
|---|
| 595 | if((ULONG)mp1 == WIN32MSG_MAGICA) {
|
|---|
| 596 | rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 597 | }
|
|---|
| 598 | else
|
|---|
| 599 | if((ULONG)mp1 == WIN32MSG_MAGICW) {
|
|---|
| 600 | rc = (MRESULT)win32wnd->DispatchMsgW(pWinMsg);
|
|---|
| 601 | }
|
|---|
| 602 | else {//broadcasted message
|
|---|
| 603 | rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 604 | }
|
|---|
| 605 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 606 | RestoreOS2TIB();
|
|---|
| 607 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 608 |
|
|---|
| 609 | #ifdef DEBUG
|
|---|
| 610 | dbg_ThreadPopCall();
|
|---|
| 611 | #endif
|
|---|
| 612 | return rc;
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | switch( msg )
|
|---|
| 616 | {
|
|---|
| 617 | //OS/2 msgs
|
|---|
| 618 | case WM_CREATE:
|
|---|
| 619 | {
|
|---|
| 620 | if(teb->o.odin.newWindow == 0)
|
|---|
| 621 | goto createfail;
|
|---|
| 622 |
|
|---|
| 623 | //Processing is done in after WinCreateWindow returns
|
|---|
| 624 | dprintf(("OS2: WM_CREATE %x", hwnd));
|
|---|
| 625 | win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
|
|---|
| 626 | win32wnd->addRef();
|
|---|
| 627 | teb->o.odin.newWindow = 0;
|
|---|
| 628 | if(win32wnd->MsgCreate(hwnd) == FALSE)
|
|---|
| 629 | {
|
|---|
| 630 | rc = (MRESULT)TRUE; //discontinue window creation
|
|---|
| 631 | break;
|
|---|
| 632 | }
|
|---|
| 633 |
|
|---|
| 634 | //Create CD notification window
|
|---|
| 635 | if(hwndCD == 0 && fEnableCDPolling) {
|
|---|
| 636 | hwndCD = WinCreateWindow(HWND_DESKTOP, WIN32_CDCLASS,
|
|---|
| 637 | NULL, 0, 0, 0, 0, 0,
|
|---|
| 638 | HWND_DESKTOP, HWND_TOP, 0, NULL, NULL);
|
|---|
| 639 | }
|
|---|
| 640 |
|
|---|
| 641 | createfail:
|
|---|
| 642 | rc = (MRESULT)FALSE;
|
|---|
| 643 | break;
|
|---|
| 644 | }
|
|---|
| 645 |
|
|---|
| 646 | case WM_QUIT:
|
|---|
| 647 | dprintf(("OS2: WM_QUIT %x", hwnd));
|
|---|
| 648 | win32wnd->MsgQuit();
|
|---|
| 649 | break;
|
|---|
| 650 |
|
|---|
| 651 | case WM_CLOSE:
|
|---|
| 652 | dprintf(("OS2: WM_CLOSE %x", hwnd));
|
|---|
| 653 | win32wnd->MsgClose();
|
|---|
| 654 | break;
|
|---|
| 655 |
|
|---|
| 656 | case WM_DESTROY:
|
|---|
| 657 | dprintf(("OS2: WM_DESTROY %x", hwnd));
|
|---|
| 658 | win32wnd->MsgDestroy();
|
|---|
| 659 | WinSetVisibleRegionNotify(hwnd, FALSE);
|
|---|
| 660 | goto RunDefWndProc;
|
|---|
| 661 |
|
|---|
| 662 | case WM_ENABLE:
|
|---|
| 663 | dprintf(("OS2: WM_ENABLE %x", hwnd));
|
|---|
| 664 | break;
|
|---|
| 665 |
|
|---|
| 666 | case WM_SHOW:
|
|---|
| 667 | {
|
|---|
| 668 | dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
|
|---|
| 669 | win32wnd->MsgShow((ULONG)mp1);
|
|---|
| 670 |
|
|---|
| 671 | //if a child window is hidden, then the update region of the
|
|---|
| 672 | //parent changes and a WM_ERASEBKGND is required during the next
|
|---|
| 673 | //BeginPaint call.
|
|---|
| 674 | if((ULONG)mp1 == FALSE)
|
|---|
| 675 | {
|
|---|
| 676 | Win32BaseWindow *parent = win32wnd->getParent();
|
|---|
| 677 | if(parent) {
|
|---|
| 678 | dprintf(("PM Update region changed for parent %x", win32wnd->getWindowHandle()));
|
|---|
| 679 | parent->SetPMUpdateRegionChanged(TRUE);
|
|---|
| 680 | }
|
|---|
| 681 | }
|
|---|
| 682 | break;
|
|---|
| 683 | }
|
|---|
| 684 |
|
|---|
| 685 | case WM_ACTIVATE:
|
|---|
| 686 | {
|
|---|
| 687 | ULONG flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
|
|---|
| 688 |
|
|---|
| 689 | dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
|
|---|
| 690 | WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | WINDOWFLAG_ACTIVE):(flags & ~WINDOWFLAG_ACTIVE));
|
|---|
| 691 | if(win32wnd->IsWindowCreated())
|
|---|
| 692 | {
|
|---|
| 693 | win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
|
|---|
| 694 | }
|
|---|
| 695 | break;
|
|---|
| 696 | }
|
|---|
| 697 |
|
|---|
| 698 | case WM_SIZE:
|
|---|
| 699 | {
|
|---|
| 700 | dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)));
|
|---|
| 701 | win32wnd->SetPMUpdateRegionChanged(TRUE);
|
|---|
| 702 | goto RunDefWndProc;
|
|---|
| 703 | }
|
|---|
| 704 |
|
|---|
| 705 |
|
|---|
| 706 | case WM_VRNENABLED:
|
|---|
| 707 | {
|
|---|
| 708 | dprintf(("OS2: WM_VRNENABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 709 | //Always call handler; even if mp1 is 0. If we don't do this, the
|
|---|
| 710 | //DivX 4 player will never be allowed to draw after putting another window
|
|---|
| 711 | //on top of it.
|
|---|
| 712 |
|
|---|
| 713 | win32wnd->callVisibleRgnNotifyProc(TRUE);
|
|---|
| 714 |
|
|---|
| 715 | //Workaround for PM/GPI bug when moving/sizing a window with open DCs
|
|---|
| 716 | //
|
|---|
| 717 | //Windows applictions often get a DC and keep it open for the duration
|
|---|
| 718 | //of the application. When the DC's window is moved (full window dragging on)
|
|---|
| 719 | //PM/GPI doesn't seem to update the DC properly/in time.
|
|---|
| 720 | //This can result is visible distortions on the screen.
|
|---|
| 721 | //Debugging showed that querying the visible region of a DC will cure
|
|---|
| 722 | //this problem (GPI probably recalculates the visible region).
|
|---|
| 723 | int nrdcs = 0;
|
|---|
| 724 | HDC hdcWindow[MAX_OPENDCS];
|
|---|
| 725 |
|
|---|
| 726 | if(win32wnd->queryOpenDCs(hdcWindow, MAX_OPENDCS, &nrdcs))
|
|---|
| 727 | {
|
|---|
| 728 | RECTL rcl = {0,0,1,1};
|
|---|
| 729 | HRGN hrgnRect;
|
|---|
| 730 |
|
|---|
| 731 | for(int i=0;i<nrdcs;i++) {
|
|---|
| 732 | dprintf(("Recalc visible region of DC %x for window %x", hdcWindow[i], win32wnd->getWindowHandle()));
|
|---|
| 733 | hrgnRect = GreCreateRectRegion(hdcWindow[i], &rcl, 1);
|
|---|
| 734 | GreCopyClipRegion(hdcWindow[i], hrgnRect, 0, COPYCRGN_VISRGN);
|
|---|
| 735 | GreDestroyRegion(hdcWindow[i], hrgnRect);
|
|---|
| 736 | }
|
|---|
| 737 | }
|
|---|
| 738 |
|
|---|
| 739 | //Workaround END
|
|---|
| 740 |
|
|---|
| 741 | if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
|
|---|
| 742 | {
|
|---|
| 743 | HWND hwndrelated;
|
|---|
| 744 | Win32BaseWindow *topwindow;
|
|---|
| 745 |
|
|---|
| 746 | win32wnd->setComingToTop(TRUE);
|
|---|
| 747 |
|
|---|
| 748 | hwndrelated = WinQueryWindow(hwnd, QW_PREV);
|
|---|
| 749 | dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
|
|---|
| 750 | topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
|
|---|
| 751 | if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
|
|---|
| 752 | //put window at the top of z order
|
|---|
| 753 | WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
|
|---|
| 754 | }
|
|---|
| 755 | if(topwindow) RELEASE_WNDOBJ(topwindow);
|
|---|
| 756 |
|
|---|
| 757 | win32wnd->setComingToTop(FALSE);
|
|---|
| 758 | break;
|
|---|
| 759 | }
|
|---|
| 760 | goto RunDefWndProc;
|
|---|
| 761 | }
|
|---|
| 762 |
|
|---|
| 763 | case WM_VRNDISABLED:
|
|---|
| 764 | {
|
|---|
| 765 | dprintf(("OS2: WM_VRNDISABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 766 | //visible region is about to change or WinLockWindowUpdate called
|
|---|
| 767 | //suspend window drawing
|
|---|
| 768 |
|
|---|
| 769 | win32wnd->callVisibleRgnNotifyProc(FALSE);
|
|---|
| 770 | goto RunDefWndProc;
|
|---|
| 771 | }
|
|---|
| 772 |
|
|---|
| 773 | case WIN32APP_DDRAWFULLSCREEN:
|
|---|
| 774 | //Changing the size of the win32 window in SetCooperativeLevel can
|
|---|
| 775 | //fail if this happens during WM_ADJUSTWINDOWPOS
|
|---|
| 776 | //NOTE: This is not a good solution, but a proper fix is more difficult
|
|---|
| 777 | // with the current window mess
|
|---|
| 778 | dprintf(("WIN32APP_DDRAWFULLSCREEN %x (%d,%d)", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 779 | SetWindowPos(win32wnd->getWindowHandle(), HWND_TOP_W, 0, 0, (DWORD)mp1, (DWORD)mp2, 0);
|
|---|
| 780 | ShowWindow(win32wnd->getWindowHandle(), SW_SHOW_W);
|
|---|
| 781 | break;
|
|---|
| 782 |
|
|---|
| 783 | case WIN32APP_CHNGEFRAMECTRLS:
|
|---|
| 784 | {
|
|---|
| 785 | dprintf(("OS2: WIN32APP_CHANGEFRAMECTRLS"));
|
|---|
| 786 | OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), (ULONG)mp1, win32wnd->getExStyle(), (ULONG)mp2);
|
|---|
| 787 | break;
|
|---|
| 788 | }
|
|---|
| 789 |
|
|---|
| 790 | #ifdef DEBUG
|
|---|
| 791 | case WM_SETFOCUS:
|
|---|
| 792 | {
|
|---|
| 793 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 794 | dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d cur focus %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2, WinQueryFocus(HWND_DESKTOP)));
|
|---|
| 795 | if(WinQueryFocus(HWND_DESKTOP) == win32wnd->getOS2FrameWindowHandle()) {
|
|---|
| 796 | dprintf(("WARNING: Focus set to frame window"));
|
|---|
| 797 | }
|
|---|
| 798 | break;
|
|---|
| 799 | }
|
|---|
| 800 | #endif
|
|---|
| 801 |
|
|---|
| 802 | //Handle all focus processed during WM_FOCUSCHANGED; PM doesn't like focus
|
|---|
| 803 | //changes during focus processing (WM_SETFOCUS). This message is sent
|
|---|
| 804 | //after all focus work has been completed.
|
|---|
| 805 | case WM_FOCUSCHANGED:
|
|---|
| 806 | {
|
|---|
| 807 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 808 | HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
|
|---|
| 809 |
|
|---|
| 810 | dprintf(("OS2: WM_FOCUSCHANGED %x %x (%x) %d cur focus %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2, WinQueryFocus(HWND_DESKTOP)));
|
|---|
| 811 |
|
|---|
| 812 | //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
|
|---|
| 813 | //must delay this function call
|
|---|
| 814 |
|
|---|
| 815 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC)
|
|---|
| 816 | {
|
|---|
| 817 | //another (non-win32) application's window
|
|---|
| 818 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
|---|
| 819 | hwndFocus = 0;
|
|---|
| 820 | hwndFocusWin32 = 0;
|
|---|
| 821 | }
|
|---|
| 822 | if((ULONG)mp2 == TRUE) {
|
|---|
| 823 | recreateCaret(hwndFocusWin32);
|
|---|
| 824 | win32wnd->MsgSetFocus(hwndFocusWin32);
|
|---|
| 825 | }
|
|---|
| 826 | else {
|
|---|
| 827 | //If SetFocus(0) was called, then the window has already received
|
|---|
| 828 | //a WM_KILLFOCUS; don't send another one
|
|---|
| 829 | if(!fIgnoreKeystrokes) {
|
|---|
| 830 | win32wnd->MsgKillFocus(OS2ToWin32Handle(hwndFocus));
|
|---|
| 831 | }
|
|---|
| 832 | else dprintf(("Window has already received a WM_KILLFOCUS (SetFocus(0)); ignore"));
|
|---|
| 833 | }
|
|---|
| 834 | break;
|
|---|
| 835 | }
|
|---|
| 836 |
|
|---|
| 837 | //**************************************************************************
|
|---|
| 838 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
|---|
| 839 | //**************************************************************************
|
|---|
| 840 |
|
|---|
| 841 | case WM_BUTTON1DOWN:
|
|---|
| 842 | case WM_BUTTON1UP:
|
|---|
| 843 | case WM_BUTTON1DBLCLK:
|
|---|
| 844 | case WM_BUTTON2DOWN:
|
|---|
| 845 | case WM_BUTTON2UP:
|
|---|
| 846 | case WM_BUTTON2DBLCLK:
|
|---|
| 847 | case WM_BUTTON3DOWN:
|
|---|
| 848 | case WM_BUTTON3UP:
|
|---|
| 849 | case WM_BUTTON3DBLCLK:
|
|---|
| 850 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 851 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 852 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 853 | }
|
|---|
| 854 | if(win32wnd)
|
|---|
| 855 | win32wnd->MsgButton(pWinMsg);
|
|---|
| 856 |
|
|---|
| 857 | rc = (MRESULT)TRUE;
|
|---|
| 858 | break;
|
|---|
| 859 |
|
|---|
| 860 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 861 | case WM_BUTTON2MOTIONEND:
|
|---|
| 862 | case WM_BUTTON2CLICK:
|
|---|
| 863 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 864 | case WM_BUTTON1MOTIONEND:
|
|---|
| 865 | case WM_BUTTON1CLICK:
|
|---|
| 866 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 867 | case WM_BUTTON3MOTIONEND:
|
|---|
| 868 | case WM_BUTTON3CLICK:
|
|---|
| 869 | rc = (MRESULT)TRUE;
|
|---|
| 870 | break;
|
|---|
| 871 |
|
|---|
| 872 | case WM_MOUSEMOVE:
|
|---|
| 873 | {
|
|---|
| 874 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 875 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 876 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 877 | }
|
|---|
| 878 | if(win32wnd)
|
|---|
| 879 | win32wnd->MsgMouseMove(pWinMsg);
|
|---|
| 880 | break;
|
|---|
| 881 | }
|
|---|
| 882 |
|
|---|
| 883 | case WM_CONTROL:
|
|---|
| 884 | goto RunDefWndProc;
|
|---|
| 885 |
|
|---|
| 886 | case WM_COMMAND:
|
|---|
| 887 | dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
|
|---|
| 888 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 889 | break;
|
|---|
| 890 |
|
|---|
| 891 | case WM_SYSCOMMAND:
|
|---|
| 892 | dprintf(("OS2: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 893 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 894 | break;
|
|---|
| 895 |
|
|---|
| 896 | case WM_RENDERFMT:
|
|---|
| 897 | case WM_RENDERALLFMTS:
|
|---|
| 898 | case WM_DESTROYCLIPBOARD:
|
|---|
| 899 | case WM_DRAWCLIPBOARD:
|
|---|
| 900 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 901 | break;
|
|---|
| 902 |
|
|---|
| 903 | case WM_CHAR_SPECIAL:
|
|---|
| 904 | /* NO BREAK! FALLTHRU CASE! */
|
|---|
| 905 |
|
|---|
| 906 | case WM_CHAR:
|
|---|
| 907 | dprintf(("OS2: WM_CHAR %x %x %x, %x %x focus wnd %x", win32wnd->getWindowHandle(), mp1, mp2, pWinMsg->wParam, pWinMsg->lParam, WinQueryFocus(HWND_DESKTOP)));
|
|---|
| 908 | win32wnd->MsgChar(pWinMsg);
|
|---|
| 909 | break;
|
|---|
| 910 |
|
|---|
| 911 | case WM_TIMER:
|
|---|
| 912 | dprintf(("OS2: WM_TIMER %x %x time %x", win32wnd->getWindowHandle(), pWinMsg->wParam, GetTickCount()));
|
|---|
| 913 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 914 | goto RunDefWndProc;
|
|---|
| 915 |
|
|---|
| 916 | case WM_SETWINDOWPARAMS:
|
|---|
| 917 | {
|
|---|
| 918 | WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
|
|---|
| 919 |
|
|---|
| 920 | dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
|
|---|
| 921 | if(wndParams->fsStatus & WPM_TEXT) {
|
|---|
| 922 | win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
|
|---|
| 923 | }
|
|---|
| 924 | goto RunDefWndProc;
|
|---|
| 925 | }
|
|---|
| 926 |
|
|---|
| 927 | case WM_QUERYWINDOWPARAMS:
|
|---|
| 928 | {
|
|---|
| 929 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
|---|
| 930 | ULONG textlen;
|
|---|
| 931 | PSZ wintext;
|
|---|
| 932 |
|
|---|
| 933 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
|---|
| 934 | {
|
|---|
| 935 | if(wndpars->fsStatus & WPM_TEXT)
|
|---|
| 936 | win32wnd->MsgGetText(wndpars->pszText, wndpars->cchText);
|
|---|
| 937 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
|---|
| 938 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
|---|
| 939 |
|
|---|
| 940 | wndpars->fsStatus = 0;
|
|---|
| 941 | wndpars->cbCtlData = 0;
|
|---|
| 942 | wndpars->cbPresParams = 0;
|
|---|
| 943 | rc = (MRESULT)TRUE;
|
|---|
| 944 | break;
|
|---|
| 945 | }
|
|---|
| 946 | goto RunDefWndProc;
|
|---|
| 947 | }
|
|---|
| 948 |
|
|---|
| 949 | case WM_PAINT:
|
|---|
| 950 | {
|
|---|
| 951 | RECTL rectl;
|
|---|
| 952 | BOOL rc;
|
|---|
| 953 |
|
|---|
| 954 | win32wnd->checkForDirtyUpdateRegion();
|
|---|
| 955 |
|
|---|
| 956 | rc = WinQueryUpdateRect(hwnd, &rectl);
|
|---|
| 957 | dprintf(("OS2: WM_PAINT %x (%d,%d) (%d,%d) rc=%d", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop, rc));
|
|---|
| 958 |
|
|---|
| 959 | if(rc && win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
|---|
| 960 | rectl.yBottom != rectl.yTop) && !IsIconic(win32wnd->GetTopParent()))
|
|---|
| 961 | {
|
|---|
| 962 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 963 | if(WinQueryUpdateRect(hwnd, NULL) == TRUE)
|
|---|
| 964 | {//the application didn't validate the update region; Windows
|
|---|
| 965 | //will only send a WM_PAINT once until another part of the
|
|---|
| 966 | //window is invalidated. Unfortunately PM keeps on sending
|
|---|
| 967 | //WM_PAINT messages until we validate the update region.
|
|---|
| 968 |
|
|---|
| 969 | win32wnd->saveAndValidateUpdateRegion();
|
|---|
| 970 | }
|
|---|
| 971 | }
|
|---|
| 972 | else goto RunDefWndProc;
|
|---|
| 973 | break;
|
|---|
| 974 | }
|
|---|
| 975 |
|
|---|
| 976 | case WM_ERASEBACKGROUND:
|
|---|
| 977 | {
|
|---|
| 978 | dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
|---|
| 979 | rc = (MRESULT)FALSE;
|
|---|
| 980 | break;
|
|---|
| 981 | }
|
|---|
| 982 |
|
|---|
| 983 | case WM_CALCVALIDRECTS:
|
|---|
| 984 | dprintf(("OS2: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 985 | rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
|---|
| 986 | break;
|
|---|
| 987 |
|
|---|
| 988 | case WM_REALIZEPALETTE:
|
|---|
| 989 | {
|
|---|
| 990 | dprintf(("OS2: WM_REALIZEPALETTE %x", win32wnd->getWindowHandle()));
|
|---|
| 991 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 992 | break;
|
|---|
| 993 | }
|
|---|
| 994 |
|
|---|
| 995 | case WM_HSCROLL:
|
|---|
| 996 | case WM_VSCROLL:
|
|---|
| 997 | dprintf(("OS2: %s %x %x %x", (msg == WM_HSCROLL) ? "WM_HSCROLL" : "WM_VSCROLL", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 998 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 999 | break;
|
|---|
| 1000 |
|
|---|
| 1001 | case DM_DRAGOVER:
|
|---|
| 1002 | {
|
|---|
| 1003 | PDRAGINFO pDragInfo = (PDRAGINFO)mp1;
|
|---|
| 1004 | PDRAGITEM pDragItem;
|
|---|
| 1005 | USHORT sxDrop = SHORT1FROMMP(mp2);
|
|---|
| 1006 | USHORT syDrop = SHORT2FROMMP(mp2);
|
|---|
| 1007 |
|
|---|
| 1008 | dprintf(("OS2: DM_DRAGOVER %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop));
|
|---|
| 1009 |
|
|---|
| 1010 | if(fDragDropDisabled) {
|
|---|
| 1011 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1012 | break;
|
|---|
| 1013 | }
|
|---|
| 1014 |
|
|---|
| 1015 | //does this window accept dropped files?
|
|---|
| 1016 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
|---|
| 1017 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1018 | break;
|
|---|
| 1019 | }
|
|---|
| 1020 |
|
|---|
| 1021 | if(PMDragValidate(pDragInfo) == FALSE) {
|
|---|
| 1022 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1023 | break;
|
|---|
| 1024 | }
|
|---|
| 1025 | if(win32wnd->isDragDropActive() == FALSE) {
|
|---|
| 1026 | ULONG ulBytes, cItems;
|
|---|
| 1027 | char *pszFiles;
|
|---|
| 1028 |
|
|---|
| 1029 | pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes);
|
|---|
| 1030 | if(pszFiles) {
|
|---|
| 1031 | POINT point = {sxDrop, syDrop};
|
|---|
| 1032 | if(DragDropDragEnter(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes, DROPEFFECT_COPY_W) == FALSE) {
|
|---|
| 1033 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1034 | }
|
|---|
| 1035 | else {
|
|---|
| 1036 | fDragDropActive = TRUE;
|
|---|
| 1037 | rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
|---|
| 1038 | win32wnd->setDragDropActive(TRUE);
|
|---|
| 1039 | }
|
|---|
| 1040 | free(pszFiles);
|
|---|
| 1041 | }
|
|---|
| 1042 | else {
|
|---|
| 1043 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1044 | }
|
|---|
| 1045 | }
|
|---|
| 1046 | else {
|
|---|
| 1047 | if(DragDropDragOver(win32wnd->getWindowHandle(), DROPEFFECT_COPY_W) == FALSE) {
|
|---|
| 1048 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1049 | }
|
|---|
| 1050 | else rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
|---|
| 1051 | }
|
|---|
| 1052 | break;
|
|---|
| 1053 | }
|
|---|
| 1054 |
|
|---|
| 1055 | case DM_DRAGLEAVE:
|
|---|
| 1056 | {
|
|---|
| 1057 | dprintf(("OS2: DM_DRAGLEAVE %x", win32wnd->getWindowHandle()));
|
|---|
| 1058 |
|
|---|
| 1059 | if(fDragDropDisabled) {
|
|---|
| 1060 | break;
|
|---|
| 1061 | }
|
|---|
| 1062 |
|
|---|
| 1063 | fDragDropActive = FALSE;
|
|---|
| 1064 |
|
|---|
| 1065 | //does this window accept dropped files?
|
|---|
| 1066 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
|---|
| 1067 | break;
|
|---|
| 1068 | }
|
|---|
| 1069 |
|
|---|
| 1070 | DragDropDragLeave(win32wnd->getWindowHandle());
|
|---|
| 1071 | win32wnd->setDragDropActive(FALSE);
|
|---|
| 1072 | break;
|
|---|
| 1073 | }
|
|---|
| 1074 |
|
|---|
| 1075 | case DM_DROP:
|
|---|
| 1076 | {
|
|---|
| 1077 | PDRAGINFO pDragInfo = (PDRAGINFO)mp1;
|
|---|
| 1078 | PDRAGITEM pDragItem;
|
|---|
| 1079 | USHORT sxDrop = SHORT1FROMMP(mp2);
|
|---|
| 1080 | USHORT syDrop = SHORT2FROMMP(mp2);
|
|---|
| 1081 | USHORT usIndicator, usOp;
|
|---|
| 1082 |
|
|---|
| 1083 | dprintf(("OS2: DM_DROP %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop));
|
|---|
| 1084 |
|
|---|
| 1085 | fDragDropActive = FALSE;
|
|---|
| 1086 | rc = (MRFROM2SHORT (DOR_NODROP, 0));
|
|---|
| 1087 |
|
|---|
| 1088 | if(fDragDropDisabled) {
|
|---|
| 1089 | rc = (MRFROM2SHORT (DOR_NODROP, 0));
|
|---|
| 1090 | break;
|
|---|
| 1091 | }
|
|---|
| 1092 |
|
|---|
| 1093 | //does this window accept dropped files?
|
|---|
| 1094 | if(!DragDropAccept(win32wnd->getWindowHandle())) {
|
|---|
| 1095 | break;
|
|---|
| 1096 | }
|
|---|
| 1097 |
|
|---|
| 1098 | ULONG ulBytes, cItems;
|
|---|
| 1099 | char *pszFiles;
|
|---|
| 1100 |
|
|---|
| 1101 | pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes);
|
|---|
| 1102 | if(pszFiles) {
|
|---|
| 1103 | POINT point = {sxDrop, syDrop};
|
|---|
| 1104 | if(DragDropFiles(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes) == FALSE) {
|
|---|
| 1105 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1106 | }
|
|---|
| 1107 | else {
|
|---|
| 1108 | rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));
|
|---|
| 1109 | win32wnd->setDragDropActive(FALSE);
|
|---|
| 1110 | }
|
|---|
| 1111 | free(pszFiles);
|
|---|
| 1112 | }
|
|---|
| 1113 | else {
|
|---|
| 1114 | rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
|
|---|
| 1115 | }
|
|---|
| 1116 | break;
|
|---|
| 1117 | }
|
|---|
| 1118 |
|
|---|
| 1119 | case DM_RENDER:
|
|---|
| 1120 | {
|
|---|
| 1121 | PDRAGTRANSFER pDragTransfer = (PDRAGTRANSFER)mp1;
|
|---|
| 1122 |
|
|---|
| 1123 | dprintf(("OS2: DM_RENDER %x", pDragTransfer));
|
|---|
| 1124 |
|
|---|
| 1125 | rc = (MRESULT)OSLibRenderFormat(pDragTransfer);
|
|---|
| 1126 | break;
|
|---|
| 1127 | }
|
|---|
| 1128 |
|
|---|
| 1129 | case DM_RENDERPREPARE:
|
|---|
| 1130 | {
|
|---|
| 1131 | PDRAGTRANSFER pDragTransfer = (PDRAGTRANSFER)mp1;
|
|---|
| 1132 |
|
|---|
| 1133 | dprintf(("OS2: DM_RENDERPREPARE %x", pDragTransfer));
|
|---|
| 1134 | break;
|
|---|
| 1135 | }
|
|---|
| 1136 |
|
|---|
| 1137 | case DM_ENDCONVERSATION:
|
|---|
| 1138 | {
|
|---|
| 1139 | dprintf(("OS2: DM_ENDCONVERSATION"));
|
|---|
| 1140 | rc = (MRESULT)OSLibEndConversation();
|
|---|
| 1141 | break;
|
|---|
| 1142 | }
|
|---|
| 1143 |
|
|---|
| 1144 | case DM_RENDERFILE:
|
|---|
| 1145 | {
|
|---|
| 1146 | dprintf(("OS2: DM_ENDCONVERSATION"));
|
|---|
| 1147 | rc = FALSE;
|
|---|
| 1148 | break;
|
|---|
| 1149 | }
|
|---|
| 1150 |
|
|---|
| 1151 | case WM_DDE_INITIATE:
|
|---|
| 1152 | case WM_DDE_INITIATEACK:
|
|---|
| 1153 | case WM_DDE_REQUEST:
|
|---|
| 1154 | case WM_DDE_ACK:
|
|---|
| 1155 | case WM_DDE_DATA:
|
|---|
| 1156 | case WM_DDE_ADVISE:
|
|---|
| 1157 | case WM_DDE_UNADVISE:
|
|---|
| 1158 | case WM_DDE_POKE:
|
|---|
| 1159 | case WM_DDE_EXECUTE:
|
|---|
| 1160 | case WM_DDE_TERMINATE:
|
|---|
| 1161 | dprintf(("OS2: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
|
|---|
| 1162 | goto RunDefWndProc;
|
|---|
| 1163 |
|
|---|
| 1164 | case WM_INITMENU:
|
|---|
| 1165 | case WM_MENUSELECT:
|
|---|
| 1166 | case WM_MENUEND:
|
|---|
| 1167 | case WM_NEXTMENU:
|
|---|
| 1168 | case WM_SYSCOLORCHANGE:
|
|---|
| 1169 | case WM_SYSVALUECHANGED:
|
|---|
| 1170 | case WM_SETSELECTION:
|
|---|
| 1171 | case WM_PPAINT:
|
|---|
| 1172 | case WM_PSETFOCUS:
|
|---|
| 1173 | case WM_PSYSCOLORCHANGE:
|
|---|
| 1174 | case WM_PSIZE:
|
|---|
| 1175 | case WM_PACTIVATE:
|
|---|
| 1176 | case WM_PCONTROL:
|
|---|
| 1177 | case WM_HELP:
|
|---|
| 1178 | case WM_APPTERMINATENOTIFY:
|
|---|
| 1179 | case WM_PRESPARAMCHANGED:
|
|---|
| 1180 | case WM_DRAWITEM:
|
|---|
| 1181 | case WM_MEASUREITEM:
|
|---|
| 1182 | case WM_CONTROLPOINTER:
|
|---|
| 1183 | case WM_QUERYDLGCODE:
|
|---|
| 1184 | case WM_SUBSTITUTESTRING:
|
|---|
| 1185 | case WM_MATCHMNEMONIC:
|
|---|
| 1186 | case WM_SAVEAPPLICATION:
|
|---|
| 1187 | case WM_SEMANTICEVENT:
|
|---|
| 1188 | default:
|
|---|
| 1189 | dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
|
|---|
| 1190 | goto RunDefWndProc;
|
|---|
| 1191 | }
|
|---|
| 1192 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 1193 | RestoreOS2TIB();
|
|---|
| 1194 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 1195 |
|
|---|
| 1196 | #ifdef DEBUG
|
|---|
| 1197 | dbg_ThreadPopCall();
|
|---|
| 1198 | #endif
|
|---|
| 1199 | return (MRESULT)rc;
|
|---|
| 1200 |
|
|---|
| 1201 | RunDefWndProc:
|
|---|
| 1202 | // dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
|
|---|
| 1203 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 1204 |
|
|---|
| 1205 | RestoreOS2TIB();
|
|---|
| 1206 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 1207 |
|
|---|
| 1208 | #ifdef DEBUG
|
|---|
| 1209 | dbg_ThreadPopCall();
|
|---|
| 1210 | #endif
|
|---|
| 1211 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 1212 | } /* End of Win32WindowProc */
|
|---|
| 1213 | //******************************************************************************
|
|---|
| 1214 | //******************************************************************************
|
|---|
| 1215 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1216 | {
|
|---|
| 1217 | POSTMSG_PACKET *postmsg;
|
|---|
| 1218 | OSLIBPOINT point, ClientPoint;
|
|---|
| 1219 | Win32BaseWindow *win32wnd;
|
|---|
| 1220 | TEB *teb;
|
|---|
| 1221 | MRESULT rc = 0;
|
|---|
| 1222 | MSG winMsg, *pWinMsg;
|
|---|
| 1223 | EXCEPTIONREGISTRATIONRECORD exceptRegRec = {0,0};
|
|---|
| 1224 |
|
|---|
| 1225 | #ifdef DEBUG
|
|---|
| 1226 | dbg_ThreadPushCall("Win32FrameWindowProc");
|
|---|
| 1227 | #endif
|
|---|
| 1228 |
|
|---|
| 1229 | ODIN_SetExceptionHandler(&exceptRegRec);
|
|---|
| 1230 | //Restore our FS selector
|
|---|
| 1231 | SetWin32TIB();
|
|---|
| 1232 |
|
|---|
| 1233 | // BEGIN NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
|
|---|
| 1234 | teb = GetThreadTEB();
|
|---|
| 1235 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
|---|
| 1236 |
|
|---|
| 1237 | // do some sanity checking here:
|
|---|
| 1238 | // - we need to have a TEB handle
|
|---|
| 1239 | // - unless this is WM_CREATE (the very first message), there has to be
|
|---|
| 1240 | // a USER32 window object for this window handle
|
|---|
| 1241 | // - thread must not be suspended in WaitMessage
|
|---|
| 1242 | if(!teb || (msg != WM_CREATE && win32wnd == NULL) || teb->o.odin.fWaitMessageSuspend) {
|
|---|
| 1243 | if(teb && teb->o.odin.fWaitMessageSuspend)
|
|---|
| 1244 | dprintf(("PMFRAME: fWaitMessageSuspend window %x msg %x -> run default frame proc", hwnd, msg));
|
|---|
| 1245 | else dprintf(("PMFRAME: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
|
|---|
| 1246 | goto RunDefFrameWndProc;
|
|---|
| 1247 | }
|
|---|
| 1248 | //// if(teb->o.odin.fIgnoreMsgs) {
|
|---|
| 1249 | //// goto RunDefWndProc;
|
|---|
| 1250 | //// }
|
|---|
| 1251 |
|
|---|
| 1252 | // check if the message state counter in the TEB is odd
|
|---|
| 1253 | // This means the message has been sent directly from PM to our message
|
|---|
| 1254 | // handler (so it is the first time we know about this PM message).
|
|---|
| 1255 | // If this is the case, we have to translate it here to a Win32
|
|---|
| 1256 | // message first. The other case is that the message is the result of a
|
|---|
| 1257 | // WinDispatchMsg call and therefore has already been translated.
|
|---|
| 1258 | if((teb->o.odin.msgstate & 1) == 0)
|
|---|
| 1259 | {//message that was sent directly to our window proc handler; translate it here
|
|---|
| 1260 | QMSG qmsg;
|
|---|
| 1261 |
|
|---|
| 1262 | qmsg.msg = msg;
|
|---|
| 1263 | qmsg.hwnd = hwnd;
|
|---|
| 1264 | qmsg.mp1 = mp1;
|
|---|
| 1265 | qmsg.mp2 = mp2;
|
|---|
| 1266 | qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
|
|---|
| 1267 | WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
|
|---|
| 1268 | qmsg.reserved = 0;
|
|---|
| 1269 |
|
|---|
| 1270 | if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
|
|---|
| 1271 | {//message was not translated
|
|---|
| 1272 | memset(&winMsg, 0, sizeof(MSG));
|
|---|
| 1273 | }
|
|---|
| 1274 | pWinMsg = &winMsg;
|
|---|
| 1275 | }
|
|---|
| 1276 | else {
|
|---|
| 1277 | // message has already been translated before (GetMessage/PeekMessage).
|
|---|
| 1278 | // Use the translated information. Flip the translation flag.
|
|---|
| 1279 | pWinMsg = &teb->o.odin.msg;
|
|---|
| 1280 | teb->o.odin.msgstate++;
|
|---|
| 1281 | }
|
|---|
| 1282 | // END NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
|
|---|
| 1283 |
|
|---|
| 1284 | switch( msg )
|
|---|
| 1285 | {
|
|---|
| 1286 | case WM_CREATE:
|
|---|
| 1287 | {
|
|---|
| 1288 | //WM_CREATE handled during client window creation
|
|---|
| 1289 | dprintf(("PMFRAME: WM_CREATE %x", hwnd));
|
|---|
| 1290 | goto RunDefFrameWndProc;
|
|---|
| 1291 | }
|
|---|
| 1292 |
|
|---|
| 1293 | //hack alert; PM crashes if child calls DestroyWindow for parent/owner in WM_DESTROY
|
|---|
| 1294 | // handler; must postpone it, so do it here
|
|---|
| 1295 | case WIN32APP_POSTPONEDESTROY:
|
|---|
| 1296 | OSLibWinDestroyWindow(hwnd);
|
|---|
| 1297 | break;
|
|---|
| 1298 | //hack end
|
|---|
| 1299 |
|
|---|
| 1300 | #ifdef DEBUG
|
|---|
| 1301 | case WM_CLOSE:
|
|---|
| 1302 | {
|
|---|
| 1303 | dprintf(("PMFRAME: WM_CLOSE %x", hwnd));
|
|---|
| 1304 | goto RunDefFrameWndProc;
|
|---|
| 1305 | }
|
|---|
| 1306 | #endif
|
|---|
| 1307 |
|
|---|
| 1308 | case WM_PAINT:
|
|---|
| 1309 | {
|
|---|
| 1310 | RECTL rectl;
|
|---|
| 1311 | HRGN hrgn;
|
|---|
| 1312 |
|
|---|
| 1313 | hrgn = CreateRectRgn(0, 0, 0, 0);
|
|---|
| 1314 | GetUpdateRgnFrame(win32wnd->getWindowHandle(), hrgn);
|
|---|
| 1315 |
|
|---|
| 1316 | HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
|
|---|
| 1317 | dprintf(("PMFRAME: WM_PAINT %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
|
|---|
| 1318 |
|
|---|
| 1319 | if(win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
|
|---|
| 1320 | rectl.yBottom != rectl.yTop))
|
|---|
| 1321 | {
|
|---|
| 1322 | PRECT pClient = win32wnd->getClientRectPtr();
|
|---|
| 1323 | PRECT pWindow = win32wnd->getWindowRect();
|
|---|
| 1324 |
|
|---|
| 1325 | if(!(pClient->left == 0 && pClient->top == 0 &&
|
|---|
| 1326 | win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
|
|---|
| 1327 | win32wnd->getClientWidth() == win32wnd->getWindowWidth()))
|
|---|
| 1328 | {
|
|---|
| 1329 | RECT rectUpdate;
|
|---|
| 1330 |
|
|---|
| 1331 | mapOS2ToWin32Rect(win32wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
|
|---|
| 1332 | win32wnd->MsgNCPaint(&rectUpdate, hrgn);
|
|---|
| 1333 | }
|
|---|
| 1334 | }
|
|---|
| 1335 | WinEndPaint(hps);
|
|---|
| 1336 |
|
|---|
| 1337 | DeleteObject(hrgn);
|
|---|
| 1338 | break;
|
|---|
| 1339 | }
|
|---|
| 1340 |
|
|---|
| 1341 | case WM_ERASEBACKGROUND:
|
|---|
| 1342 | {
|
|---|
| 1343 | dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
|
|---|
| 1344 | rc = (MRESULT)FALSE;
|
|---|
| 1345 | break;
|
|---|
| 1346 | }
|
|---|
| 1347 |
|
|---|
| 1348 | //**************************************************************************
|
|---|
| 1349 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
|---|
| 1350 | //**************************************************************************
|
|---|
| 1351 |
|
|---|
| 1352 | case WM_BUTTON1DOWN:
|
|---|
| 1353 | case WM_BUTTON1UP:
|
|---|
| 1354 | case WM_BUTTON1DBLCLK:
|
|---|
| 1355 | case WM_BUTTON2DOWN:
|
|---|
| 1356 | case WM_BUTTON2UP:
|
|---|
| 1357 | case WM_BUTTON2DBLCLK:
|
|---|
| 1358 | case WM_BUTTON3DOWN:
|
|---|
| 1359 | case WM_BUTTON3UP:
|
|---|
| 1360 | case WM_BUTTON3DBLCLK:
|
|---|
| 1361 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 1362 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 1363 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 1364 | }
|
|---|
| 1365 | if(win32wnd)
|
|---|
| 1366 | win32wnd->MsgButton(pWinMsg);
|
|---|
| 1367 |
|
|---|
| 1368 | rc = (MRESULT)TRUE;
|
|---|
| 1369 | break;
|
|---|
| 1370 |
|
|---|
| 1371 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 1372 | case WM_BUTTON2MOTIONEND:
|
|---|
| 1373 | case WM_BUTTON2CLICK:
|
|---|
| 1374 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 1375 | case WM_BUTTON1MOTIONEND:
|
|---|
| 1376 | case WM_BUTTON1CLICK:
|
|---|
| 1377 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 1378 | case WM_BUTTON3MOTIONEND:
|
|---|
| 1379 | case WM_BUTTON3CLICK:
|
|---|
| 1380 | rc = (MRESULT)TRUE;
|
|---|
| 1381 | break;
|
|---|
| 1382 |
|
|---|
| 1383 | case WM_MOUSEMOVE:
|
|---|
| 1384 | {
|
|---|
| 1385 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 1386 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 1387 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 1388 | }
|
|---|
| 1389 | if(win32wnd)
|
|---|
| 1390 | win32wnd->MsgMouseMove(pWinMsg);
|
|---|
| 1391 | break;
|
|---|
| 1392 | }
|
|---|
| 1393 |
|
|---|
| 1394 | case WM_CHAR_SPECIAL_CONSOLE_BREAK:
|
|---|
| 1395 | {
|
|---|
| 1396 | //ignore this message. don't forward it to the default PM frame window handler
|
|---|
| 1397 | //as that one sends it to the client. as a result we end up translating
|
|---|
| 1398 | //it twice
|
|---|
| 1399 | break;
|
|---|
| 1400 | }
|
|---|
| 1401 |
|
|---|
| 1402 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 1403 | {
|
|---|
| 1404 | PSWP pswp = (PSWP)mp1;
|
|---|
| 1405 | SWP swpOld;
|
|---|
| 1406 | WINDOWPOS wp,wpOld;
|
|---|
| 1407 | ULONG ulFlags;
|
|---|
| 1408 | ULONG ret = 0;
|
|---|
| 1409 | HWND hParent = NULLHANDLE, hwndAfter;
|
|---|
| 1410 |
|
|---|
| 1411 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1412 |
|
|---|
| 1413 | ulFlags = pswp->fl;
|
|---|
| 1414 |
|
|---|
| 1415 | if(win32wnd->IsParentChanging()) {
|
|---|
| 1416 | rc = 0;
|
|---|
| 1417 | break;
|
|---|
| 1418 | }
|
|---|
| 1419 |
|
|---|
| 1420 | //@@PF all commands from minimized window viewer or from Ctrl-Esc
|
|---|
| 1421 | //are 'pure' and should be handled only by DeFrameProc - this is weird
|
|---|
| 1422 | //but without them we will not have results. Pure = plain flag of restore/minimize/maximize
|
|---|
| 1423 | if((pswp->fl == SWP_MINIMIZE) || (pswp->fl & SWP_RESTORE)) {
|
|---|
| 1424 | // note the purity of SWP no other SWP_FLAGS allowed
|
|---|
| 1425 | goto RunDefFrameWndProc;
|
|---|
| 1426 | }
|
|---|
| 1427 |
|
|---|
| 1428 | if(pswp->fl & SWP_NOADJUST) {
|
|---|
| 1429 | //ignore weird messages (TODO: why are they sent?)
|
|---|
| 1430 | dprintf(("WARNING: WM_ADJUSTWINDOWPOS with SWP_NOADJUST flag!!"));
|
|---|
| 1431 | break;
|
|---|
| 1432 |
|
|---|
| 1433 | }
|
|---|
| 1434 |
|
|---|
| 1435 | //PF Pure flags should not cause any subsequent messages to win32 windows
|
|---|
| 1436 | //we should route them to DefFrameWndProc and check highlight.
|
|---|
| 1437 |
|
|---|
| 1438 | if ((pswp->fl == SWP_FOCUSACTIVATE) || (pswp->fl == SWP_FOCUSDEACTIVATE))
|
|---|
| 1439 | {
|
|---|
| 1440 | if (fOS2Look)
|
|---|
| 1441 | {
|
|---|
| 1442 | if(pswp->fl == SWP_FOCUSACTIVATE)
|
|---|
| 1443 | {
|
|---|
| 1444 | dprintf2(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1445 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, (MPARAM)1, 0);
|
|---|
| 1446 | }
|
|---|
| 1447 | else
|
|---|
| 1448 | {
|
|---|
| 1449 | dprintf2(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1450 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, 0, 0);
|
|---|
| 1451 | }
|
|---|
| 1452 | }
|
|---|
| 1453 | goto RunDefFrameWndProc;
|
|---|
| 1454 | }
|
|---|
| 1455 |
|
|---|
| 1456 | //CB: show dialog in front of owner
|
|---|
| 1457 | if (win32wnd->IsModalDialogOwner())
|
|---|
| 1458 | {
|
|---|
| 1459 | dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
|
|---|
| 1460 | pswp->fl |= SWP_ZORDER;
|
|---|
| 1461 | pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
|
|---|
| 1462 | if (pswp->fl & SWP_ACTIVATE)
|
|---|
| 1463 | {
|
|---|
| 1464 | pswp->fl &= ~SWP_ACTIVATE;
|
|---|
| 1465 | WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
|
|---|
| 1466 | }
|
|---|
| 1467 | }
|
|---|
| 1468 |
|
|---|
| 1469 | if(!win32wnd->CanReceiveSizeMsgs())
|
|---|
| 1470 | break;
|
|---|
| 1471 |
|
|---|
| 1472 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 1473 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 1474 | if (win32wnd->isChild()) {
|
|---|
| 1475 | if(win32wnd->getParent()) {
|
|---|
| 1476 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 1477 | }
|
|---|
| 1478 | else goto RunDefFrameWndProc;
|
|---|
| 1479 | }
|
|---|
| 1480 | }
|
|---|
| 1481 | hwndAfter = pswp->hwndInsertBehind;
|
|---|
| 1482 | if(win32wnd->getParent()) {
|
|---|
| 1483 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(), hwnd);
|
|---|
| 1484 | }
|
|---|
| 1485 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
|---|
| 1486 |
|
|---|
| 1487 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 1488 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 1489 | {
|
|---|
| 1490 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 1491 | dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
|
|---|
| 1492 | if(wndAfter) {
|
|---|
| 1493 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 1494 | RELEASE_WNDOBJ(wndAfter);
|
|---|
| 1495 | }
|
|---|
| 1496 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 1497 | }
|
|---|
| 1498 |
|
|---|
| 1499 | wpOld = wp;
|
|---|
| 1500 | win32wnd->MsgPosChanging((LPARAM)&wp);
|
|---|
| 1501 |
|
|---|
| 1502 | if(win32wnd->getOldStyle() != win32wnd->getStyle())
|
|---|
| 1503 | {
|
|---|
| 1504 | OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), win32wnd->getStyle(), win32wnd->getExStyle(), win32wnd->getStyle());
|
|---|
| 1505 | if(fOS2Look) {
|
|---|
| 1506 | DWORD dwOldStyle = win32wnd->getOldStyle();
|
|---|
| 1507 | DWORD dwStyle = win32wnd->getStyle();
|
|---|
| 1508 |
|
|---|
| 1509 | win32wnd->setOldStyle(dwStyle);
|
|---|
| 1510 | if((dwOldStyle & WS_MINIMIZE_W) && !(dwStyle & WS_MINIMIZE_W)) {
|
|---|
| 1511 | //SC_RESTORE -> SC_MINIMIZE
|
|---|
| 1512 | dprintf(("%x -> SC_RESTORE -> SC_MINIMIZE", win32wnd->getWindowHandle()));
|
|---|
| 1513 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_RESTORE, SC_MINIMIZE, hbmFrameMenu[PMMENU_MINBUTTON]);
|
|---|
| 1514 | if(dwStyle & WS_MAXIMIZE_W) {
|
|---|
| 1515 | //SC_MAXIMIZE -> SC_RESTORE
|
|---|
| 1516 | dprintf(("%x -> SC_MAXIMIZE -> SC_RESTORE (1)", win32wnd->getWindowHandle()));
|
|---|
| 1517 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
|---|
| 1518 | }
|
|---|
| 1519 | }
|
|---|
| 1520 | else
|
|---|
| 1521 | if((dwOldStyle & WS_MAXIMIZE_W) && !(dwStyle & WS_MAXIMIZE_W)) {
|
|---|
| 1522 | //SC_RESTORE -> SC_MAXIMIZE
|
|---|
| 1523 | dprintf(("%x -> SC_RESTORE -> SC_MAXIMIZE", win32wnd->getWindowHandle()));
|
|---|
| 1524 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_RESTORE, SC_MAXIMIZE, hbmFrameMenu[PMMENU_MAXBUTTON]);
|
|---|
| 1525 | }
|
|---|
| 1526 | else
|
|---|
| 1527 | if(!(dwOldStyle & WS_MINIMIZE_W) && (dwStyle & WS_MINIMIZE_W)) {
|
|---|
| 1528 | //SC_MINIMIZE -> SC_RESTORE
|
|---|
| 1529 | dprintf(("%x -> SC_MINIMIZE -> SC_RESTORE", win32wnd->getWindowHandle()));
|
|---|
| 1530 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), 0, SC_MINIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
|---|
| 1531 | }
|
|---|
| 1532 | else
|
|---|
| 1533 | if(!(dwOldStyle & WS_MAXIMIZE_W) && (dwStyle & WS_MAXIMIZE_W)) {
|
|---|
| 1534 | //SC_MAXIMIZE -> SC_RESTORE
|
|---|
| 1535 | dprintf(("%x -> SC_MAXIMIZE -> SC_RESTORE (2)", win32wnd->getWindowHandle()));
|
|---|
| 1536 | FrameReplaceMenuItem(WinWindowFromID(hwnd, FID_MINMAX), MIT_END, SC_MAXIMIZE, SC_RESTORE, hbmFrameMenu[PMMENU_RESTOREBUTTON]);
|
|---|
| 1537 | }
|
|---|
| 1538 | }
|
|---|
| 1539 | }
|
|---|
| 1540 |
|
|---|
| 1541 | if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
|---|
| 1542 | (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
|
|---|
| 1543 | {
|
|---|
| 1544 | ULONG flags = pswp->fl; //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
|
|---|
| 1545 |
|
|---|
| 1546 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 1547 | dprintf(("%x (%s) (%d,%d), (%d,%d)", pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1548 |
|
|---|
| 1549 | if(win32wnd->getParent()) {
|
|---|
| 1550 | OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 1551 | hwnd);
|
|---|
| 1552 | }
|
|---|
| 1553 | else OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
|---|
| 1554 |
|
|---|
| 1555 | dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1556 |
|
|---|
| 1557 | //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
|
|---|
| 1558 | if(pswp->fl & SWP_SIZE)
|
|---|
| 1559 | flags |= SWP_SIZE;
|
|---|
| 1560 |
|
|---|
| 1561 | if(pswp->fl & SWP_MOVE)
|
|---|
| 1562 | flags |= SWP_MOVE;
|
|---|
| 1563 |
|
|---|
| 1564 | pswp->fl = flags; //restore flags
|
|---|
| 1565 |
|
|---|
| 1566 | pswp->fl |= SWP_NOADJUST;
|
|---|
| 1567 | pswp->hwndInsertBehind = hwndAfter;
|
|---|
| 1568 | pswp->hwnd = hwnd;
|
|---|
| 1569 |
|
|---|
| 1570 | ret = 0xf;
|
|---|
| 1571 | }
|
|---|
| 1572 | adjustend:
|
|---|
| 1573 | //The next part needs to be done for top-level windows only
|
|---|
| 1574 | if(!((win32wnd->getStyle() & (WS_POPUP_W|WS_CHILD_W)) == WS_CHILD_W))
|
|---|
| 1575 | {
|
|---|
| 1576 | //Setting these flags is necessary to avoid activation/focus problems
|
|---|
| 1577 | if(ulFlags & SWP_DEACTIVATE) {
|
|---|
| 1578 | ret |= AWP_DEACTIVATE;
|
|---|
| 1579 | }
|
|---|
| 1580 | if(ulFlags & SWP_ACTIVATE)
|
|---|
| 1581 | {
|
|---|
| 1582 | if(ulFlags & SWP_ZORDER) {
|
|---|
| 1583 | dprintf(("Set FF_NOACTIVATESWP"));
|
|---|
| 1584 | ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
|
|---|
| 1585 | WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags | FF_NOACTIVATESWP);
|
|---|
| 1586 | }
|
|---|
| 1587 |
|
|---|
| 1588 | if(!(ulFlags & SWP_SHOW))
|
|---|
| 1589 | {
|
|---|
| 1590 | ret |= AWP_ACTIVATE;
|
|---|
| 1591 | }
|
|---|
| 1592 | else
|
|---|
| 1593 | {
|
|---|
| 1594 | FrameSetFocus(hwnd);
|
|---|
| 1595 | }
|
|---|
| 1596 | }
|
|---|
| 1597 | }
|
|---|
| 1598 | else {
|
|---|
| 1599 | if(ulFlags & (SWP_ACTIVATE|SWP_FOCUSACTIVATE))
|
|---|
| 1600 | {
|
|---|
| 1601 | win32wnd->MsgChildActivate(TRUE);
|
|---|
| 1602 | if(fOS2Look) {
|
|---|
| 1603 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1604 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, (MPARAM)1, 0);
|
|---|
| 1605 | }
|
|---|
| 1606 | }
|
|---|
| 1607 | else
|
|---|
| 1608 | if(ulFlags & (SWP_DEACTIVATE|SWP_FOCUSDEACTIVATE))
|
|---|
| 1609 | {
|
|---|
| 1610 | win32wnd->MsgChildActivate(FALSE);
|
|---|
| 1611 | if(fOS2Look) {
|
|---|
| 1612 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1613 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, 0, 0);
|
|---|
| 1614 | }
|
|---|
| 1615 | }
|
|---|
| 1616 | }
|
|---|
| 1617 | #ifdef DEBUG
|
|---|
| 1618 | dprintf(("WM_ADJUSTWINDOWPOS ret %x flags %x", ret, WinQueryWindowUShort(hwnd, QWS_FLAGS)));
|
|---|
| 1619 | if(ret == 0x0f) {
|
|---|
| 1620 | dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
|
|---|
| 1621 | dprintf(("%x (%s) (%d,%d), (%d,%d)", pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 1622 | }
|
|---|
| 1623 | #endif
|
|---|
| 1624 | rc = (MRESULT)ret;
|
|---|
| 1625 | break;
|
|---|
| 1626 | }
|
|---|
| 1627 |
|
|---|
| 1628 | case WM_WINDOWPOSCHANGED:
|
|---|
| 1629 | {
|
|---|
| 1630 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
|---|
| 1631 | SWP swpOld = *(pswp + 1);
|
|---|
| 1632 | WINDOWPOS wp;
|
|---|
| 1633 | ULONG flAfp = (ULONG)mp2;
|
|---|
| 1634 | HWND hParent = NULLHANDLE;
|
|---|
| 1635 | RECTL rect;
|
|---|
| 1636 |
|
|---|
| 1637 | dprintf(("PMFRAME:WM_WINDOWPOSCHANGED (%x) %x %x (%s) (%d,%d) (%d,%d) z %x", mp2, win32wnd->getWindowHandle(), pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy, Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind)));
|
|---|
| 1638 | if(win32wnd->IsParentChanging()) {
|
|---|
| 1639 | goto PosChangedEnd;
|
|---|
| 1640 | }
|
|---|
| 1641 |
|
|---|
| 1642 | // PF: MDI window is not a common OS/2 frame window so we just skipped all
|
|---|
| 1643 | // PM default processing for it that basicly moved this window to 0,0 point
|
|---|
| 1644 | // and changed frame controls. Now do our own processing.
|
|---|
| 1645 |
|
|---|
| 1646 | if ((pswp->fl & SWP_MAXIMIZE) && (win32wnd->getExStyle() & WS_EX_MDICHILD_W))
|
|---|
| 1647 | {
|
|---|
| 1648 | SendMessageA(win32wnd->getWindowHandle(), WM_SYSCOMMAND_W, SC_MAXIMIZE_W, 0);
|
|---|
| 1649 | goto PosChangedEnd;
|
|---|
| 1650 | }
|
|---|
| 1651 |
|
|---|
| 1652 | //SvL: When a window is made visible, then we don't receive a
|
|---|
| 1653 | // WM_VRNENABLED message (for some weird reason)
|
|---|
| 1654 | if(pswp->fl & SWP_SHOW) {
|
|---|
| 1655 | win32wnd->callVisibleRgnNotifyProc(TRUE);
|
|---|
| 1656 | }
|
|---|
| 1657 | else
|
|---|
| 1658 | if(pswp->fl & SWP_HIDE) {
|
|---|
| 1659 | win32wnd->callVisibleRgnNotifyProc(FALSE);
|
|---|
| 1660 | }
|
|---|
| 1661 |
|
|---|
| 1662 | if(pswp->fl & (SWP_MOVE | SWP_SIZE))
|
|---|
| 1663 | {
|
|---|
| 1664 | if(win32wnd->isChild())
|
|---|
| 1665 | {
|
|---|
| 1666 | if(win32wnd->getParent()) {
|
|---|
| 1667 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 1668 | }
|
|---|
| 1669 | else goto PosChangedEnd; //parent has just been destroyed
|
|---|
| 1670 | }
|
|---|
| 1671 | }
|
|---|
| 1672 |
|
|---|
| 1673 |
|
|---|
| 1674 | if(win32wnd->getParent()) {
|
|---|
| 1675 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 1676 | hwnd);
|
|---|
| 1677 | }
|
|---|
| 1678 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
|---|
| 1679 |
|
|---|
| 1680 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 1681 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 1682 | {
|
|---|
| 1683 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 1684 | dprintf2(("SWP_ZORDER: %x %x", pswp->hwndInsertBehind, (wndAfter) ? wndAfter->getWindowHandle() : 0));
|
|---|
| 1685 | if(wndAfter) {
|
|---|
| 1686 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 1687 | RELEASE_WNDOBJ(wndAfter);
|
|---|
| 1688 | }
|
|---|
| 1689 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 1690 | }
|
|---|
| 1691 |
|
|---|
| 1692 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
|
|---|
| 1693 | {
|
|---|
| 1694 | if(pswp->fl & SWP_RESTORE && win32wnd->getStyle() & WS_MINIMIZE_W) {
|
|---|
| 1695 | dprintf(("Restoring minimized window %x", win32wnd->getWindowHandle()));
|
|---|
| 1696 | win32wnd->ShowWindow(SW_RESTORE_W);
|
|---|
| 1697 | }
|
|---|
| 1698 | if(pswp->fl & SWP_SHOW) {
|
|---|
| 1699 | WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
|
|---|
| 1700 | }
|
|---|
| 1701 | else
|
|---|
| 1702 | if(pswp->fl & SWP_HIDE) {
|
|---|
| 1703 | WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
|
|---|
| 1704 | }
|
|---|
| 1705 | if(pswp->fl & (SWP_SHOW|SWP_HIDE))
|
|---|
| 1706 | {//TODO: necessary for more options? (activate?)
|
|---|
| 1707 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 1708 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 1709 | }
|
|---|
| 1710 |
|
|---|
| 1711 | //MUST call the old frame window proc!
|
|---|
| 1712 | goto RunDefFrameWndProc;
|
|---|
| 1713 | }
|
|---|
| 1714 |
|
|---|
| 1715 | if(pswp->fl & SWP_SHOW) {
|
|---|
| 1716 | WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
|
|---|
| 1717 | }
|
|---|
| 1718 | else
|
|---|
| 1719 | if(pswp->fl & SWP_HIDE) {
|
|---|
| 1720 | WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
|
|---|
| 1721 | }
|
|---|
| 1722 |
|
|---|
| 1723 | if(flAfp & AWP_ACTIVATE)
|
|---|
| 1724 | {
|
|---|
| 1725 | FrameSetFocus(hwnd);
|
|---|
| 1726 | }
|
|---|
| 1727 |
|
|---|
| 1728 | #ifndef USE_CALCVALIDRECT
|
|---|
| 1729 | if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
|
|---|
| 1730 | {
|
|---|
| 1731 | //CB: todo: use result for WM_CALCVALIDRECTS
|
|---|
| 1732 | //Get old client rectangle (for invalidation of frame window parts later on)
|
|---|
| 1733 | //Use new window height to calculate the client area
|
|---|
| 1734 | mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
|
|---|
| 1735 |
|
|---|
| 1736 | //Note: Also updates the new window rectangle
|
|---|
| 1737 | win32wnd->MsgFormatFrame(&wp);
|
|---|
| 1738 |
|
|---|
| 1739 | if(win32wnd->isOwnDC()) {
|
|---|
| 1740 | setPageXForm(win32wnd, (pDCData)GpiQueryDCData(win32wnd->getOwnDC()));
|
|---|
| 1741 | }
|
|---|
| 1742 |
|
|---|
| 1743 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 1744 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 1745 |
|
|---|
| 1746 | if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
|
|---|
| 1747 | {
|
|---|
| 1748 | //redraw the frame (to prevent unnecessary client updates)
|
|---|
| 1749 | BOOL redrawAll = FALSE;
|
|---|
| 1750 |
|
|---|
| 1751 | dprintf2(("WM_WINDOWPOSCHANGED: redraw frame"));
|
|---|
| 1752 | if (win32wnd->getWindowClass())
|
|---|
| 1753 | {
|
|---|
| 1754 | DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
|
|---|
| 1755 |
|
|---|
| 1756 | if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
|
|---|
| 1757 | redrawAll = TRUE;
|
|---|
| 1758 | else
|
|---|
| 1759 | if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
|
|---|
| 1760 | redrawAll = TRUE;
|
|---|
| 1761 | }
|
|---|
| 1762 | else redrawAll = TRUE;
|
|---|
| 1763 |
|
|---|
| 1764 | if(win32wnd->IsMixMaxStateChanging()) {
|
|---|
| 1765 | dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
|
|---|
| 1766 | redrawAll = TRUE;
|
|---|
| 1767 | }
|
|---|
| 1768 |
|
|---|
| 1769 | if (redrawAll)
|
|---|
| 1770 | {
|
|---|
| 1771 | //CB: redraw all children for now
|
|---|
| 1772 | // -> problems with update region if we don't do it
|
|---|
| 1773 | // todo: rewrite whole handling
|
|---|
| 1774 | dprintf(("PMFRAME: WM_WINDOWPOSCHANGED invalidate all"));
|
|---|
| 1775 | WinInvalidateRect(hwnd,NULL,TRUE);
|
|---|
| 1776 | }
|
|---|
| 1777 | else
|
|---|
| 1778 | {
|
|---|
| 1779 | HPS hps = WinGetPS(hwnd);
|
|---|
| 1780 | RECTL frame,client,arcl[4];
|
|---|
| 1781 |
|
|---|
| 1782 | WinQueryWindowRect(hwnd,&frame);
|
|---|
| 1783 |
|
|---|
| 1784 | //top
|
|---|
| 1785 | arcl[0].xLeft = 0;
|
|---|
| 1786 | arcl[0].xRight = frame.xRight;
|
|---|
| 1787 | arcl[0].yBottom = rect.yTop;
|
|---|
| 1788 | arcl[0].yTop = frame.yTop;
|
|---|
| 1789 | //right
|
|---|
| 1790 | arcl[1].xLeft = rect.xRight;
|
|---|
| 1791 | arcl[1].xRight = frame.xRight;
|
|---|
| 1792 | arcl[1].yBottom = 0;
|
|---|
| 1793 | arcl[1].yTop = frame.yTop;
|
|---|
| 1794 | //left
|
|---|
| 1795 | arcl[2].xLeft = 0;
|
|---|
| 1796 | arcl[2].xRight = rect.xLeft;
|
|---|
| 1797 | arcl[2].yBottom = 0;
|
|---|
| 1798 | arcl[2].yTop = frame.yTop;
|
|---|
| 1799 | //bottom
|
|---|
| 1800 | arcl[3].xLeft = 0;
|
|---|
| 1801 | arcl[3].xRight = frame.xRight;
|
|---|
| 1802 | arcl[3].yBottom = 0;
|
|---|
| 1803 | arcl[3].yTop = rect.yBottom;
|
|---|
| 1804 |
|
|---|
| 1805 | HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
|
|---|
| 1806 |
|
|---|
| 1807 | WinInvalidateRegion(hwnd,hrgn,FALSE);
|
|---|
| 1808 | GpiDestroyRegion(hps,hrgn);
|
|---|
| 1809 | WinReleasePS(hps);
|
|---|
| 1810 | }
|
|---|
| 1811 | }
|
|---|
| 1812 | }
|
|---|
| 1813 | else
|
|---|
| 1814 | {
|
|---|
| 1815 | #endif //USE_CALCVALIDRECT
|
|---|
| 1816 | if(win32wnd->CanReceiveSizeMsgs())
|
|---|
| 1817 | win32wnd->MsgPosChanged((LPARAM)&wp);
|
|---|
| 1818 | #ifndef USE_CALCVALIDRECT
|
|---|
| 1819 | }
|
|---|
| 1820 | #endif
|
|---|
| 1821 | //PF This is the final step of PM restoration - should end up
|
|---|
| 1822 | //in default handler.
|
|---|
| 1823 | if (win32wnd->getOldStyle() & WS_MINIMIZE_W && pswp->fl & SWP_RESTORE)
|
|---|
| 1824 | goto RunDefFrameWndProc;
|
|---|
| 1825 |
|
|---|
| 1826 | //PF This is the final step of PM minimization - shoukd end up
|
|---|
| 1827 | //in default handler
|
|---|
| 1828 | if (win32wnd->getStyle() & WS_MINIMIZE_W && pswp->fl & SWP_MINIMIZE)
|
|---|
| 1829 | goto RunDefFrameWndProc;
|
|---|
| 1830 |
|
|---|
| 1831 | PosChangedEnd:
|
|---|
| 1832 | rc = (MRESULT)FALSE;
|
|---|
| 1833 | break;
|
|---|
| 1834 | }
|
|---|
| 1835 |
|
|---|
| 1836 | case WM_CALCVALIDRECTS:
|
|---|
| 1837 | #ifdef USE_CALCVALIDRECT
|
|---|
| 1838 | {
|
|---|
| 1839 | PRECTL oldRect = (PRECTL)mp1, newRect = oldRect+1;
|
|---|
| 1840 | PSWP pswp = (PSWP)mp2;
|
|---|
| 1841 | SWP swpOld;
|
|---|
| 1842 | WINDOWPOS wp;
|
|---|
| 1843 | RECTL newClientRect, oldClientRect;
|
|---|
| 1844 | ULONG nccalcret;
|
|---|
| 1845 | // UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
|
|---|
| 1846 | UINT res = 0;
|
|---|
| 1847 |
|
|---|
| 1848 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 1849 |
|
|---|
| 1850 | //Get old position info
|
|---|
| 1851 | WinQueryWindowPos(hwnd, &swpOld);
|
|---|
| 1852 |
|
|---|
| 1853 | if(win32wnd->getParent()) {
|
|---|
| 1854 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 1855 | win32wnd->getParent()->getClientRectPtr()->left,
|
|---|
| 1856 | win32wnd->getParent()->getClientRectPtr()->top,
|
|---|
| 1857 | hwnd);
|
|---|
| 1858 | }
|
|---|
| 1859 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
|
|---|
| 1860 |
|
|---|
| 1861 | wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 1862 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 1863 | {
|
|---|
| 1864 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 1865 | if(wndAfter) {
|
|---|
| 1866 | wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 1867 | RELEASE_WNDOBJ(wndAfter);
|
|---|
| 1868 | }
|
|---|
| 1869 | else wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 1870 | }
|
|---|
| 1871 |
|
|---|
| 1872 | //Get old client rectangle
|
|---|
| 1873 | mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
|
|---|
| 1874 |
|
|---|
| 1875 | //Note: Also updates the new window rectangle
|
|---|
| 1876 | nccalcret = win32wnd->MsgFormatFrame(&wp);
|
|---|
| 1877 |
|
|---|
| 1878 | //Get new client rectangle
|
|---|
| 1879 | mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
|
|---|
| 1880 |
|
|---|
| 1881 | if(nccalcret == 0) {
|
|---|
| 1882 | res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
|
|---|
| 1883 | }
|
|---|
| 1884 | else {
|
|---|
| 1885 | if(nccalcret & WVR_ALIGNTOP_W) {
|
|---|
| 1886 | res |= CVR_ALIGNTOP;
|
|---|
| 1887 | }
|
|---|
| 1888 | else
|
|---|
| 1889 | if(nccalcret & WVR_ALIGNBOTTOM_W) {
|
|---|
| 1890 | res |= CVR_ALIGNBOTTOM;
|
|---|
| 1891 | }
|
|---|
| 1892 |
|
|---|
| 1893 | if(nccalcret & WVR_ALIGNLEFT_W) {
|
|---|
| 1894 | res |= CVR_ALIGNLEFT;
|
|---|
| 1895 | }
|
|---|
| 1896 | else
|
|---|
| 1897 | if(nccalcret & WVR_ALIGNRIGHT_W) {
|
|---|
| 1898 | res |= CVR_ALIGNRIGHT;
|
|---|
| 1899 | }
|
|---|
| 1900 |
|
|---|
| 1901 | if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
|
|---|
| 1902 | res |= CVR_REDRAW;
|
|---|
| 1903 | }
|
|---|
| 1904 | else
|
|---|
| 1905 | if(nccalcret & WVR_VALIDRECTS_W) {
|
|---|
| 1906 | //TODO:
|
|---|
| 1907 | //res = 0;
|
|---|
| 1908 | }
|
|---|
| 1909 | }
|
|---|
| 1910 | if(win32wnd->IsMixMaxStateChanging()) {
|
|---|
| 1911 | dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
|
|---|
| 1912 | res |= CVR_REDRAW;
|
|---|
| 1913 | }
|
|---|
| 1914 | if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
|
|---|
| 1915 | oldRect->xRight -= oldClientRect.xLeft;
|
|---|
| 1916 | oldRect->yBottom += oldClientRect.yBottom;
|
|---|
| 1917 | newRect->xRight -= newClientRect.xLeft;
|
|---|
| 1918 | newRect->yBottom += newClientRect.yBottom;
|
|---|
| 1919 | }
|
|---|
| 1920 | rc = res;
|
|---|
| 1921 | break;
|
|---|
| 1922 | }
|
|---|
| 1923 | #else
|
|---|
| 1924 | dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
|
|---|
| 1925 | rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
|
|---|
| 1926 | break;
|
|---|
| 1927 | #endif
|
|---|
| 1928 |
|
|---|
| 1929 | case WM_CALCFRAMERECT:
|
|---|
| 1930 | dprintf(("PMFRAME:WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
|
|---|
| 1931 | rc = (MRESULT)TRUE;
|
|---|
| 1932 | break;
|
|---|
| 1933 |
|
|---|
| 1934 | case WM_QUERYCTLTYPE:
|
|---|
| 1935 | // This is a frame window
|
|---|
| 1936 | dprintf(("PMFRAME:WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
|
|---|
| 1937 | rc = (MRESULT)CCT_FRAME;
|
|---|
| 1938 | break;
|
|---|
| 1939 |
|
|---|
| 1940 | #ifdef DEBUG
|
|---|
| 1941 | case WM_QUERYFOCUSCHAIN:
|
|---|
| 1942 | dprintf2(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x (%s) parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), DbgPrintQFCFlags(SHORT1FROMMP(mp1)), (mp2) ? OS2ToWin32Handle((DWORD)mp2) : 0));
|
|---|
| 1943 |
|
|---|
| 1944 | RestoreOS2TIB();
|
|---|
| 1945 | rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 1946 | SetWin32TIB();
|
|---|
| 1947 | dprintf2(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x returned %x (%x)", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), (mp2) ? OS2ToWin32Handle((DWORD)mp2) : 0, (rc) ? OS2ToWin32Handle((DWORD)rc) : 0, rc));
|
|---|
| 1948 | break;
|
|---|
| 1949 | // goto RunDefFrameWndProc;
|
|---|
| 1950 | #endif
|
|---|
| 1951 |
|
|---|
| 1952 | case WM_FOCUSCHANGE:
|
|---|
| 1953 | {
|
|---|
| 1954 | HWND hwndFocus = (HWND)mp1;
|
|---|
| 1955 | HWND hwndLoseFocus, hwndGainFocus;
|
|---|
| 1956 | USHORT usSetFocus = SHORT1FROMMP(mp2);
|
|---|
| 1957 | USHORT fsFocusChange = SHORT2FROMMP(mp2);
|
|---|
| 1958 |
|
|---|
| 1959 | //Save window that gains focus so we can determine which
|
|---|
| 1960 | //process we lose activation to
|
|---|
| 1961 | hwndFocusChange = (HWND)mp1;
|
|---|
| 1962 |
|
|---|
| 1963 | dprintf(("PMFRAME:WM_FOCUSCHANGE %x %x (%x) %x %x", win32wnd->getWindowHandle(), OS2ToWin32Handle(hwndFocus), hwndFocus, usSetFocus, fsFocusChange));
|
|---|
| 1964 | goto RunDefFrameWndProc;
|
|---|
| 1965 | }
|
|---|
| 1966 |
|
|---|
| 1967 | #ifdef DEBUG
|
|---|
| 1968 | case WM_SETFOCUS:
|
|---|
| 1969 | {
|
|---|
| 1970 | dprintf(("PMFRAME: WM_SETFOCUS %x %x %d -> %x", win32wnd->getWindowHandle(), hwnd, mp2, mp1));
|
|---|
| 1971 | goto RunDefFrameWndProc;
|
|---|
| 1972 | }
|
|---|
| 1973 | #endif
|
|---|
| 1974 |
|
|---|
| 1975 | case WM_ACTIVATE:
|
|---|
| 1976 | {
|
|---|
| 1977 | HWND hwndTitle;
|
|---|
| 1978 | USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
|
|---|
| 1979 |
|
|---|
| 1980 | dprintf(("PMFRAME: WM_ACTIVATE %x %x %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle((DWORD)mp2)));
|
|---|
| 1981 | if (win32wnd->IsWindowCreated())
|
|---|
| 1982 | {
|
|---|
| 1983 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 1984 | if(fOS2Look) {
|
|---|
| 1985 | dprintf(("TBM_QUERYHILITE returned %d", WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_QUERYHILITE, 0, 0)));
|
|---|
| 1986 | WinSendDlgItemMsg(hwnd, FID_TITLEBAR, TBM_SETHILITE, mp1, 0);
|
|---|
| 1987 | }
|
|---|
| 1988 | if(SHORT1FROMMP(mp1) == 0) {
|
|---|
| 1989 | //deactivate
|
|---|
| 1990 | WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
|
|---|
| 1991 | }
|
|---|
| 1992 | PID pidThis, pidPartner, pidTemp;
|
|---|
| 1993 | TID tidPartner;
|
|---|
| 1994 | HENUM henum;
|
|---|
| 1995 | HWND hwndEnum;
|
|---|
| 1996 |
|
|---|
| 1997 | WinQueryWindowProcess(hwnd, &pidThis, NULL);
|
|---|
| 1998 | WinQueryWindowProcess(hwndFocusChange, &pidPartner, &tidPartner);
|
|---|
| 1999 |
|
|---|
| 2000 | if(pidThis != pidPartner) {
|
|---|
| 2001 | //Gain or lose activation to window in other process
|
|---|
| 2002 | //must send WM_ACTIVATEAPP to top-level windows
|
|---|
| 2003 |
|
|---|
| 2004 | //Iterate over all child windows of the desktop
|
|---|
| 2005 | henum = WinBeginEnumWindows(HWND_DESKTOP);
|
|---|
| 2006 |
|
|---|
| 2007 | while(hwndEnum = WinGetNextWindow(henum))
|
|---|
| 2008 | {
|
|---|
| 2009 | WinQueryWindowProcess(hwndEnum, &pidTemp, NULL);
|
|---|
| 2010 | if(pidTemp == pidThis)
|
|---|
| 2011 | {
|
|---|
| 2012 | SendMessageA(OS2ToWin32Handle(hwndEnum), WM_ACTIVATEAPP_W, (WPARAM)SHORT1FROMMP(mp1), (LPARAM)tidPartner);
|
|---|
| 2013 | }
|
|---|
| 2014 | }
|
|---|
| 2015 | WinEndEnumWindows(henum);
|
|---|
| 2016 | }
|
|---|
| 2017 | if(SHORT1FROMMP(mp1)) {
|
|---|
| 2018 | //activate
|
|---|
| 2019 | WinSendDlgItemMsg(hwnd, FID_CLIENT, WM_ACTIVATE, mp1, mp2);
|
|---|
| 2020 | }
|
|---|
| 2021 |
|
|---|
| 2022 | //CB: show owner behind the dialog
|
|---|
| 2023 | if (win32wnd->IsModalDialog())
|
|---|
| 2024 | {
|
|---|
| 2025 | if(win32wnd->getOwner()) {
|
|---|
| 2026 | Win32BaseWindow *topOwner = Win32BaseWindow::GetWindowFromHandle(win32wnd->getOwner()->GetTopParent());
|
|---|
| 2027 |
|
|---|
| 2028 | if (topOwner) {
|
|---|
| 2029 | WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
|
|---|
| 2030 | RELEASE_WNDOBJ(topOwner);
|
|---|
| 2031 | }
|
|---|
| 2032 | }
|
|---|
| 2033 | }
|
|---|
| 2034 | }
|
|---|
| 2035 | else
|
|---|
| 2036 | {
|
|---|
| 2037 | WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
|
|---|
| 2038 | }
|
|---|
| 2039 | rc = 0;
|
|---|
| 2040 | break;
|
|---|
| 2041 | }
|
|---|
| 2042 |
|
|---|
| 2043 | case WM_ENABLE:
|
|---|
| 2044 | dprintf(("PMFRAME: WM_ENABLE %x", hwnd));
|
|---|
| 2045 | win32wnd->MsgEnable(SHORT1FROMMP(mp1));
|
|---|
| 2046 | break;
|
|---|
| 2047 |
|
|---|
| 2048 | case WM_SHOW:
|
|---|
| 2049 | dprintf(("PMFRAME: WM_SHOW %x %d", hwnd, mp1));
|
|---|
| 2050 | //show client window
|
|---|
| 2051 | WinShowWindow(win32wnd->getOS2WindowHandle(), (BOOL)mp1);
|
|---|
| 2052 | break;
|
|---|
| 2053 |
|
|---|
| 2054 | case WM_QUERYTRACKINFO:
|
|---|
| 2055 | {
|
|---|
| 2056 | PTRACKINFO trackInfo = (PTRACKINFO)mp2;
|
|---|
| 2057 |
|
|---|
| 2058 | dprintf(("PMFRAME:WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 2059 | trackInfo->cxBorder = 4;
|
|---|
| 2060 | trackInfo->cyBorder = 4;
|
|---|
| 2061 | win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
|
|---|
| 2062 | rc = (MRESULT)TRUE;
|
|---|
| 2063 | break;
|
|---|
| 2064 | }
|
|---|
| 2065 |
|
|---|
| 2066 | case WM_QUERYBORDERSIZE:
|
|---|
| 2067 | {
|
|---|
| 2068 | PWPOINT size = (PWPOINT)mp1;
|
|---|
| 2069 |
|
|---|
| 2070 | dprintf(("PMFRAME:WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
|
|---|
| 2071 |
|
|---|
| 2072 | size->x = 0;
|
|---|
| 2073 | size->y = 0;
|
|---|
| 2074 | rc = (MRESULT)TRUE;
|
|---|
| 2075 | break;
|
|---|
| 2076 | }
|
|---|
| 2077 |
|
|---|
| 2078 | #ifdef DEBUG
|
|---|
| 2079 | case WM_QUERYFRAMEINFO:
|
|---|
| 2080 | dprintf(("PMFRAME:WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
|
|---|
| 2081 | goto RunDefFrameWndProc;
|
|---|
| 2082 | #endif
|
|---|
| 2083 |
|
|---|
| 2084 | case WM_FORMATFRAME:
|
|---|
| 2085 | dprintf(("PMFRAME:WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 2086 | break;
|
|---|
| 2087 |
|
|---|
| 2088 | case WM_ADJUSTFRAMEPOS:
|
|---|
| 2089 | {
|
|---|
| 2090 | PSWP pswp = (PSWP)mp1;
|
|---|
| 2091 |
|
|---|
| 2092 | dprintf(("PMFRAME:WM_ADJUSTFRAMEPOS %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 2093 | //hack alert: the PM frame control changes the z-order of a child window
|
|---|
| 2094 | // if it receives focus after a window has been destroyed
|
|---|
| 2095 | // We can't let this happen as this messes up assumptions
|
|---|
| 2096 | // elsewhere (e.g. GetNextDlgGroupItem)
|
|---|
| 2097 | // By returning 0 here, we prevent the default frame handler
|
|---|
| 2098 | // from messing things up. (one example is a group of radio buttons)
|
|---|
| 2099 | //NOTE: We really need to get rid of frame & client windows for each
|
|---|
| 2100 | // win32 window
|
|---|
| 2101 | if(pswp->fl == SWP_FOCUSACTIVATE && win32wnd->isChild()) {
|
|---|
| 2102 | rc = 0;
|
|---|
| 2103 | break;
|
|---|
| 2104 | }
|
|---|
| 2105 | //hack alert: as we return zero as border size (check handler) we need
|
|---|
| 2106 | //to do adjustments here as well or PM will calculate it for us and
|
|---|
| 2107 | //result will be illegal. Btw we do not honour PM border size settings
|
|---|
| 2108 | //and never will. I was unable to figure out why only X coordinate
|
|---|
| 2109 | //is being broken but not Y as well.
|
|---|
| 2110 |
|
|---|
| 2111 | if ((pswp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
|---|
| 2112 | {
|
|---|
| 2113 | RECT rect;
|
|---|
| 2114 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
|---|
| 2115 | win32wnd->AdjustMaximizedRect(&rect);
|
|---|
| 2116 |
|
|---|
| 2117 | pswp->x += rect.left;
|
|---|
| 2118 | }
|
|---|
| 2119 | goto RunDefFrameWndProc;
|
|---|
| 2120 | }
|
|---|
| 2121 |
|
|---|
| 2122 | #ifdef DEBUG
|
|---|
| 2123 | case WM_OWNERPOSCHANGE:
|
|---|
| 2124 | {
|
|---|
| 2125 | PSWP pswp = (PSWP)mp1;
|
|---|
| 2126 |
|
|---|
| 2127 | dprintf(("PMFRAME:WM_OWNERPOSCHANGE %x %x %x (%s) (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, DbgGetStringSWPFlags(pswp->fl), pswp->x, pswp->y, pswp->cx, pswp->cy));
|
|---|
| 2128 | goto RunDefFrameWndProc;
|
|---|
| 2129 | }
|
|---|
| 2130 | #endif
|
|---|
| 2131 |
|
|---|
| 2132 | case WM_MINMAXFRAME:
|
|---|
| 2133 | {
|
|---|
| 2134 | PSWP swp = (PSWP)mp1;
|
|---|
| 2135 |
|
|---|
| 2136 | if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
|
|---|
| 2137 |
|
|---|
| 2138 | dprintf(("PMFRAME:WM_MINMAXFRAME %x",hwnd));
|
|---|
| 2139 | if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
|
|---|
| 2140 | {
|
|---|
| 2141 | // MDI frame windows are not common PM windows so we need to
|
|---|
| 2142 | // drop-out WHOLE chain of WM_X commands with SWP_MAXIMIZE flag
|
|---|
| 2143 | // finally last WM_WINDOWPOSCHANGED will take care of maximization
|
|---|
| 2144 |
|
|---|
| 2145 | if (win32wnd->getExStyle() & WS_EX_MDICHILD_W) {
|
|---|
| 2146 | rc = 0;
|
|---|
| 2147 | break;
|
|---|
| 2148 | }
|
|---|
| 2149 |
|
|---|
| 2150 | RECT rect;
|
|---|
| 2151 | rect.left = rect.top = rect.right = rect.bottom = 0;
|
|---|
| 2152 | win32wnd->AdjustMaximizedRect(&rect);
|
|---|
| 2153 |
|
|---|
| 2154 | swp->x += rect.left;
|
|---|
| 2155 | swp->cx += rect.right-rect.left;
|
|---|
| 2156 | swp->y -= rect.bottom;
|
|---|
| 2157 | swp->cy += rect.bottom-rect.top;
|
|---|
| 2158 |
|
|---|
| 2159 | win32wnd->ShowWindow(SW_RESTORE_W);
|
|---|
| 2160 | }
|
|---|
| 2161 | else
|
|---|
| 2162 | if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
|
|---|
| 2163 | {
|
|---|
| 2164 | win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
|
|---|
| 2165 | }
|
|---|
| 2166 | else
|
|---|
| 2167 | if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
|
|---|
| 2168 | {
|
|---|
| 2169 | win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
|
|---|
| 2170 | }
|
|---|
| 2171 | goto RunDefWndProc;
|
|---|
| 2172 | }
|
|---|
| 2173 |
|
|---|
| 2174 | #ifdef DEBUG
|
|---|
| 2175 | case WM_UPDATEFRAME:
|
|---|
| 2176 | dprintf(("PMFRAME:WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
|
|---|
| 2177 | goto RunDefFrameWndProc;
|
|---|
| 2178 | #endif
|
|---|
| 2179 |
|
|---|
| 2180 | case WM_TRACKFRAME:
|
|---|
| 2181 | dprintf(("PMFRAME: WM_TRACKFRAME %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 2182 | if(fOS2Look) {//sent by titlebar control
|
|---|
| 2183 | Frame_SysCommandSizeMove(win32wnd, SC_MOVE_W+HTCAPTION_W);
|
|---|
| 2184 | }
|
|---|
| 2185 | rc = 0;
|
|---|
| 2186 | break;
|
|---|
| 2187 |
|
|---|
| 2188 | case WM_SYSCOMMAND:
|
|---|
| 2189 | dprintf(("PMFRAME: WM_SYSCOMMAND %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
|
|---|
| 2190 | if (fOS2Look == OS2_APPEARANCE_SYSMENU && mp1 == (MPARAM)OSSC_SYSMENU)
|
|---|
| 2191 | goto RunDefFrameWndProc;
|
|---|
| 2192 |
|
|---|
| 2193 | if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
|
|---|
| 2194 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2195 | win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
|
|---|
| 2196 | }
|
|---|
| 2197 | if(win32wnd)
|
|---|
| 2198 | win32wnd->DispatchMsgA(pWinMsg);
|
|---|
| 2199 | break;
|
|---|
| 2200 |
|
|---|
| 2201 | #ifdef DEBUG
|
|---|
| 2202 | case WM_DDE_INITIATE:
|
|---|
| 2203 | case WM_DDE_INITIATEACK:
|
|---|
| 2204 | case WM_DDE_REQUEST:
|
|---|
| 2205 | case WM_DDE_ACK:
|
|---|
| 2206 | case WM_DDE_DATA:
|
|---|
| 2207 | case WM_DDE_ADVISE:
|
|---|
| 2208 | case WM_DDE_UNADVISE:
|
|---|
| 2209 | case WM_DDE_POKE:
|
|---|
| 2210 | case WM_DDE_EXECUTE:
|
|---|
| 2211 | case WM_DDE_TERMINATE:
|
|---|
| 2212 | dprintf(("PMFRAME: WM_DDE %x %x", msg, win32wnd->getWindowHandle()));
|
|---|
| 2213 | break;
|
|---|
| 2214 | #endif
|
|---|
| 2215 |
|
|---|
| 2216 | default:
|
|---|
| 2217 | goto RunDefFrameWndProc;
|
|---|
| 2218 | }
|
|---|
| 2219 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2220 | RestoreOS2TIB();
|
|---|
| 2221 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 2222 |
|
|---|
| 2223 | #ifdef DEBUG
|
|---|
| 2224 | dbg_ThreadPopCall();
|
|---|
| 2225 | #endif
|
|---|
| 2226 | return (MRESULT)rc;
|
|---|
| 2227 |
|
|---|
| 2228 | RunDefFrameWndProc:
|
|---|
| 2229 | dprintf2(("RunDefFrameWndProc"));
|
|---|
| 2230 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2231 | RestoreOS2TIB();
|
|---|
| 2232 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 2233 |
|
|---|
| 2234 | #ifdef DEBUG
|
|---|
| 2235 | dbg_ThreadPopCall();
|
|---|
| 2236 | #endif
|
|---|
| 2237 | return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 2238 |
|
|---|
| 2239 | RunDefWndProc:
|
|---|
| 2240 | dprintf2(("RunDefWndProc"));
|
|---|
| 2241 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2242 | RestoreOS2TIB();
|
|---|
| 2243 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 2244 |
|
|---|
| 2245 | //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
|
|---|
| 2246 | // return pfnFrameWndProc(hwnd, msg, mp1, mp2);
|
|---|
| 2247 |
|
|---|
| 2248 | #ifdef DEBUG
|
|---|
| 2249 | dbg_ThreadPopCall();
|
|---|
| 2250 | #endif
|
|---|
| 2251 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 2252 | }
|
|---|
| 2253 | //******************************************************************************
|
|---|
| 2254 | //******************************************************************************
|
|---|
| 2255 | MRESULT EXPENTRY Win32FakeWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 2256 | {
|
|---|
| 2257 | PFNWP pfnOldWindowProc;
|
|---|
| 2258 | Win32BaseWindow *win32wnd, *win32wndchild;
|
|---|
| 2259 | TEB *teb;
|
|---|
| 2260 | MRESULT rc = 0;
|
|---|
| 2261 | EXCEPTIONREGISTRATIONRECORD exceptRegRec = {0,0};
|
|---|
| 2262 |
|
|---|
| 2263 | //Restore our FS selector
|
|---|
| 2264 | SetWin32TIB();
|
|---|
| 2265 |
|
|---|
| 2266 | win32wnd = Win32FakeWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 2267 | if(win32wnd == NULL) {
|
|---|
| 2268 | DebugInt3();
|
|---|
| 2269 | goto RunDefWndProc;
|
|---|
| 2270 | }
|
|---|
| 2271 |
|
|---|
| 2272 | pfnOldWindowProc = (PFNWP)win32wnd->getOldPMWindowProc();
|
|---|
| 2273 | if(pfnOldWindowProc == NULL) {
|
|---|
| 2274 | DebugInt3();
|
|---|
| 2275 | goto RunDefWndProc;
|
|---|
| 2276 | }
|
|---|
| 2277 |
|
|---|
| 2278 | RestoreOS2TIB();
|
|---|
| 2279 | rc = pfnOldWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 2280 |
|
|---|
| 2281 | ODIN_SetExceptionHandler(&exceptRegRec);
|
|---|
| 2282 | SetWin32TIB();
|
|---|
| 2283 | switch(msg) {
|
|---|
| 2284 | case WM_WINDOWPOSCHANGED:
|
|---|
| 2285 | {
|
|---|
| 2286 | PSWP pswp = (PSWP)mp1,pswpOld = pswp+1;
|
|---|
| 2287 | SWP swpOld = *(pswp + 1);
|
|---|
| 2288 | WINDOWPOS wp;
|
|---|
| 2289 |
|
|---|
| 2290 | if(win32wnd->getParent()) {
|
|---|
| 2291 | OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 2292 | hwnd);
|
|---|
| 2293 | }
|
|---|
| 2294 | else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
|
|---|
| 2295 |
|
|---|
| 2296 | win32wnd->SetWindowPos(wp.hwndInsertAfter, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
|
|---|
| 2297 | break;
|
|---|
| 2298 | }
|
|---|
| 2299 |
|
|---|
| 2300 | }
|
|---|
| 2301 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 2302 | RestoreOS2TIB();
|
|---|
| 2303 | ODIN_UnsetExceptionHandler(&exceptRegRec);
|
|---|
| 2304 | return rc;
|
|---|
| 2305 |
|
|---|
| 2306 | RunDefWndProc:
|
|---|
| 2307 | RestoreOS2TIB();
|
|---|
| 2308 | return WinDefWindowProc( hwnd, msg, mp1, mp2 );
|
|---|
| 2309 | }
|
|---|
| 2310 | //******************************************************************************
|
|---|
| 2311 | // PMWinSubclassFakeWindow
|
|---|
| 2312 | //
|
|---|
| 2313 | // Subclass a fake window (converted PM window)
|
|---|
| 2314 | //
|
|---|
| 2315 | // Parameters
|
|---|
| 2316 | //
|
|---|
| 2317 | // HWND hwndOS2 - PM handle of fake window
|
|---|
| 2318 | //
|
|---|
| 2319 | // Returns
|
|---|
| 2320 | // NULL - Failure
|
|---|
| 2321 | // else - Old PM window procedure
|
|---|
| 2322 | //
|
|---|
| 2323 | //******************************************************************************
|
|---|
| 2324 | PVOID PMWinSubclassFakeWindow(HWND hwndOS2)
|
|---|
| 2325 | {
|
|---|
| 2326 | return WinSubclassWindow(hwndOS2, Win32FakeWindowProc);
|
|---|
| 2327 | }
|
|---|
| 2328 | //******************************************************************************
|
|---|
| 2329 | //******************************************************************************
|
|---|
| 2330 | void FrameSetFocus(HWND hwnd)
|
|---|
| 2331 | {
|
|---|
| 2332 | HWND hwndFocusSave = WinQueryWindowULong(hwnd, QWL_HWNDFOCUSSAVE);
|
|---|
| 2333 | if(!WinIsWindow(hab, hwndFocusSave)) {
|
|---|
| 2334 | hwndFocusSave = WinWindowFromID(hwnd, FID_CLIENT);
|
|---|
| 2335 | WinSetWindowULong(hwnd, QWL_HWNDFOCUSSAVE, hwndFocusSave);
|
|---|
| 2336 | }
|
|---|
| 2337 | dprintf(("FrameSetFocus: hwndFocusSave %x %x", OS2ToWin32Handle(hwndFocusSave), hwndFocusSave));
|
|---|
| 2338 | WinSetFocus(HWND_DESKTOP, hwndFocusSave);
|
|---|
| 2339 |
|
|---|
| 2340 | ULONG ulFrameFlags = WinQueryWindowUShort(hwnd, QWS_FLAGS);
|
|---|
| 2341 | ulFrameFlags &= ~FF_NOACTIVATESWP;
|
|---|
| 2342 | WinSetWindowUShort(hwnd, QWS_FLAGS, ulFrameFlags);
|
|---|
| 2343 | }
|
|---|
| 2344 | //******************************************************************************
|
|---|
| 2345 | //******************************************************************************
|
|---|
| 2346 | void FrameReplaceMenuItem(HWND hwndMenu, ULONG nIndex, ULONG idOld, ULONG idNew,
|
|---|
| 2347 | HBITMAP hbmNew)
|
|---|
| 2348 | {
|
|---|
| 2349 | MENUITEM mi;
|
|---|
| 2350 |
|
|---|
| 2351 | if (!hwndMenu)
|
|---|
| 2352 | return;
|
|---|
| 2353 |
|
|---|
| 2354 | WinEnableWindowUpdate(hwndMenu, FALSE);
|
|---|
| 2355 |
|
|---|
| 2356 | if (WinSendMsg(hwndMenu, MM_QUERYITEM, MPFROM2SHORT(idOld, TRUE), MPFROMP(&mi)))
|
|---|
| 2357 | {
|
|---|
| 2358 | WinSendMsg(hwndMenu, MM_REMOVEITEM, (MPARAM)idOld, 0);
|
|---|
| 2359 | mi.afStyle = MIS_BITMAP | MIS_SYSCOMMAND;
|
|---|
| 2360 | mi.afAttribute = 0;
|
|---|
| 2361 | mi.hwndSubMenu = 0;
|
|---|
| 2362 | mi.id = idNew;
|
|---|
| 2363 | mi.hItem = (ULONG)hbmNew;
|
|---|
| 2364 | WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, 0);
|
|---|
| 2365 | }
|
|---|
| 2366 | else
|
|---|
| 2367 | dprintf(("WARNING: FrameReplaceMenuItem control %x not found",idOld));
|
|---|
| 2368 |
|
|---|
| 2369 | WinEnableWindowUpdate(hwndMenu, TRUE);
|
|---|
| 2370 |
|
|---|
| 2371 | WinInvalidateRect(hwndMenu, NULL, TRUE);
|
|---|
| 2372 | }
|
|---|
| 2373 | //******************************************************************************
|
|---|
| 2374 | //******************************************************************************
|
|---|
| 2375 | static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes)
|
|---|
| 2376 | {
|
|---|
| 2377 | PDRAGITEM pDragItem;
|
|---|
| 2378 | int i, cItems;
|
|---|
| 2379 | BOOL ret;
|
|---|
| 2380 | char szFileName[CCHMAXPATH];
|
|---|
| 2381 | char szContainerName[CCHMAXPATH];
|
|---|
| 2382 | ULONG ulBytes;
|
|---|
| 2383 | char *pszCurFile = NULL;
|
|---|
| 2384 |
|
|---|
| 2385 | /* Get access to the DRAGINFO data structure */
|
|---|
| 2386 | if(!DrgAccessDraginfo(pDragInfo)) {
|
|---|
| 2387 | return NULL;
|
|---|
| 2388 | }
|
|---|
| 2389 |
|
|---|
| 2390 | cItems = DrgQueryDragitemCount(pDragInfo);
|
|---|
| 2391 |
|
|---|
| 2392 | //compute memory required to hold all filenames
|
|---|
| 2393 | int bufsize = 0;
|
|---|
| 2394 | for (i = 0; i < cItems; i++) {
|
|---|
| 2395 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
|---|
| 2396 |
|
|---|
| 2397 | bufsize += DrgQueryStrNameLen(pDragItem->hstrContainerName) + DrgQueryStrNameLen(pDragItem->hstrSourceName);
|
|---|
| 2398 | bufsize++; //0 terminator
|
|---|
| 2399 | bufsize++; //+ potential missing backslash
|
|---|
| 2400 | }
|
|---|
| 2401 | bufsize++; //extra 0 terminator
|
|---|
| 2402 | char *pszFiles = (char *)malloc(bufsize);
|
|---|
| 2403 | if(pszFiles == NULL) {
|
|---|
| 2404 | dprintf(("Out of memory!!"));
|
|---|
| 2405 | DebugInt3();
|
|---|
| 2406 | goto failure;
|
|---|
| 2407 | }
|
|---|
| 2408 | memset(pszFiles, 0, bufsize);
|
|---|
| 2409 |
|
|---|
| 2410 | pszCurFile = pszFiles;
|
|---|
| 2411 |
|
|---|
| 2412 | //copy all filenames
|
|---|
| 2413 | for (i = 0; i < cItems; i++) {
|
|---|
| 2414 | char *pszTemp = pszCurFile;
|
|---|
| 2415 |
|
|---|
| 2416 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
|---|
| 2417 |
|
|---|
| 2418 | ulBytes = DrgQueryStrNameLen(pDragItem->hstrContainerName);
|
|---|
| 2419 | ulBytes = DrgQueryStrName(pDragItem->hstrContainerName,
|
|---|
| 2420 | ulBytes, pszCurFile);
|
|---|
| 2421 | if(pszCurFile[ulBytes-1] != '\\') {
|
|---|
| 2422 | pszCurFile[ulBytes] = '\\';
|
|---|
| 2423 | pszCurFile++;
|
|---|
| 2424 | }
|
|---|
| 2425 | pszCurFile += ulBytes;
|
|---|
| 2426 |
|
|---|
| 2427 | ulBytes = DrgQueryStrNameLen(pDragItem->hstrSourceName);
|
|---|
| 2428 | ulBytes = DrgQueryStrName(pDragItem->hstrSourceName,
|
|---|
| 2429 | ulBytes+1, pszCurFile);
|
|---|
| 2430 | pszCurFile += ulBytes + 1; //+ terminator
|
|---|
| 2431 |
|
|---|
| 2432 | dprintf(("dropped file %s", pszTemp));
|
|---|
| 2433 | }
|
|---|
| 2434 |
|
|---|
| 2435 | /* Release the draginfo data structure */
|
|---|
| 2436 | DrgFreeDraginfo(pDragInfo);
|
|---|
| 2437 |
|
|---|
| 2438 | *pulBytes = bufsize;
|
|---|
| 2439 | *pcItems = cItems;
|
|---|
| 2440 |
|
|---|
| 2441 | return pszFiles;
|
|---|
| 2442 |
|
|---|
| 2443 | failure:
|
|---|
| 2444 | /* Release the draginfo data structure */
|
|---|
| 2445 | DrgFreeDraginfo(pDragInfo);
|
|---|
| 2446 | if(pszFiles) {
|
|---|
| 2447 | free(pszFiles);
|
|---|
| 2448 | }
|
|---|
| 2449 | return NULL;
|
|---|
| 2450 | }
|
|---|
| 2451 | //******************************************************************************
|
|---|
| 2452 | //******************************************************************************
|
|---|
| 2453 | static BOOL PMDragValidate(PDRAGINFO pDragInfo)
|
|---|
| 2454 | {
|
|---|
| 2455 | PDRAGITEM pDragItem;
|
|---|
| 2456 | ULONG ulBytes;
|
|---|
| 2457 | int i, cItems;
|
|---|
| 2458 | BOOL ret;
|
|---|
| 2459 | char szFileName[CCHMAXPATH];
|
|---|
| 2460 | char szContainerName[CCHMAXPATH];
|
|---|
| 2461 | USHORT usOp = DO_MOVE;
|
|---|
| 2462 |
|
|---|
| 2463 | /* Get access to the DRAGINFO data structure */
|
|---|
| 2464 | if(!DrgAccessDraginfo(pDragInfo)) {
|
|---|
| 2465 | return FALSE;
|
|---|
| 2466 | }
|
|---|
| 2467 |
|
|---|
| 2468 | /* Can we accept this drop? */
|
|---|
| 2469 | switch (pDragInfo->usOperation) {
|
|---|
| 2470 | /* Return DOR_NODROPOP if current operation */
|
|---|
| 2471 | /* is link or unknown */
|
|---|
| 2472 | case DO_LINK:
|
|---|
| 2473 | case DO_COPY:
|
|---|
| 2474 | case DO_UNKNOWN:
|
|---|
| 2475 | goto failure;
|
|---|
| 2476 |
|
|---|
| 2477 | /* Our default operation is Move */
|
|---|
| 2478 | case DO_MOVE:
|
|---|
| 2479 | case DO_DEFAULT:
|
|---|
| 2480 | pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
|
|---|
| 2481 | ulBytes = DrgQueryStrName(pDragItem->hstrContainerName,
|
|---|
| 2482 | sizeof(szContainerName),
|
|---|
| 2483 | szContainerName);
|
|---|
| 2484 | ulBytes = DrgQueryStrName(pDragItem->hstrSourceName,
|
|---|
| 2485 | sizeof(szFileName),
|
|---|
| 2486 | szFileName);
|
|---|
| 2487 | if (!ulBytes) {
|
|---|
| 2488 | goto failure;
|
|---|
| 2489 | }
|
|---|
| 2490 |
|
|---|
| 2491 | dprintf(("dropped file %s%s", szContainerName, szFileName));
|
|---|
| 2492 | break;
|
|---|
| 2493 | }
|
|---|
| 2494 |
|
|---|
| 2495 | cItems = DrgQueryDragitemCount(pDragInfo);
|
|---|
| 2496 |
|
|---|
| 2497 | /* Now, we need to look at each item in turn */
|
|---|
| 2498 | for (i = 0; i < cItems; i++) {
|
|---|
| 2499 | pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
|
|---|
| 2500 |
|
|---|
| 2501 | /* Make sure we can move for a Move request */
|
|---|
| 2502 | if (!((pDragItem->fsSupportedOps & DO_MOVEABLE) &&
|
|---|
| 2503 | (usOp == (USHORT)DO_MOVE)))
|
|---|
| 2504 | {
|
|---|
| 2505 | dprintf(("item %d not accepted", i));
|
|---|
| 2506 | goto failure;
|
|---|
| 2507 | }
|
|---|
| 2508 | }
|
|---|
| 2509 | /* Release the draginfo data structure */
|
|---|
| 2510 | DrgFreeDraginfo(pDragInfo);
|
|---|
| 2511 | return TRUE;
|
|---|
| 2512 |
|
|---|
| 2513 | failure:
|
|---|
| 2514 | DrgFreeDraginfo(pDragInfo);
|
|---|
| 2515 | return FALSE;
|
|---|
| 2516 | }
|
|---|
| 2517 |
|
|---|
| 2518 | //******************************************************************************
|
|---|
| 2519 | // Override std class names we use in Odin (necessary for keyboard hook)
|
|---|
| 2520 | //******************************************************************************
|
|---|
| 2521 | void WIN32API SetCustomStdClassName(LPSTR pszStdClassName)
|
|---|
| 2522 | {
|
|---|
| 2523 | strcpy(WIN32_STDCLASS, pszStdClassName);
|
|---|
| 2524 | }
|
|---|
| 2525 | //******************************************************************************
|
|---|
| 2526 | //******************************************************************************
|
|---|
| 2527 | char *WIN32API QueryCustomStdClassName()
|
|---|
| 2528 | {
|
|---|
| 2529 | return WIN32_STDCLASS;
|
|---|
| 2530 | }
|
|---|
| 2531 | //******************************************************************************
|
|---|
| 2532 | //******************************************************************************
|
|---|
| 2533 |
|
|---|
| 2534 | #ifdef DEBUG
|
|---|
| 2535 | static char *DbgGetStringSWPFlags(ULONG flags)
|
|---|
| 2536 | {
|
|---|
| 2537 | static char szSWPFlags[512];
|
|---|
| 2538 |
|
|---|
| 2539 | szSWPFlags[0] = 0;
|
|---|
| 2540 |
|
|---|
| 2541 | if(flags & SWP_SIZE) {
|
|---|
| 2542 | strcat(szSWPFlags, "SWP_SIZE ");
|
|---|
| 2543 | }
|
|---|
| 2544 | if(flags & SWP_MOVE) {
|
|---|
| 2545 | strcat(szSWPFlags, "SWP_MOVE ");
|
|---|
| 2546 | }
|
|---|
| 2547 | if(flags & SWP_ZORDER) {
|
|---|
| 2548 | strcat(szSWPFlags, "SWP_ZORDER ");
|
|---|
| 2549 | }
|
|---|
| 2550 | if(flags & SWP_SHOW) {
|
|---|
| 2551 | strcat(szSWPFlags, "SWP_SHOW ");
|
|---|
| 2552 | }
|
|---|
| 2553 | if(flags & SWP_HIDE) {
|
|---|
| 2554 | strcat(szSWPFlags, "SWP_HIDE ");
|
|---|
| 2555 | }
|
|---|
| 2556 | if(flags & SWP_NOREDRAW) {
|
|---|
| 2557 | strcat(szSWPFlags, "SWP_NOREDRAW ");
|
|---|
| 2558 | }
|
|---|
| 2559 | if(flags & SWP_NOADJUST) {
|
|---|
| 2560 | strcat(szSWPFlags, "SWP_NOADJUST ");
|
|---|
| 2561 | }
|
|---|
| 2562 | if(flags & SWP_ACTIVATE) {
|
|---|
| 2563 | strcat(szSWPFlags, "SWP_ACTIVATE ");
|
|---|
| 2564 | }
|
|---|
| 2565 | if(flags & SWP_DEACTIVATE) {
|
|---|
| 2566 | strcat(szSWPFlags, "SWP_DEACTIVATE ");
|
|---|
| 2567 | }
|
|---|
| 2568 | if(flags & SWP_EXTSTATECHANGE) {
|
|---|
| 2569 | strcat(szSWPFlags, "SWP_EXTSTATECHANGE ");
|
|---|
| 2570 | }
|
|---|
| 2571 | if(flags & SWP_MINIMIZE) {
|
|---|
| 2572 | strcat(szSWPFlags, "SWP_MINIMIZE ");
|
|---|
| 2573 | }
|
|---|
| 2574 | if(flags & SWP_MAXIMIZE) {
|
|---|
| 2575 | strcat(szSWPFlags, "SWP_MAXIMIZE ");
|
|---|
| 2576 | }
|
|---|
| 2577 | if(flags & SWP_RESTORE) {
|
|---|
| 2578 | strcat(szSWPFlags, "SWP_RESTORE ");
|
|---|
| 2579 | }
|
|---|
| 2580 | if(flags & SWP_FOCUSACTIVATE) {
|
|---|
| 2581 | strcat(szSWPFlags, "SWP_FOCUSACTIVATE ");
|
|---|
| 2582 | }
|
|---|
| 2583 | if(flags & SWP_FOCUSDEACTIVATE) {
|
|---|
| 2584 | strcat(szSWPFlags, "SWP_FOCUSDEACTIVATE ");
|
|---|
| 2585 | }
|
|---|
| 2586 | if(flags & SWP_NOAUTOCLOSE) {
|
|---|
| 2587 | strcat(szSWPFlags, "SWP_NOAUTOCLOSE ");
|
|---|
| 2588 | }
|
|---|
| 2589 | return szSWPFlags;
|
|---|
| 2590 | }
|
|---|
| 2591 | static char *DbgPrintQFCFlags(ULONG flags)
|
|---|
| 2592 | {
|
|---|
| 2593 | static char szQFCFlags[64];
|
|---|
| 2594 |
|
|---|
| 2595 | szQFCFlags[0] = 0;
|
|---|
| 2596 |
|
|---|
| 2597 | if(flags & QFC_NEXTINCHAIN) {
|
|---|
| 2598 | strcat(szQFCFlags, "QFC_NEXTINCHAIN");
|
|---|
| 2599 | }
|
|---|
| 2600 | else
|
|---|
| 2601 | if(flags & QFC_ACTIVE) {
|
|---|
| 2602 | strcat(szQFCFlags, "QFC_ACTIVE");
|
|---|
| 2603 | }
|
|---|
| 2604 | else
|
|---|
| 2605 | if(flags & QFC_FRAME) {
|
|---|
| 2606 | strcat(szQFCFlags, "QFC_FRAME");
|
|---|
| 2607 | }
|
|---|
| 2608 | else
|
|---|
| 2609 | if(flags & QFC_SELECTACTIVE) {
|
|---|
| 2610 | strcat(szQFCFlags, "QFC_SELECTACTIVE");
|
|---|
| 2611 | }
|
|---|
| 2612 | else
|
|---|
| 2613 | if(flags & QFC_PARTOFCHAIN) {
|
|---|
| 2614 | strcat(szQFCFlags, "QFC_PARTOFCHAIN");
|
|---|
| 2615 | }
|
|---|
| 2616 |
|
|---|
| 2617 | return szQFCFlags;
|
|---|
| 2618 | }
|
|---|
| 2619 | #endif
|
|---|