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