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