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