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