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