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