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