| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: mainwnd.c 824 2007-08-31 23:12:20Z stevenhl $ | 
|---|
| 5 |  | 
|---|
| 6 | fm/2 main window | 
|---|
| 7 |  | 
|---|
| 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 9 | Copyright (c) 2001, 2007 Steven H. Levine | 
|---|
| 10 |  | 
|---|
| 11 | 11 Jun 02 SHL Drop obsolete xor code | 
|---|
| 12 | 16 Oct 02 SHL Handle large partitions | 
|---|
| 13 | 01 Aug 04 SHL Rework lstrip/rstrip usage | 
|---|
| 14 | 23 May 05 SHL Use QWL_USER | 
|---|
| 15 | 23 May 05 SHL Use datamin.h | 
|---|
| 16 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL | 
|---|
| 17 | 26 May 05 SHL Comments and localize code | 
|---|
| 18 | 05 Jun 05 SHL Use QWL_USER | 
|---|
| 19 | 06 Jun 05 SHL Rework MainWMCommand for VAC3.65 compat | 
|---|
| 20 | 13 Aug 05 SHL Renames and comments | 
|---|
| 21 | 08 Dec 05 SHL DriveProc: disable menu items if drive not ready | 
|---|
| 22 | 17 Dec 05 SHL DriveProc: correct my stupid | 
|---|
| 23 | 29 May 06 SHL IDM_EDITANYARCHIVER: sanitize code | 
|---|
| 24 | 17 Jul 06 SHL Use Runtime_Error | 
|---|
| 25 | 17 Aug 06 SHL Complain nicer if state name does not exist | 
|---|
| 26 | 18 Feb 07 GKY More drive type and icon support | 
|---|
| 27 | 08 Mar 07 SHL SaveDirCnrState: do not save state of NOPRESCAN volumes | 
|---|
| 28 | 09 Mar 07 SHL RestoreDirCnrState/SaveDirCnrState: optimize and avoid overflows | 
|---|
| 29 | 30 Mar 07 GKY Remove GetPString for window class names | 
|---|
| 30 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits | 
|---|
| 31 | 06 Apr 07 GKY Add some error checking in drag/drop | 
|---|
| 32 | 15 Apr 07 SHL mainwnd MAIN_SETUPLIST restore state not found reporting | 
|---|
| 33 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods | 
|---|
| 34 | 20 Apr 07 SHL Avoid spurious add_udir error reports | 
|---|
| 35 | 12 May 07 SHL Use dcd->ulItemsToUnHilite | 
|---|
| 36 | 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit | 
|---|
| 37 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148) | 
|---|
| 38 | 07 Aug 07 SHL Use BldQuotedFileName | 
|---|
| 39 | 16 Aug 07 SHL Update IDM_SAVEDIRCNRSTATE logic for ticket# 109 | 
|---|
| 40 | 18 Aug 07 SHL Rework UM_FILLSETUPLIST for new setups storage | 
|---|
| 41 | 19 Aug 07 SHL Move #pragma alloc_text to end of file for OpenWatcom | 
|---|
| 42 | 19 Aug 07 SHL Rework SaveDirCnrState to return better error info | 
|---|
| 43 | 30 Aug 07 SHL Add accelerator support to quicklist windows | 
|---|
| 44 |  | 
|---|
| 45 | ***********************************************************************/ | 
|---|
| 46 |  | 
|---|
| 47 | #define INCL_DOS | 
|---|
| 48 | #define INCL_WIN | 
|---|
| 49 | // #define INCL_WINERRORS | 
|---|
| 50 | #define INCL_SHLERRORS                  // PMERR_NOT_IN_IDX | 
|---|
| 51 | #define INCL_WINHELP | 
|---|
| 52 | #define INCL_GPI | 
|---|
| 53 | #define INCL_LONGLONG | 
|---|
| 54 | #include <os2.h> | 
|---|
| 55 |  | 
|---|
| 56 | #include <stdarg.h> | 
|---|
| 57 | #include <stdio.h> | 
|---|
| 58 | #include <stdlib.h> | 
|---|
| 59 | #include <string.h> | 
|---|
| 60 | #include <ctype.h> | 
|---|
| 61 | #include <share.h> | 
|---|
| 62 | #include <process.h>                    // _beginthread | 
|---|
| 63 |  | 
|---|
| 64 | #include "fm3dll.h" | 
|---|
| 65 | #include "fm3dlg.h" | 
|---|
| 66 | #include "fm3str.h" | 
|---|
| 67 | #include "tools.h" | 
|---|
| 68 | #include "datamin.h" | 
|---|
| 69 |  | 
|---|
| 70 | #pragma data_seg(DATA1) | 
|---|
| 71 |  | 
|---|
| 72 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 73 |  | 
|---|
| 74 | static USHORT firsttool = 0; | 
|---|
| 75 |  | 
|---|
| 76 | static BOOL CloseDirCnrChildren(HWND hwndClient); | 
|---|
| 77 | static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview); | 
|---|
| 78 |  | 
|---|
| 79 | static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 80 | MPARAM mp2) | 
|---|
| 81 | { | 
|---|
| 82 | switch (msg) { | 
|---|
| 83 | case UM_SETUP: | 
|---|
| 84 | case UM_SETUP2: | 
|---|
| 85 | case UM_SETUP3: | 
|---|
| 86 | case UM_SETUP4: | 
|---|
| 87 | case UM_SETUP5: | 
|---|
| 88 | /* | 
|---|
| 89 | * feed setup messages to main window | 
|---|
| 90 | */ | 
|---|
| 91 | PostMsg(hwndMain, msg, mp1, mp2); | 
|---|
| 92 | return 0; | 
|---|
| 93 |  | 
|---|
| 94 | case UM_SETUP6: | 
|---|
| 95 | /* | 
|---|
| 96 | * handle bubble help requests from drive bar buttons | 
|---|
| 97 | */ | 
|---|
| 98 | { | 
|---|
| 99 | char dv[3], d; | 
|---|
| 100 | HWND hwndB = (HWND) mp1; | 
|---|
| 101 | USHORT id; | 
|---|
| 102 |  | 
|---|
| 103 | id = WinQueryWindowUShort(hwndB, QWS_ID); | 
|---|
| 104 | *dv = 0; | 
|---|
| 105 | WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB, QW_PARENT), | 
|---|
| 106 | id + 50), sizeof(dv), dv); | 
|---|
| 107 | d = toupper(*dv); | 
|---|
| 108 | if (isalpha(d) && d > 'B' && | 
|---|
| 109 | !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID | | 
|---|
| 110 | DRIVE_SLOW)) && | 
|---|
| 111 | (!hwndBubble || | 
|---|
| 112 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && | 
|---|
| 113 | !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 114 |  | 
|---|
| 115 | FSALLOCATE fsa; | 
|---|
| 116 | CHAR s[90], szQty[38]; | 
|---|
| 117 | ULONG ulPctFree; | 
|---|
| 118 | ULONGLONG ullFreeQty; | 
|---|
| 119 |  | 
|---|
| 120 | if (!DosQueryFSInfo((d - 'A') + 1, | 
|---|
| 121 | FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) { | 
|---|
| 122 | ullFreeQty = (ULONGLONG) fsa.cUnitAvail * | 
|---|
| 123 | (fsa.cSectorUnit * fsa.cbSector); | 
|---|
| 124 | ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ? | 
|---|
| 125 | (fsa.cUnitAvail * 100) / fsa.cUnit : 0; | 
|---|
| 126 | CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' '); | 
|---|
| 127 | sprintf(s, "%s (%lu%%) free", szQty, ulPctFree); | 
|---|
| 128 | } | 
|---|
| 129 | if ((!hwndBubble || | 
|---|
| 130 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && | 
|---|
| 131 | !WinQueryCapture(HWND_DESKTOP)) | 
|---|
| 132 | WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID); | 
|---|
| 133 | } | 
|---|
| 134 | } | 
|---|
| 135 | return 0; | 
|---|
| 136 |  | 
|---|
| 137 | case UM_SETDIR: | 
|---|
| 138 | { | 
|---|
| 139 | CHAR s[8] = " :\\OS2"; | 
|---|
| 140 | ULONG bd; | 
|---|
| 141 |  | 
|---|
| 142 | if (DosQuerySysInfo(QSV_BOOT_DRIVE, | 
|---|
| 143 | QSV_BOOT_DRIVE, | 
|---|
| 144 | (PVOID) & bd, (ULONG) sizeof(ULONG))) | 
|---|
| 145 | bd = 3L; | 
|---|
| 146 | *s = (CHAR) bd + '@'; | 
|---|
| 147 | WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1)); | 
|---|
| 148 | if (!mp1) { | 
|---|
| 149 | s[3] = 0; | 
|---|
| 150 | WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID); | 
|---|
| 151 | } | 
|---|
| 152 | PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1)); | 
|---|
| 153 | } | 
|---|
| 154 | return 0; | 
|---|
| 155 |  | 
|---|
| 156 | case UM_RESTORE: | 
|---|
| 157 | if (mp2) { | 
|---|
| 158 | switch ((ULONG) mp2) { | 
|---|
| 159 | case 1: | 
|---|
| 160 | TileChildren(hwndMain, TRUE); | 
|---|
| 161 | break; | 
|---|
| 162 | case 2: | 
|---|
| 163 | CloseDirCnrChildren(hwndMain); | 
|---|
| 164 | break; | 
|---|
| 165 | } | 
|---|
| 166 | } | 
|---|
| 167 | else { | 
|---|
| 168 | fNoTileUpdate = TRUE; | 
|---|
| 169 | WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), FALSE); | 
|---|
| 170 | RestoreDirCnrState(hwndMain, (char *)mp1, FALSE); | 
|---|
| 171 | WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), TRUE); | 
|---|
| 172 | fNoTileUpdate = FALSE; | 
|---|
| 173 | if (mp1) | 
|---|
| 174 | free((char *)mp1); | 
|---|
| 175 | if (fAutoTile) | 
|---|
| 176 | TileChildren(hwndMain, TRUE); | 
|---|
| 177 | } | 
|---|
| 178 | return 0; | 
|---|
| 179 |  | 
|---|
| 180 | case UM_NOTIFY: | 
|---|
| 181 | /* | 
|---|
| 182 | * bring up notify messages for various windows | 
|---|
| 183 | */ | 
|---|
| 184 | if (mp1) | 
|---|
| 185 | return MRFROMLONG(DoNotify((char *)mp1)); | 
|---|
| 186 | return 0; | 
|---|
| 187 |  | 
|---|
| 188 | case WM_DESTROY: | 
|---|
| 189 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID)) | 
|---|
| 190 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 191 | break; | 
|---|
| 192 | } | 
|---|
| 193 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 194 | } | 
|---|
| 195 |  | 
|---|
| 196 | VOID MakeMainObjWin(VOID * args) | 
|---|
| 197 | { | 
|---|
| 198 | HAB hab2; | 
|---|
| 199 | HMQ hmq2; | 
|---|
| 200 | QMSG qmsg2; | 
|---|
| 201 |  | 
|---|
| 202 | priority_bumped(); | 
|---|
| 203 | hab2 = WinInitialize(0); | 
|---|
| 204 | if (hab2) { | 
|---|
| 205 | hmq2 = WinCreateMsgQueue(hab2, 128); | 
|---|
| 206 | if (hmq2) { | 
|---|
| 207 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 208 | WinRegisterClass(hab2, | 
|---|
| 209 | (PSZ) WC_OBJECTWINDOW, | 
|---|
| 210 | MainObjectWndProc, 0, sizeof(PVOID)); | 
|---|
| 211 | MainObjectHwnd = WinCreateWindow(HWND_OBJECT, | 
|---|
| 212 | WC_OBJECTWINDOW, | 
|---|
| 213 | (PSZ) NULL, | 
|---|
| 214 | 0, | 
|---|
| 215 | 0L, | 
|---|
| 216 | 0L, | 
|---|
| 217 | 0L, | 
|---|
| 218 | 0L, | 
|---|
| 219 | 0L, HWND_TOP, OBJ_FRAME, NULL, NULL); | 
|---|
| 220 | if (!MainObjectHwnd) | 
|---|
| 221 | Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 222 | IDS_WINCREATEWINDOW); | 
|---|
| 223 | else { | 
|---|
| 224 | WinSetWindowPtr(MainObjectHwnd, QWL_USER, args); | 
|---|
| 225 | while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0)) | 
|---|
| 226 | WinDispatchMsg(hab2, &qmsg2); | 
|---|
| 227 | WinDestroyWindow(MainObjectHwnd); | 
|---|
| 228 | } | 
|---|
| 229 | WinDestroyMsgQueue(hmq2); | 
|---|
| 230 | } | 
|---|
| 231 | WinTerminate(hab2); | 
|---|
| 232 | } | 
|---|
| 233 | } | 
|---|
| 234 |  | 
|---|
| 235 | static MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 236 | MPARAM mp2) | 
|---|
| 237 | { | 
|---|
| 238 | switch (msg) { | 
|---|
| 239 | case WM_MOUSEMOVE: | 
|---|
| 240 | BubbleHelp(hwnd, TRUE, FALSE, FALSE, GetPString(IDS_IDEALBUTTONHELP)); | 
|---|
| 241 | break; | 
|---|
| 242 | } | 
|---|
| 243 | return PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 244 | } | 
|---|
| 245 |  | 
|---|
| 246 | HWND TopWindow(HWND hwndParent, HWND exclude) | 
|---|
| 247 | { | 
|---|
| 248 | HENUM henum; | 
|---|
| 249 | HWND hwndC = (HWND) 0; | 
|---|
| 250 | USHORT id; | 
|---|
| 251 |  | 
|---|
| 252 | if (hwndParent) { | 
|---|
| 253 | henum = WinBeginEnumWindows(hwndMain); | 
|---|
| 254 | while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 255 | if (hwndC != exclude) { | 
|---|
| 256 | id = WinQueryWindowUShort(hwndC, QWS_ID); | 
|---|
| 257 | if (id) | 
|---|
| 258 | break; | 
|---|
| 259 | } | 
|---|
| 260 | } | 
|---|
| 261 | WinEndEnumWindows(henum); | 
|---|
| 262 | } | 
|---|
| 263 | return hwndC; | 
|---|
| 264 | } | 
|---|
| 265 |  | 
|---|
| 266 | HWND TopWindowName(HWND hwndParent, HWND exclude, CHAR * ret) | 
|---|
| 267 | { | 
|---|
| 268 | HENUM henum; | 
|---|
| 269 | HWND hwndC = (HWND) 0, hwndDir, hwndClient; | 
|---|
| 270 | USHORT id; | 
|---|
| 271 | PCNRITEM pci = NULL; | 
|---|
| 272 |  | 
|---|
| 273 | if (ret) { | 
|---|
| 274 | *ret = 0; | 
|---|
| 275 | if (hwndParent) { | 
|---|
| 276 | henum = WinBeginEnumWindows(hwndMain); | 
|---|
| 277 | while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 278 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC); | 
|---|
| 279 | if (hwndC != exclude && hwndC != hwndTree) { | 
|---|
| 280 | id = WinQueryWindowUShort(hwndC, QWS_ID); | 
|---|
| 281 | if (id) { | 
|---|
| 282 | hwndClient = WinWindowFromID(hwndC, FID_CLIENT); | 
|---|
| 283 | if (hwndClient) { | 
|---|
| 284 | hwndDir = WinWindowFromID(hwndClient, DIR_CNR); | 
|---|
| 285 | if (hwndDir) { | 
|---|
| 286 | if (fLookInDir) { | 
|---|
| 287 | pci = (PCNRITEM) WinSendMsg(hwndDir, | 
|---|
| 288 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 289 | MPFROMLONG(CMA_FIRST), | 
|---|
| 290 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 291 | if (pci && (INT) pci != -1) | 
|---|
| 292 | break; | 
|---|
| 293 | } | 
|---|
| 294 | if (WinSendMsg(hwndClient, | 
|---|
| 295 | UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) { | 
|---|
| 296 | MakeValidDir(ret); | 
|---|
| 297 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret); | 
|---|
| 298 | WinEndEnumWindows(henum); | 
|---|
| 299 | return hwndC; | 
|---|
| 300 | } | 
|---|
| 301 | } | 
|---|
| 302 | } | 
|---|
| 303 | } | 
|---|
| 304 | } | 
|---|
| 305 | } | 
|---|
| 306 | WinEndEnumWindows(henum); | 
|---|
| 307 | if (!pci || (INT) pci == -1) { | 
|---|
| 308 | hwndC = hwndTree; | 
|---|
| 309 | pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree, | 
|---|
| 310 | FID_CLIENT), | 
|---|
| 311 | TREE_CNR), | 
|---|
| 312 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 313 | MPFROMLONG(CMA_FIRST), | 
|---|
| 314 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 315 | } | 
|---|
| 316 | if (pci && (INT) pci != -1) { | 
|---|
| 317 | strcpy(ret, pci->pszFileName); | 
|---|
| 318 | MakeValidDir(ret); | 
|---|
| 319 | } | 
|---|
| 320 | else | 
|---|
| 321 | save_dir2(ret); | 
|---|
| 322 | } | 
|---|
| 323 | } | 
|---|
| 324 | return hwndC; | 
|---|
| 325 | } | 
|---|
| 326 |  | 
|---|
| 327 | ULONG CountDirCnrs(HWND hwndParent) | 
|---|
| 328 | { | 
|---|
| 329 | HENUM henum; | 
|---|
| 330 | HWND hwndF = (HWND) 0, hwndC, hwndDir; | 
|---|
| 331 | ULONG ret = 0; | 
|---|
| 332 |  | 
|---|
| 333 | henum = WinBeginEnumWindows(hwndParent); | 
|---|
| 334 | while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 335 | hwndC = WinWindowFromID(hwndF, FID_CLIENT); | 
|---|
| 336 | if (hwndC) { | 
|---|
| 337 | hwndDir = WinWindowFromID(hwndC, DIR_CNR); | 
|---|
| 338 | if (hwndDir) | 
|---|
| 339 | ret++; | 
|---|
| 340 | } | 
|---|
| 341 | } | 
|---|
| 342 | WinEndEnumWindows(henum); | 
|---|
| 343 | return ret; | 
|---|
| 344 | } | 
|---|
| 345 |  | 
|---|
| 346 | HWND FindDirCnrByName(CHAR * directory, BOOL restore) | 
|---|
| 347 | { | 
|---|
| 348 | HENUM henum; | 
|---|
| 349 | HWND hwndF = (HWND) 0, hwndC, hwndDir; | 
|---|
| 350 | CHAR retstr[CCHMAXPATH]; | 
|---|
| 351 |  | 
|---|
| 352 | if (hwndMain) { | 
|---|
| 353 | henum = WinBeginEnumWindows(hwndMain); | 
|---|
| 354 | while ((hwndF = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 355 | hwndC = WinWindowFromID(hwndF, FID_CLIENT); | 
|---|
| 356 | if (hwndC) { | 
|---|
| 357 | hwndDir = WinWindowFromID(hwndC, DIR_CNR); | 
|---|
| 358 | if (hwndDir) { | 
|---|
| 359 | *retstr = 0; | 
|---|
| 360 | WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID); | 
|---|
| 361 | if (*retstr && !stricmp(retstr, directory)) { | 
|---|
| 362 | if (restore) | 
|---|
| 363 | WinSetWindowPos(hwndF, | 
|---|
| 364 | HWND_TOP, | 
|---|
| 365 | 0, | 
|---|
| 366 | 0, | 
|---|
| 367 | 0, | 
|---|
| 368 | 0, | 
|---|
| 369 | SWP_RESTORE | SWP_SHOW | | 
|---|
| 370 | SWP_ACTIVATE | SWP_ZORDER); | 
|---|
| 371 | break; | 
|---|
| 372 | } | 
|---|
| 373 | } | 
|---|
| 374 | } | 
|---|
| 375 | } | 
|---|
| 376 | WinEndEnumWindows(henum); | 
|---|
| 377 | } | 
|---|
| 378 | return hwndF; | 
|---|
| 379 | } | 
|---|
| 380 |  | 
|---|
| 381 | static VOID SetToggleChecks(HWND hwndMenu) | 
|---|
| 382 | { | 
|---|
| 383 | WinCheckMenuItem(hwndMenu, IDM_TEXTTOOLS, fTextTools); | 
|---|
| 384 | WinCheckMenuItem(hwndMenu, IDM_TOOLTITLES, fToolTitles); | 
|---|
| 385 | WinCheckMenuItem(hwndMenu, IDM_USERLIST, fUserComboBox); | 
|---|
| 386 | WinCheckMenuItem(hwndMenu, IDM_TOOLSUBMENU, fToolbar); | 
|---|
| 387 | WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWSUBMENU, fAutoView); | 
|---|
| 388 | WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWFILE, !fComments); | 
|---|
| 389 | WinCheckMenuItem(hwndMenu, IDM_AUTOVIEWCOMMENTS, fComments); | 
|---|
| 390 | WinCheckMenuItem(hwndMenu, IDM_MOREBUTTONS, fMoreButtons); | 
|---|
| 391 | WinCheckMenuItem(hwndMenu, IDM_DRIVEBAR, fDrivebar); | 
|---|
| 392 | WinCheckMenuItem(hwndMenu, IDM_AUTOTILE, fAutoTile); | 
|---|
| 393 | WinCheckMenuItem(hwndMenu, IDM_TILEBACKWARDS, fTileBackwards); | 
|---|
| 394 | } | 
|---|
| 395 |  | 
|---|
| 396 | static VOID ResizeTools(HWND hwnd) | 
|---|
| 397 | { | 
|---|
| 398 | register ULONG butx = 18L; | 
|---|
| 399 | INT attrib = SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_NOREDRAW, | 
|---|
| 400 | noattrib; | 
|---|
| 401 | register TOOL *tool, *starttool; | 
|---|
| 402 | SWP *swp; | 
|---|
| 403 | register ULONG numtools, x; | 
|---|
| 404 |  | 
|---|
| 405 | if (!fToolbar) | 
|---|
| 406 | return; | 
|---|
| 407 | noattrib = attrib; | 
|---|
| 408 | noattrib &= (~(SWP_SHOW | SWP_ZORDER)); | 
|---|
| 409 | noattrib |= SWP_HIDE; | 
|---|
| 410 | /* count tools */ | 
|---|
| 411 | tool = toolhead; | 
|---|
| 412 | for (numtools = 0L; tool; numtools++) | 
|---|
| 413 | tool = tool->next; | 
|---|
| 414 | /* allocate swp array for WinSetMultWindowPos */ | 
|---|
| 415 | swp = xmallocz(sizeof(SWP) * (numtools + 2), pszSrcFile, __LINE__); | 
|---|
| 416 | if (swp) { | 
|---|
| 417 | for (x = 0; x < numtools + 2L; x++) { | 
|---|
| 418 | swp[x].hwndInsertBehind = HWND_TOP; | 
|---|
| 419 | swp[x].fl = attrib; | 
|---|
| 420 | swp[x].y = (fToolTitles) ? 14L : 3L; | 
|---|
| 421 | swp[x].cx = 32L; | 
|---|
| 422 | swp[x].cy = 32L; | 
|---|
| 423 | } | 
|---|
| 424 | swp[0].x = swp[1].x = 2L; | 
|---|
| 425 | swp[0].y = (fTextTools) ? 14L : 18L; | 
|---|
| 426 | swp[1].y = (fTextTools) ? 1L : 2L; | 
|---|
| 427 | swp[0].cx = swp[1].cx = 14L; | 
|---|
| 428 | swp[0].cy = swp[1].cy = 14L; | 
|---|
| 429 | swp[0].hwnd = WinWindowFromID(hwnd, IDM_TOOLLEFT); | 
|---|
| 430 | swp[1].hwnd = WinWindowFromID(hwnd, IDM_TOOLRIGHT); | 
|---|
| 431 | x = 2L; | 
|---|
| 432 | tool = find_tool(firsttool); | 
|---|
| 433 | if (!tool) | 
|---|
| 434 | tool = toolhead; | 
|---|
| 435 | starttool = tool; | 
|---|
| 436 | while (tool) { | 
|---|
| 437 | if (!(tool->flags & T_INVISIBLE)) { | 
|---|
| 438 | swp[x].x = butx; | 
|---|
| 439 | if (fTextTools || (tool->flags & T_TEXT)) { | 
|---|
| 440 | butx += 55L; | 
|---|
| 441 | swp[x].cx = 54L; | 
|---|
| 442 | swp[x].cy = 24L; | 
|---|
| 443 | swp[x].y = 3L; | 
|---|
| 444 | } | 
|---|
| 445 | else | 
|---|
| 446 | butx += 33L; | 
|---|
| 447 | if (tool->flags & T_SEPARATOR) | 
|---|
| 448 | butx += 12; | 
|---|
| 449 | } | 
|---|
| 450 | else | 
|---|
| 451 | swp[x].fl = noattrib; | 
|---|
| 452 | swp[x].hwnd = WinWindowFromID(hwnd, tool->id); | 
|---|
| 453 | x++; | 
|---|
| 454 | tool = tool->next; | 
|---|
| 455 | } | 
|---|
| 456 | tool = toolhead; | 
|---|
| 457 | while (tool && tool != starttool) { | 
|---|
| 458 | swp[x].x = butx; | 
|---|
| 459 | if (!(tool->flags & T_INVISIBLE)) { | 
|---|
| 460 | if (fTextTools || (tool->flags & T_TEXT)) { | 
|---|
| 461 | butx += 55L; | 
|---|
| 462 | swp[x].cx = 54L; | 
|---|
| 463 | swp[x].cy = 24L; | 
|---|
| 464 | swp[x].y = 3L; | 
|---|
| 465 | } | 
|---|
| 466 | else | 
|---|
| 467 | butx += 33L; | 
|---|
| 468 | if (tool->flags & T_SEPARATOR) | 
|---|
| 469 | butx += 12; | 
|---|
| 470 | } | 
|---|
| 471 | else | 
|---|
| 472 | swp[x].fl = noattrib; | 
|---|
| 473 | swp[x].hwnd = WinWindowFromID(hwnd, tool->id); | 
|---|
| 474 | x++; | 
|---|
| 475 | tool = tool->next; | 
|---|
| 476 | } | 
|---|
| 477 | WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), swp, numtools + 2L); | 
|---|
| 478 | if (!fTextTools && fToolTitles) { | 
|---|
| 479 | for (x = 2L; x < numtools + 2L; x++) { | 
|---|
| 480 | if (fTextTools || !fToolTitles) | 
|---|
| 481 | swp[x].fl = noattrib; | 
|---|
| 482 | else { | 
|---|
| 483 | tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID)); | 
|---|
| 484 | if (tool && (tool->flags & T_TEXT)) | 
|---|
| 485 | swp[x].fl = noattrib; | 
|---|
| 486 | else { | 
|---|
| 487 | swp[x].hwndInsertBehind = HWND_TOP; | 
|---|
| 488 | swp[x].y = 1L; | 
|---|
| 489 | swp[x].cy = 10L; | 
|---|
| 490 | } | 
|---|
| 491 | } | 
|---|
| 492 | swp[x].hwnd = WinWindowFromID(hwnd, | 
|---|
| 493 | WinQueryWindowUShort(swp[x].hwnd, | 
|---|
| 494 | QWS_ID) + 25000); | 
|---|
| 495 | } | 
|---|
| 496 | WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools); | 
|---|
| 497 | } | 
|---|
| 498 | free(swp); | 
|---|
| 499 | } | 
|---|
| 500 | WinInvalidateRect(hwnd, NULL, TRUE); | 
|---|
| 501 | } | 
|---|
| 502 |  | 
|---|
| 503 | static MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 504 | MPARAM mp2) | 
|---|
| 505 | { | 
|---|
| 506 | PFNWP oldproc = (PFNWP) INSTDATA(hwnd); | 
|---|
| 507 | USHORT id; | 
|---|
| 508 |  | 
|---|
| 509 | static HWND hwndMenu = (HWND)0; | 
|---|
| 510 | static BOOL emphasized = FALSE; | 
|---|
| 511 |  | 
|---|
| 512 | switch (msg) { | 
|---|
| 513 | case WM_MOUSEMOVE: | 
|---|
| 514 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 515 | break; | 
|---|
| 516 |  | 
|---|
| 517 | case WM_CHAR: | 
|---|
| 518 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 519 | break; | 
|---|
| 520 |  | 
|---|
| 521 | case WM_MENUEND: | 
|---|
| 522 | if (hwndMenu == (HWND) mp2) { | 
|---|
| 523 | WinDestroyWindow(hwndMenu); | 
|---|
| 524 | hwndMenu = (HWND) 0; | 
|---|
| 525 | } | 
|---|
| 526 | break; | 
|---|
| 527 |  | 
|---|
| 528 | case WM_FOCUSCHANGE: | 
|---|
| 529 | { | 
|---|
| 530 | HAB hab = WinQueryAnchorBlock(hwnd); | 
|---|
| 531 | HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT); | 
|---|
| 532 | HWND hwndFrame = WinQueryWindow(hwndParent, QW_PARENT); | 
|---|
| 533 | static HACCEL haccelSaved = NULLHANDLE; | 
|---|
| 534 | static HACCEL haccelDriveList = NULLHANDLE; | 
|---|
| 535 | static HACCEL haccelSetupList = NULLHANDLE; | 
|---|
| 536 | static HACCEL haccelUserList = NULLHANDLE; | 
|---|
| 537 | static HACCEL haccelCmdList = NULLHANDLE; | 
|---|
| 538 | static HACCEL haccelButtonList = NULLHANDLE; | 
|---|
| 539 | // DbgMsg(pszSrcFile, __LINE__, "WM_FOCUSCHANGE %u", SHORT1FROMMP(mp2)); | 
|---|
| 540 | id = WinQueryWindowUShort(hwndParent, QWS_ID); | 
|---|
| 541 | if (SHORT1FROMMP(mp2)) { | 
|---|
| 542 | // If getting focus 1st time - save original accelerator | 
|---|
| 543 | if (haccelSaved == NULLHANDLE) { | 
|---|
| 544 | haccelSaved = WinQueryAccelTable(hab, hwndFrame); | 
|---|
| 545 | if (haccelSaved == NULLHANDLE) | 
|---|
| 546 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable"); | 
|---|
| 547 | // else | 
|---|
| 548 | // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved); | 
|---|
| 549 | } | 
|---|
| 550 | if (haccelSaved != NULLHANDLE) { | 
|---|
| 551 | switch (id) { | 
|---|
| 552 | case MAIN_DRIVELIST: | 
|---|
| 553 | if (haccelDriveList == NULLHANDLE) { | 
|---|
| 554 | haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST); | 
|---|
| 555 | if (haccelDriveList == NULLHANDLE) | 
|---|
| 556 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable"); | 
|---|
| 557 | } | 
|---|
| 558 | if (haccelDriveList != NULLHANDLE) { | 
|---|
| 559 | if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame)) | 
|---|
| 560 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable"); | 
|---|
| 561 | // else | 
|---|
| 562 | // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList); | 
|---|
| 563 | } | 
|---|
| 564 | break; | 
|---|
| 565 | case MAIN_SETUPLIST: | 
|---|
| 566 | if (haccelSetupList == NULLHANDLE) { | 
|---|
| 567 | haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST); | 
|---|
| 568 | if (haccelSetupList == NULLHANDLE) | 
|---|
| 569 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable"); | 
|---|
| 570 | } | 
|---|
| 571 | if (haccelSetupList != NULLHANDLE) { | 
|---|
| 572 | if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame)) | 
|---|
| 573 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable"); | 
|---|
| 574 | // else | 
|---|
| 575 | // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList); | 
|---|
| 576 | } | 
|---|
| 577 | break; | 
|---|
| 578 | case MAIN_CMDLIST: | 
|---|
| 579 | if (haccelCmdList == NULLHANDLE) { | 
|---|
| 580 | haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST); | 
|---|
| 581 | if (haccelCmdList == NULLHANDLE) | 
|---|
| 582 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable"); | 
|---|
| 583 | } | 
|---|
| 584 | if (haccelCmdList != NULLHANDLE) { | 
|---|
| 585 | if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame)) | 
|---|
| 586 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable"); | 
|---|
| 587 | // else | 
|---|
| 588 | // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList); | 
|---|
| 589 | } | 
|---|
| 590 | break; | 
|---|
| 591 | case MAIN_USERLIST: | 
|---|
| 592 | if (haccelUserList == NULLHANDLE) { | 
|---|
| 593 | haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST); | 
|---|
| 594 | if (haccelUserList == NULLHANDLE) | 
|---|
| 595 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable"); | 
|---|
| 596 | } | 
|---|
| 597 | if (haccelUserList != NULLHANDLE) { | 
|---|
| 598 | if (!WinSetAccelTable(hab, haccelUserList, hwndFrame)) | 
|---|
| 599 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable"); | 
|---|
| 600 | // else | 
|---|
| 601 | // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList); | 
|---|
| 602 | } | 
|---|
| 603 | break; | 
|---|
| 604 | case MAIN_BUTTONLIST: | 
|---|
| 605 | if (haccelButtonList == NULLHANDLE) { | 
|---|
| 606 | haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST); | 
|---|
| 607 | if (haccelButtonList == NULLHANDLE) | 
|---|
| 608 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable"); | 
|---|
| 609 | } | 
|---|
| 610 | if (haccelButtonList != NULLHANDLE) { | 
|---|
| 611 | if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame)) | 
|---|
| 612 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable"); | 
|---|
| 613 | // else | 
|---|
| 614 | // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList); | 
|---|
| 615 | } | 
|---|
| 616 | break; | 
|---|
| 617 | } // switch | 
|---|
| 618 | } | 
|---|
| 619 | } | 
|---|
| 620 | else { | 
|---|
| 621 | // Losing focus | 
|---|
| 622 | switch (id) { | 
|---|
| 623 | case MAIN_DRIVELIST: | 
|---|
| 624 | case MAIN_SETUPLIST: | 
|---|
| 625 | case MAIN_CMDLIST: | 
|---|
| 626 | case MAIN_USERLIST: | 
|---|
| 627 | case MAIN_BUTTONLIST: | 
|---|
| 628 | if (haccelSaved != NULLHANDLE) { | 
|---|
| 629 | if (!WinSetAccelTable(hab, haccelSaved, hwndFrame)) | 
|---|
| 630 | Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable"); | 
|---|
| 631 | // else | 
|---|
| 632 | // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved); | 
|---|
| 633 | } | 
|---|
| 634 | break; | 
|---|
| 635 | } // switch | 
|---|
| 636 | } | 
|---|
| 637 | } | 
|---|
| 638 | break; // WM_FOCUSCHANGE | 
|---|
| 639 |  | 
|---|
| 640 | case WM_CONTEXTMENU: | 
|---|
| 641 | { | 
|---|
| 642 | MRESULT ret = MRFROMSHORT(TRUE); | 
|---|
| 643 |  | 
|---|
| 644 | if (hwndMenu) | 
|---|
| 645 | WinDestroyWindow(hwndMenu); | 
|---|
| 646 | hwndMenu = (HWND) 0; | 
|---|
| 647 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 648 | switch (id) { | 
|---|
| 649 | case MAIN_CMDLIST: | 
|---|
| 650 | WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 651 | QW_PARENT), | 
|---|
| 652 | QW_PARENT), | 
|---|
| 653 | FID_CLIENT), | 
|---|
| 654 | WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID); | 
|---|
| 655 | break; | 
|---|
| 656 | case MAIN_USERLIST: | 
|---|
| 657 | case MAIN_SETUPLIST: | 
|---|
| 658 | hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id); | 
|---|
| 659 | if (hwndMenu) | 
|---|
| 660 | PopupMenu(hwnd, | 
|---|
| 661 | WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 662 | QW_PARENT), | 
|---|
| 663 | QW_PARENT), | 
|---|
| 664 | FID_CLIENT), hwndMenu); | 
|---|
| 665 | break; | 
|---|
| 666 | default: | 
|---|
| 667 | ret = FALSE; | 
|---|
| 668 | break; | 
|---|
| 669 | } // switch | 
|---|
| 670 | return ret; | 
|---|
| 671 | } | 
|---|
| 672 |  | 
|---|
| 673 | case WM_CONTROL: | 
|---|
| 674 | if (hwndStatus2) { | 
|---|
| 675 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 676 | case CBID_EDIT: | 
|---|
| 677 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 678 | switch (SHORT2FROMMP(mp1)) { | 
|---|
| 679 | case EN_SETFOCUS: | 
|---|
| 680 | switch (id) { | 
|---|
| 681 | case MAIN_CMDLIST: | 
|---|
| 682 | WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP)); | 
|---|
| 683 | break; | 
|---|
| 684 | case MAIN_SETUPLIST: | 
|---|
| 685 | WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP)); | 
|---|
| 686 | break; | 
|---|
| 687 | case MAIN_USERLIST: | 
|---|
| 688 | WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP)); | 
|---|
| 689 | break; | 
|---|
| 690 | case MAIN_DRIVELIST: | 
|---|
| 691 | WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP)); | 
|---|
| 692 | break; | 
|---|
| 693 | case MAIN_BUTTONLIST: | 
|---|
| 694 | WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP)); | 
|---|
| 695 | break; | 
|---|
| 696 | default: | 
|---|
| 697 | break; | 
|---|
| 698 | } | 
|---|
| 699 | break; | 
|---|
| 700 |  | 
|---|
| 701 | default: | 
|---|
| 702 | break; | 
|---|
| 703 | } | 
|---|
| 704 | } | 
|---|
| 705 | break; | 
|---|
| 706 |  | 
|---|
| 707 | default: | 
|---|
| 708 | break; | 
|---|
| 709 | } | 
|---|
| 710 | break; | 
|---|
| 711 |  | 
|---|
| 712 | case WM_BEGINDRAG: | 
|---|
| 713 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 714 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%u %s %u",id,(id == CBID_EDIT) ? "TRUE" : "FALSE",WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID) == MAIN_USERLIST); | 
|---|
| 715 | if (id == CBID_EDIT && | 
|---|
| 716 | WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) == | 
|---|
| 717 | MAIN_USERLIST) { | 
|---|
| 718 |  | 
|---|
| 719 | CHAR path[CCHMAXPATH]; | 
|---|
| 720 |  | 
|---|
| 721 | *path = 0; | 
|---|
| 722 | WinQueryWindowText(hwnd, CCHMAXPATH, path); | 
|---|
| 723 | bstrip(path); | 
|---|
| 724 | // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path); | 
|---|
| 725 | if (*path && !IsRoot(path)) | 
|---|
| 726 | DragOne(hwnd, (HWND) 0, path, FALSE); | 
|---|
| 727 | return 0; | 
|---|
| 728 | } | 
|---|
| 729 | break; | 
|---|
| 730 |  | 
|---|
| 731 | case DM_DRAGOVER: | 
|---|
| 732 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 733 | if (id == MAIN_USERLIST) { | 
|---|
| 734 | if (!emphasized) { | 
|---|
| 735 | emphasized = TRUE; | 
|---|
| 736 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 737 | } | 
|---|
| 738 | if (AcceptOneDrop(hwnd, mp1, mp2)) | 
|---|
| 739 | return MRFROM2SHORT(DOR_DROP, DO_MOVE); | 
|---|
| 740 | return MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| 741 | } | 
|---|
| 742 | break; | 
|---|
| 743 |  | 
|---|
| 744 | case DM_DRAGLEAVE: | 
|---|
| 745 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 746 | if (id == MAIN_USERLIST) { | 
|---|
| 747 | if (emphasized) { | 
|---|
| 748 | emphasized = FALSE; | 
|---|
| 749 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 750 | } | 
|---|
| 751 | } | 
|---|
| 752 | break; | 
|---|
| 753 |  | 
|---|
| 754 | case DM_DROPHELP: | 
|---|
| 755 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 756 | if (id == MAIN_USERLIST) { | 
|---|
| 757 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_USERLISTDROPHELP)); | 
|---|
| 758 | return 0; | 
|---|
| 759 | } | 
|---|
| 760 | break; | 
|---|
| 761 |  | 
|---|
| 762 | case DM_DROP: | 
|---|
| 763 | id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID); | 
|---|
| 764 | if (id == MAIN_USERLIST) { | 
|---|
| 765 |  | 
|---|
| 766 | char szFrom[CCHMAXPATH + 2]; | 
|---|
| 767 |  | 
|---|
| 768 | if (emphasized) { | 
|---|
| 769 | emphasized = FALSE; | 
|---|
| 770 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 771 | } | 
|---|
| 772 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) { | 
|---|
| 773 | MakeValidDir(szFrom); | 
|---|
| 774 | WinSetWindowText(hwnd, szFrom); | 
|---|
| 775 | PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 776 | QW_PARENT), | 
|---|
| 777 | QW_PARENT), | 
|---|
| 778 | FID_CLIENT), | 
|---|
| 779 | UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID); | 
|---|
| 780 | return 0; | 
|---|
| 781 | } | 
|---|
| 782 | } | 
|---|
| 783 | break; | 
|---|
| 784 |  | 
|---|
| 785 | case WM_DESTROY: | 
|---|
| 786 | if (hwndMenu) | 
|---|
| 787 | WinDestroyWindow(hwndMenu); | 
|---|
| 788 | hwndMenu = (HWND) 0; | 
|---|
| 789 | break; | 
|---|
| 790 | } | 
|---|
| 791 |  | 
|---|
| 792 | return oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 793 | } | 
|---|
| 794 |  | 
|---|
| 795 | void BubbleHelp(HWND hwnd, BOOL other, BOOL drive, BOOL above, char *help) | 
|---|
| 796 | { | 
|---|
| 797 | if (help && *help && | 
|---|
| 798 | ((drive && fDrivebarHelp) || | 
|---|
| 799 | (other && fOtherHelp) || (!other && !drive && fToolbarHelp))) { | 
|---|
| 800 | if ((!hwndBubble || | 
|---|
| 801 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && | 
|---|
| 802 | !WinQueryCapture(HWND_DESKTOP)) | 
|---|
| 803 | MakeBubble(hwnd, above, help); | 
|---|
| 804 | } | 
|---|
| 805 | } | 
|---|
| 806 |  | 
|---|
| 807 | VOID MakeBubble(HWND hwnd, BOOL above, CHAR * help) | 
|---|
| 808 | { | 
|---|
| 809 | if (!hwnd || !help || !*help) | 
|---|
| 810 | return; | 
|---|
| 811 |  | 
|---|
| 812 | if (hwndBubble) | 
|---|
| 813 | WinDestroyWindow(hwndBubble); | 
|---|
| 814 |  | 
|---|
| 815 | { | 
|---|
| 816 | HWND hwndActive; | 
|---|
| 817 | char ucClassname[8]; | 
|---|
| 818 |  | 
|---|
| 819 | hwndActive = WinQueryActiveWindow(HWND_DESKTOP); | 
|---|
| 820 | if (hwndActive) { | 
|---|
| 821 | /* don't bring up help if window isn't active */ | 
|---|
| 822 | if (!WinIsChild(hwnd, hwndActive)) | 
|---|
| 823 | return; | 
|---|
| 824 | } | 
|---|
| 825 | hwndActive = WinQueryFocus(HWND_DESKTOP); | 
|---|
| 826 | if (WinQueryClassName(hwndActive, sizeof(ucClassname), ucClassname)) { | 
|---|
| 827 | /* don't bring up help if a menu is active */ | 
|---|
| 828 | if (!strcmp(ucClassname, "#4")) | 
|---|
| 829 | return; | 
|---|
| 830 | } | 
|---|
| 831 | } | 
|---|
| 832 |  | 
|---|
| 833 | hwndBubble = WinCreateWindow(HWND_DESKTOP, | 
|---|
| 834 | WC_BUBBLE, | 
|---|
| 835 | help, | 
|---|
| 836 | WS_CLIPSIBLINGS | SS_TEXT | | 
|---|
| 837 | DT_CENTER | DT_VCENTER, | 
|---|
| 838 | 0, | 
|---|
| 839 | 0, | 
|---|
| 840 | 0, | 
|---|
| 841 | 0, | 
|---|
| 842 | HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL); | 
|---|
| 843 | if (!hwndBubble) | 
|---|
| 844 | Win_Error2(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 845 | IDS_WINCREATEWINDOW); | 
|---|
| 846 | else { | 
|---|
| 847 | HPS hps; | 
|---|
| 848 | POINTL aptl[TXTBOX_COUNT], ptl, tptl; | 
|---|
| 849 | LONG lxScreen, sx, sy, extra = 0, lyScreen; | 
|---|
| 850 | char *p, *pp, *wp; | 
|---|
| 851 | SWP swp; | 
|---|
| 852 |  | 
|---|
| 853 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 854 | lyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN); | 
|---|
| 855 | lxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); | 
|---|
| 856 | WinSetWindowULong(hwndBubble, QWL_USER, hwnd); | 
|---|
| 857 | SetPresParams(hwndBubble, NULL, NULL, NULL, GetPString(IDS_8HELVTEXT)); | 
|---|
| 858 | hps = WinGetPS(hwndBubble); | 
|---|
| 859 | p = help; | 
|---|
| 860 | tptl.x = tptl.y = 0; | 
|---|
| 861 | while (p && *p) { | 
|---|
| 862 | wp = NULL; | 
|---|
| 863 | pp = strchr(p, '\r'); | 
|---|
| 864 | if (pp) { | 
|---|
| 865 | wp = pp; | 
|---|
| 866 | *pp = 0; | 
|---|
| 867 | pp++; | 
|---|
| 868 | } | 
|---|
| 869 | GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl); | 
|---|
| 870 | tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x); | 
|---|
| 871 | if (tptl.y) | 
|---|
| 872 | tptl.y += extra; | 
|---|
| 873 | else | 
|---|
| 874 | extra = aptl[TXTBOX_TOPLEFT].y / 4; | 
|---|
| 875 | tptl.y += aptl[TXTBOX_TOPLEFT].y; | 
|---|
| 876 | if (wp) | 
|---|
| 877 | *wp = '\r'; | 
|---|
| 878 | p = pp; | 
|---|
| 879 | } | 
|---|
| 880 | WinSetWindowULong(hwndBubble, QWL_USER + 4, extra); | 
|---|
| 881 | WinReleasePS(hps); | 
|---|
| 882 | ptl.x = ptl.y = 0; | 
|---|
| 883 | WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptl, 1); | 
|---|
| 884 | if (above) { | 
|---|
| 885 | sy = ptl.y + swp.cy + 4; | 
|---|
| 886 | if (sy + tptl.y + 12 > lyScreen) { | 
|---|
| 887 | above = FALSE; | 
|---|
| 888 | sy = ptl.y - (tptl.y + 14); | 
|---|
| 889 | } | 
|---|
| 890 | } | 
|---|
| 891 | else | 
|---|
| 892 | sy = ptl.y - (tptl.y + 14); | 
|---|
| 893 | if (ptl.x > (lxScreen / 2)) | 
|---|
| 894 | sx = (ptl.x - tptl.x) - 16; | 
|---|
| 895 | else | 
|---|
| 896 | sx = ptl.x + (54 * (above == FALSE)) + 2; | 
|---|
| 897 | if (sx < 0) | 
|---|
| 898 | sx = 0; | 
|---|
| 899 | if (sx + tptl.x + 14 > lxScreen) | 
|---|
| 900 | sx = lxScreen - (tptl.x + 14); | 
|---|
| 901 | if (sy < 0) { | 
|---|
| 902 | sy = ptl.y + swp.cy + 4; | 
|---|
| 903 | if (sy + tptl.y + 12 > lyScreen) | 
|---|
| 904 | sy = 0; | 
|---|
| 905 | } | 
|---|
| 906 | WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy, | 
|---|
| 907 | tptl.x + 14, | 
|---|
| 908 | tptl.y + 12, | 
|---|
| 909 | SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER | | 
|---|
| 910 | SWP_MOVE | SWP_SIZE); | 
|---|
| 911 | } | 
|---|
| 912 | } | 
|---|
| 913 |  | 
|---|
| 914 | MRESULT EXPENTRY BubbleProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 915 | { | 
|---|
| 916 | switch (msg) { | 
|---|
| 917 | case WM_SETFOCUS: | 
|---|
| 918 | if (mp2) | 
|---|
| 919 | PostMsg(hwnd, UM_FOCUSME, mp1, MPVOID); | 
|---|
| 920 | break; | 
|---|
| 921 |  | 
|---|
| 922 | case UM_FOCUSME: | 
|---|
| 923 | WinSetFocus(HWND_DESKTOP, (HWND) mp1); | 
|---|
| 924 | return 0; | 
|---|
| 925 |  | 
|---|
| 926 | case WM_MOUSEMOVE: | 
|---|
| 927 | WinShowWindow(hwnd, FALSE); | 
|---|
| 928 | break; | 
|---|
| 929 |  | 
|---|
| 930 | case UM_TIMER: | 
|---|
| 931 | { | 
|---|
| 932 | POINTL ptl; | 
|---|
| 933 |  | 
|---|
| 934 | WinQueryPointerPos(HWND_DESKTOP, &ptl); | 
|---|
| 935 | if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) != | 
|---|
| 936 | WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd)) | 
|---|
| 937 | WinDestroyWindow(hwnd); | 
|---|
| 938 | } | 
|---|
| 939 | return 0; | 
|---|
| 940 |  | 
|---|
| 941 | case WM_PAINT: | 
|---|
| 942 | { | 
|---|
| 943 | HPS hps; | 
|---|
| 944 | SWP swp; | 
|---|
| 945 | POINTL ptl, aptl[TXTBOX_COUNT]; | 
|---|
| 946 | CHAR *s, *p, *pp, *wp; | 
|---|
| 947 | ULONG extra, tlen, y; | 
|---|
| 948 |  | 
|---|
| 949 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL); | 
|---|
| 950 | if (hps) { | 
|---|
| 951 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 952 | GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0); | 
|---|
| 953 | GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198)); | 
|---|
| 954 | GpiSetBackMix(hps, BM_LEAVEALONE); | 
|---|
| 955 | GpiSetMix(hps, FM_OVERPAINT); | 
|---|
| 956 | ptl.x = ptl.y = 0; | 
|---|
| 957 | GpiMove(hps, &ptl); | 
|---|
| 958 | ptl.x = swp.cx - 1; | 
|---|
| 959 | ptl.y = swp.cy - 1; | 
|---|
| 960 | GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0); | 
|---|
| 961 | tlen = WinQueryWindowTextLength(hwnd); | 
|---|
| 962 | if (tlen) { | 
|---|
| 963 | s = xmalloc(tlen + 2, pszSrcFile, __LINE__); | 
|---|
| 964 | if (s) { | 
|---|
| 965 | WinQueryWindowText(hwnd, tlen + 1, s); | 
|---|
| 966 | if (*s) { | 
|---|
| 967 | p = s; | 
|---|
| 968 | y = swp.cy - 3; | 
|---|
| 969 | extra = WinQueryWindowULong(hwnd, QWL_USER + 4); | 
|---|
| 970 | GpiSetColor(hps, 0); | 
|---|
| 971 | GpiSetMix(hps, FM_OVERPAINT); | 
|---|
| 972 | while (p && *p) { | 
|---|
| 973 | wp = NULL; | 
|---|
| 974 | pp = strchr(p, '\r'); | 
|---|
| 975 | if (pp) { | 
|---|
| 976 | wp = pp; | 
|---|
| 977 | *pp = 0; | 
|---|
| 978 | pp++; | 
|---|
| 979 | } | 
|---|
| 980 | GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl); | 
|---|
| 981 | ptl.x = 7; | 
|---|
| 982 | y -= aptl[TXTBOX_TOPLEFT].y; | 
|---|
| 983 | if (p != s) | 
|---|
| 984 | y -= extra; | 
|---|
| 985 | ptl.y = y; | 
|---|
| 986 | GpiCharStringAt(hps, &ptl, strlen(p), p); | 
|---|
| 987 | if (wp) | 
|---|
| 988 | *wp = '\r'; | 
|---|
| 989 | p = pp; | 
|---|
| 990 | } | 
|---|
| 991 | } | 
|---|
| 992 | free(s); | 
|---|
| 993 | } | 
|---|
| 994 | } | 
|---|
| 995 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) { | 
|---|
| 996 | GpiSetColor(hps, CLR_WHITE); | 
|---|
| 997 | ptl.x = 1; | 
|---|
| 998 | ptl.y = 1; | 
|---|
| 999 | GpiMove(hps, &ptl); | 
|---|
| 1000 | ptl.y = swp.cy - 2; | 
|---|
| 1001 | GpiLine(hps, &ptl); | 
|---|
| 1002 | ptl.x = swp.cx - 2; | 
|---|
| 1003 | GpiLine(hps, &ptl); | 
|---|
| 1004 | ptl.x = 2; | 
|---|
| 1005 | ptl.y = 2; | 
|---|
| 1006 | GpiMove(hps, &ptl); | 
|---|
| 1007 | ptl.y = swp.cy - 3; | 
|---|
| 1008 | GpiLine(hps, &ptl); | 
|---|
| 1009 | ptl.x = swp.cx - 3; | 
|---|
| 1010 | GpiLine(hps, &ptl); | 
|---|
| 1011 | GpiSetColor(hps, CLR_BROWN); | 
|---|
| 1012 | ptl.x = 1; | 
|---|
| 1013 | ptl.y = 1; | 
|---|
| 1014 | GpiMove(hps, &ptl); | 
|---|
| 1015 | ptl.x = swp.cx - 2; | 
|---|
| 1016 | GpiLine(hps, &ptl); | 
|---|
| 1017 | ptl.y = swp.cy - 2; | 
|---|
| 1018 | GpiLine(hps, &ptl); | 
|---|
| 1019 | ptl.x = 2; | 
|---|
| 1020 | ptl.y = 2; | 
|---|
| 1021 | GpiMove(hps, &ptl); | 
|---|
| 1022 | ptl.x = swp.cx - 3; | 
|---|
| 1023 | GpiLine(hps, &ptl); | 
|---|
| 1024 | ptl.y = swp.cy - 3; | 
|---|
| 1025 | GpiLine(hps, &ptl); | 
|---|
| 1026 | } | 
|---|
| 1027 | WinEndPaint(hps); | 
|---|
| 1028 | } | 
|---|
| 1029 | } | 
|---|
| 1030 | return 0; | 
|---|
| 1031 |  | 
|---|
| 1032 | case WM_CLOSE: | 
|---|
| 1033 | WinDestroyWindow(hwnd); | 
|---|
| 1034 | return 0; | 
|---|
| 1035 |  | 
|---|
| 1036 | case WM_DESTROY: | 
|---|
| 1037 | hwndBubble = (HWND) 0; | 
|---|
| 1038 | break; | 
|---|
| 1039 | } | 
|---|
| 1040 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 1041 | } | 
|---|
| 1042 |  | 
|---|
| 1043 | MRESULT EXPENTRY LEDProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1044 | { | 
|---|
| 1045 | switch (msg) { | 
|---|
| 1046 | case WM_CREATE: | 
|---|
| 1047 | { | 
|---|
| 1048 | MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 1049 | HBITMAP hbmold = (HBITMAP) 0; | 
|---|
| 1050 | HPS hps = (HPS) 0; | 
|---|
| 1051 |  | 
|---|
| 1052 | switch (WinQueryWindowUShort(hwnd, QWS_ID)) { | 
|---|
| 1053 | case MAIN_LED: | 
|---|
| 1054 | hps = WinGetPS(hwnd); | 
|---|
| 1055 | hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID); | 
|---|
| 1056 | if (!fBlueLED) { | 
|---|
| 1057 | hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12); | 
|---|
| 1058 | hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12); | 
|---|
| 1059 | } | 
|---|
| 1060 | else { | 
|---|
| 1061 | hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12); | 
|---|
| 1062 | hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12); | 
|---|
| 1063 | } | 
|---|
| 1064 | if (hbmLEDoff && hbmLEDon) | 
|---|
| 1065 | WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID); | 
|---|
| 1066 | else { | 
|---|
| 1067 | if (hbmLEDoff) | 
|---|
| 1068 | GpiDeleteBitmap(hbmLEDoff); | 
|---|
| 1069 | if (hbmLEDon) | 
|---|
| 1070 | GpiDeleteBitmap(hbmLEDon); | 
|---|
| 1071 | } | 
|---|
| 1072 | if (hbmold && | 
|---|
| 1073 | hbmLEDon && | 
|---|
| 1074 | hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff) | 
|---|
| 1075 | GpiDeleteBitmap(hbmold); | 
|---|
| 1076 | if (hps) | 
|---|
| 1077 | WinReleasePS(hps); | 
|---|
| 1078 | break; | 
|---|
| 1079 | default: | 
|---|
| 1080 | SetPresParams(hwnd, | 
|---|
| 1081 | &RGBGREY, | 
|---|
| 1082 | &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT)); | 
|---|
| 1083 | break; | 
|---|
| 1084 | } | 
|---|
| 1085 | return mr; | 
|---|
| 1086 | } | 
|---|
| 1087 |  | 
|---|
| 1088 | case WM_SETFOCUS: | 
|---|
| 1089 | if (mp2) | 
|---|
| 1090 | PostMsg(hwnd, UM_FOCUSME, mp1, MPVOID); | 
|---|
| 1091 | break; | 
|---|
| 1092 |  | 
|---|
| 1093 | case UM_FOCUSME: | 
|---|
| 1094 | WinSetFocus(HWND_DESKTOP, (HWND) mp1); | 
|---|
| 1095 | return 0; | 
|---|
| 1096 |  | 
|---|
| 1097 | case WM_MOUSEMOVE: | 
|---|
| 1098 | BubbleHelp(hwnd, TRUE, FALSE, FALSE, GetPString(IDS_LEDHELP)); | 
|---|
| 1099 | if (!fNoFinger) { | 
|---|
| 1100 | WinSetPointer(HWND_DESKTOP, hptrFinger); | 
|---|
| 1101 | return MRFROMLONG(TRUE); | 
|---|
| 1102 | } | 
|---|
| 1103 | break; | 
|---|
| 1104 |  | 
|---|
| 1105 | case WM_BUTTON1CLICK: | 
|---|
| 1106 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1107 | WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID); | 
|---|
| 1108 | break; | 
|---|
| 1109 |  | 
|---|
| 1110 | case WM_BUTTON2CLICK: | 
|---|
| 1111 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1112 | WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID); | 
|---|
| 1113 | break; | 
|---|
| 1114 |  | 
|---|
| 1115 | case WM_CHORD: | 
|---|
| 1116 | case WM_BUTTON3CLICK: | 
|---|
| 1117 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1118 | WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID); | 
|---|
| 1119 | break; | 
|---|
| 1120 | } | 
|---|
| 1121 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 1122 | } | 
|---|
| 1123 |  | 
|---|
| 1124 | MRESULT EXPENTRY ChildButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1125 | { | 
|---|
| 1126 | USHORT id; | 
|---|
| 1127 | TOOL *tool; | 
|---|
| 1128 |  | 
|---|
| 1129 | static HWND hwndMenu = (HWND) 0; | 
|---|
| 1130 |  | 
|---|
| 1131 | switch (msg) { | 
|---|
| 1132 | case WM_BUTTON1DOWN: | 
|---|
| 1133 | case WM_BUTTON2DOWN: | 
|---|
| 1134 | case WM_BUTTON3DOWN: | 
|---|
| 1135 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 1136 | break; | 
|---|
| 1137 |  | 
|---|
| 1138 | case WM_MOUSEMOVE: | 
|---|
| 1139 | if (fToolbarHelp) { | 
|---|
| 1140 | if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) | 
|---|
| 1141 | && !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 1142 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1143 | tool = find_tool(id); | 
|---|
| 1144 | if (tool && tool->help && *tool->help) { | 
|---|
| 1145 |  | 
|---|
| 1146 | char s[128]; | 
|---|
| 1147 |  | 
|---|
| 1148 | strcpy(s, tool->help); | 
|---|
| 1149 | if (tool->flags & T_DROPABLE) | 
|---|
| 1150 | strcat(s, GetPString(IDS_DROPONMETEXT)); | 
|---|
| 1151 | MakeBubble(hwnd, FALSE, s); | 
|---|
| 1152 | } | 
|---|
| 1153 | } | 
|---|
| 1154 | } | 
|---|
| 1155 | break; | 
|---|
| 1156 |  | 
|---|
| 1157 | case WM_COMMAND: | 
|---|
| 1158 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 1159 | case IDM_HELP: | 
|---|
| 1160 | if (hwndHelp) | 
|---|
| 1161 | WinSendMsg(hwndHelp, | 
|---|
| 1162 | HM_DISPLAY_HELP, | 
|---|
| 1163 | MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 1164 | break; | 
|---|
| 1165 |  | 
|---|
| 1166 | case IDM_HIDEANYTOOL:               /* hide any tool */ | 
|---|
| 1167 | case IDM_HIDETOOL:                  /* hide tool */ | 
|---|
| 1168 | if (SHORT1FROMMP(mp1) == IDM_HIDETOOL) | 
|---|
| 1169 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1170 | else | 
|---|
| 1171 | id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, | 
|---|
| 1172 | PickToolProc, FM3ModHandle, | 
|---|
| 1173 | PICKBTN_FRAME, GetPString(IDS_HIDETEXT)); | 
|---|
| 1174 | if (id) { | 
|---|
| 1175 | tool = find_tool(id); | 
|---|
| 1176 | if (tool) { | 
|---|
| 1177 | tool->flags |= T_INVISIBLE; | 
|---|
| 1178 | fToolsChanged = TRUE; | 
|---|
| 1179 | } | 
|---|
| 1180 | } | 
|---|
| 1181 | break; | 
|---|
| 1182 |  | 
|---|
| 1183 | case IDM_SHOWTOOLS:                 /* show all tools */ | 
|---|
| 1184 | tool = toolhead; | 
|---|
| 1185 | while (tool) { | 
|---|
| 1186 | tool->flags &= (~T_INVISIBLE); | 
|---|
| 1187 | tool = tool->next; | 
|---|
| 1188 | fToolsChanged = TRUE; | 
|---|
| 1189 | } | 
|---|
| 1190 | break; | 
|---|
| 1191 |  | 
|---|
| 1192 | case IDM_DELETEANYTOOL:             /* delete any button */ | 
|---|
| 1193 | case IDM_DELETETOOL:                /* delete button */ | 
|---|
| 1194 | if (SHORT1FROMMP(mp1) == IDM_DELETETOOL) | 
|---|
| 1195 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1196 | else | 
|---|
| 1197 | id = | 
|---|
| 1198 | (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle, | 
|---|
| 1199 | PICKBTN_FRAME, GetPString(IDS_DELETETEXT)); | 
|---|
| 1200 | if (id) | 
|---|
| 1201 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP, | 
|---|
| 1202 | MPFROM2SHORT(id, 0), MPVOID); | 
|---|
| 1203 | return 0; | 
|---|
| 1204 |  | 
|---|
| 1205 | case IDM_EDITANYTOOL:               /* edit any button */ | 
|---|
| 1206 | case IDM_EDITTOOL:                  /* edit button */ | 
|---|
| 1207 | if (SHORT1FROMMP(mp1) == IDM_EDITTOOL) | 
|---|
| 1208 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1209 | else | 
|---|
| 1210 | id = | 
|---|
| 1211 | (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle, | 
|---|
| 1212 | PICKBTN_FRAME, GetPString(IDS_EDITTEXT)); | 
|---|
| 1213 | if (id) { | 
|---|
| 1214 | tool = find_tool(id); | 
|---|
| 1215 | if (tool) { | 
|---|
| 1216 | if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle, | 
|---|
| 1217 | ADDBTN_FRAME, (PVOID) tool)) | 
|---|
| 1218 | WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 1219 | QW_PARENT), | 
|---|
| 1220 | QW_PARENT), FID_CLIENT), | 
|---|
| 1221 | WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0), | 
|---|
| 1222 | MPFROM2SHORT(id, 0)); | 
|---|
| 1223 | } | 
|---|
| 1224 | } | 
|---|
| 1225 | break; | 
|---|
| 1226 |  | 
|---|
| 1227 | case IDM_ADDTOOL:                   /* add tool */ | 
|---|
| 1228 | id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle, | 
|---|
| 1229 | ADDBTN_FRAME, MPVOID); | 
|---|
| 1230 | if (id && id != (USHORT) - 1) | 
|---|
| 1231 | WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 1232 | QW_PARENT), | 
|---|
| 1233 | QW_PARENT), FID_CLIENT), | 
|---|
| 1234 | WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0), | 
|---|
| 1235 | MPFROM2SHORT(id, 0)); | 
|---|
| 1236 | break; | 
|---|
| 1237 |  | 
|---|
| 1238 | case IDM_REORDERTOOLS:              /* reorder tools */ | 
|---|
| 1239 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 1240 | hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID); | 
|---|
| 1241 | break; | 
|---|
| 1242 |  | 
|---|
| 1243 | case IDM_SAVETOOLS: | 
|---|
| 1244 | case IDM_LOADTOOLS: | 
|---|
| 1245 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 1246 | hwnd, | 
|---|
| 1247 | ToolIODlgProc, | 
|---|
| 1248 | FM3ModHandle, | 
|---|
| 1249 | SVBTN_FRAME, | 
|---|
| 1250 | (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ? | 
|---|
| 1251 | "TRUE" : NULL)) | 
|---|
| 1252 | BuildTools(hwndToolback, TRUE); | 
|---|
| 1253 | break; | 
|---|
| 1254 | } | 
|---|
| 1255 | ResizeTools(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 1256 | return 0; | 
|---|
| 1257 |  | 
|---|
| 1258 | case WM_MENUEND: | 
|---|
| 1259 | if (hwndMenu == (HWND) mp2) { | 
|---|
| 1260 | WinDestroyWindow(hwndMenu); | 
|---|
| 1261 | hwndMenu = (HWND) 0; | 
|---|
| 1262 | } | 
|---|
| 1263 | break; | 
|---|
| 1264 |  | 
|---|
| 1265 | case WM_CONTEXTMENU: | 
|---|
| 1266 | DosEnterCritSec(); | 
|---|
| 1267 | if (!hwndMenu) | 
|---|
| 1268 | hwndMenu = WinLoadMenu(hwnd, FM3ModHandle, ID_BUTTONMENU); | 
|---|
| 1269 | DosExitCritSec(); | 
|---|
| 1270 | SetPresParams(hwndMenu, NULL, NULL, NULL, GetPString(IDS_10SYSPROTEXT)); | 
|---|
| 1271 | if (PopupMenu(hwnd, hwnd, hwndMenu)) | 
|---|
| 1272 | WinShowWindow(hwndMenu, TRUE); | 
|---|
| 1273 | return MRFROMSHORT(TRUE); | 
|---|
| 1274 |  | 
|---|
| 1275 | case DM_DRAGOVER: | 
|---|
| 1276 | { | 
|---|
| 1277 | PDRAGINFO pDInfo;                 /* Pointer to DRAGINFO */ | 
|---|
| 1278 |  | 
|---|
| 1279 | pDInfo = (PDRAGINFO) mp1;         /* Get DRAGINFO pointer */ | 
|---|
| 1280 | DrgAccessDraginfo(pDInfo);        /* Access DRAGINFO */ | 
|---|
| 1281 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1282 | tool = find_tool(id); | 
|---|
| 1283 | if (!tool) { | 
|---|
| 1284 | DrgFreeDraginfo(pDInfo); | 
|---|
| 1285 | return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */ | 
|---|
| 1286 | } | 
|---|
| 1287 | if (!(tool->flags & T_DROPABLE)) { | 
|---|
| 1288 | DrgFreeDraginfo(pDInfo); | 
|---|
| 1289 | return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */ | 
|---|
| 1290 | } | 
|---|
| 1291 | { | 
|---|
| 1292 | PDRAGITEM pDItem;               /* Pointer to DRAGITEM */ | 
|---|
| 1293 |  | 
|---|
| 1294 | pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */ | 
|---|
| 1295 | 0);        /* Index to DRAGITEM */ | 
|---|
| 1296 | if (DrgVerifyRMF(pDItem,        /* Check valid rendering */ | 
|---|
| 1297 | DRM_OS2FILE,   /* mechanisms and data */ | 
|---|
| 1298 | NULL)) {       /* formats */ | 
|---|
| 1299 | if (!(tool->flags & T_EMPHASIZED)) { | 
|---|
| 1300 | tool->flags |= T_EMPHASIZED; | 
|---|
| 1301 | DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0)); | 
|---|
| 1302 | DrgFreeDraginfo(pDInfo); | 
|---|
| 1303 | } | 
|---|
| 1304 | return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */ | 
|---|
| 1305 | DO_MOVE));       /* Move operation valid */ | 
|---|
| 1306 | } | 
|---|
| 1307 | DrgFreeDraginfo(pDInfo); | 
|---|
| 1308 | } | 
|---|
| 1309 | } | 
|---|
| 1310 | return (MRFROM2SHORT(DOR_NEVERDROP, 0));    /* Drop not valid */ | 
|---|
| 1311 |  | 
|---|
| 1312 | case DM_DROPHELP: | 
|---|
| 1313 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1314 | tool = find_tool(id); | 
|---|
| 1315 | PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 1316 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_TOOLDROPHELP)); | 
|---|
| 1317 | return 0; | 
|---|
| 1318 |  | 
|---|
| 1319 | case DM_DRAGLEAVE: | 
|---|
| 1320 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1321 | tool = find_tool(id); | 
|---|
| 1322 | if (tool && (tool->flags & T_DROPABLE)) { | 
|---|
| 1323 | if (tool->flags & T_EMPHASIZED) { | 
|---|
| 1324 | tool->flags &= (~T_EMPHASIZED); | 
|---|
| 1325 | DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0)); | 
|---|
| 1326 | } | 
|---|
| 1327 | } | 
|---|
| 1328 | break; | 
|---|
| 1329 |  | 
|---|
| 1330 | case DM_DROP: | 
|---|
| 1331 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1332 | tool = find_tool(id); | 
|---|
| 1333 | if (tool && (tool->flags & T_DROPABLE) != 0) { | 
|---|
| 1334 | LISTINFO *li; | 
|---|
| 1335 | CNRDRAGINFO cdi; | 
|---|
| 1336 |  | 
|---|
| 1337 | if (tool->flags & T_EMPHASIZED) { | 
|---|
| 1338 | DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0)); | 
|---|
| 1339 | tool->flags &= (~T_EMPHASIZED); | 
|---|
| 1340 | } | 
|---|
| 1341 | memset(&cdi, 0, sizeof(cdi)); | 
|---|
| 1342 | cdi.pDragInfo = mp1; | 
|---|
| 1343 | li = DoFileDrop(hwnd, NULL, FALSE, mp1, MPFROMP(&cdi)); | 
|---|
| 1344 | CheckPmDrgLimit(cdi.pDragInfo); | 
|---|
| 1345 | if (li) { | 
|---|
| 1346 | li->type = id; | 
|---|
| 1347 | if (!li->list || !li->list[0]) | 
|---|
| 1348 | FreeListInfo(li); | 
|---|
| 1349 | else { | 
|---|
| 1350 | HWND hwndActive; | 
|---|
| 1351 |  | 
|---|
| 1352 | hwndActive = TopWindow(hwndMain, (HWND) 0); | 
|---|
| 1353 | if (hwndActive) { | 
|---|
| 1354 | if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID)) | 
|---|
| 1355 | FreeListInfo(li); | 
|---|
| 1356 | } | 
|---|
| 1357 | else | 
|---|
| 1358 | FreeListInfo(li); | 
|---|
| 1359 | } | 
|---|
| 1360 | } | 
|---|
| 1361 | } | 
|---|
| 1362 | return 0; | 
|---|
| 1363 |  | 
|---|
| 1364 | case WM_CLOSE: | 
|---|
| 1365 | WinDestroyWindow(hwnd); | 
|---|
| 1366 | return 0; | 
|---|
| 1367 | } | 
|---|
| 1368 | return PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 1369 | } | 
|---|
| 1370 |  | 
|---|
| 1371 | VOID BuildTools(HWND hwndT, BOOL resize) | 
|---|
| 1372 | { | 
|---|
| 1373 | TOOL *tool; | 
|---|
| 1374 | ULONG ctrlxpos = 18L; | 
|---|
| 1375 | CHAR s[33]; | 
|---|
| 1376 | HENUM henum; | 
|---|
| 1377 | HWND hwndTool; | 
|---|
| 1378 |  | 
|---|
| 1379 | henum = WinBeginEnumWindows(hwndT); | 
|---|
| 1380 | while ((hwndTool = WinGetNextWindow(henum)) != NULLHANDLE) | 
|---|
| 1381 | WinDestroyWindow(hwndTool); | 
|---|
| 1382 | WinEndEnumWindows(henum); | 
|---|
| 1383 | if (!fToolbar) { | 
|---|
| 1384 | load_quicktools(); | 
|---|
| 1385 | load_tools(NULL); | 
|---|
| 1386 | return; | 
|---|
| 1387 | } | 
|---|
| 1388 | if (!toolhead) | 
|---|
| 1389 | load_tools(NULL); | 
|---|
| 1390 | tool = toolhead; | 
|---|
| 1391 | while (tool) { | 
|---|
| 1392 | sprintf(s, "#%u", tool->id); | 
|---|
| 1393 | hwndTool = (HWND) 0; | 
|---|
| 1394 | if (!fTextTools) { | 
|---|
| 1395 | if (!(tool->flags & T_MYICON)) { | 
|---|
| 1396 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1397 | WC_TOOLBUTTONS, | 
|---|
| 1398 | s, | 
|---|
| 1399 | BS_NOPOINTERFOCUS | | 
|---|
| 1400 | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 1401 | ctrlxpos, | 
|---|
| 1402 | 14, | 
|---|
| 1403 | 32, | 
|---|
| 1404 | 32, hwndT, HWND_TOP, tool->id, NULL, NULL); | 
|---|
| 1405 | } | 
|---|
| 1406 | if (!hwndTool) { | 
|---|
| 1407 | HBITMAP hbm = LoadBitmapFromFileNum(tool->id); | 
|---|
| 1408 |  | 
|---|
| 1409 | if (hbm) { | 
|---|
| 1410 | BTNCDATA btc; | 
|---|
| 1411 |  | 
|---|
| 1412 | memset(&btc, 0, sizeof(btc)); | 
|---|
| 1413 | btc.cb = sizeof(btc); | 
|---|
| 1414 | btc.hImage = hbm; | 
|---|
| 1415 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1416 | WC_TOOLBUTTONS, | 
|---|
| 1417 | NullStr, | 
|---|
| 1418 | BS_NOPOINTERFOCUS | | 
|---|
| 1419 | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 1420 | ctrlxpos, | 
|---|
| 1421 | 14, | 
|---|
| 1422 | 32, | 
|---|
| 1423 | 32, | 
|---|
| 1424 | hwndT, HWND_TOP, tool->id, &btc, NULL); | 
|---|
| 1425 | if (!hwndTool) | 
|---|
| 1426 | GpiDeleteBitmap(hbm); | 
|---|
| 1427 | } | 
|---|
| 1428 | } | 
|---|
| 1429 | if (hwndTool) | 
|---|
| 1430 | tool->flags &= (~T_TEXT); | 
|---|
| 1431 | } | 
|---|
| 1432 | if (!hwndTool) { | 
|---|
| 1433 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1434 | WC_TOOLBUTTONS, | 
|---|
| 1435 | (!tool->text && tool->id >= IDM_COMMANDSTART | 
|---|
| 1436 | && tool->id < | 
|---|
| 1437 | IDM_QUICKTOOLSTART) ? command_title(tool-> | 
|---|
| 1438 | id - | 
|---|
| 1439 | IDM_COMMANDSTART) | 
|---|
| 1440 | : tool->text, | 
|---|
| 1441 | BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos, | 
|---|
| 1442 | 2, 54, 24, hwndT, HWND_TOP, tool->id, NULL, | 
|---|
| 1443 | NULL); | 
|---|
| 1444 | if (!hwndTool) | 
|---|
| 1445 | Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1446 | IDS_WINCREATEWINDOW); | 
|---|
| 1447 | tool->flags |= T_TEXT; | 
|---|
| 1448 | } | 
|---|
| 1449 | if (fToolTitles && !fTextTools) { | 
|---|
| 1450 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1451 | WC_STATIC, | 
|---|
| 1452 | tool->text, | 
|---|
| 1453 | SS_TEXT | DT_LEFT | DT_VCENTER, | 
|---|
| 1454 | ctrlxpos, | 
|---|
| 1455 | 1, | 
|---|
| 1456 | 32, | 
|---|
| 1457 | 10, | 
|---|
| 1458 | hwndT, | 
|---|
| 1459 | HWND_TOP, tool->id + 25000, NULL, NULL); | 
|---|
| 1460 | if (!hwndTool) | 
|---|
| 1461 | Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1462 | IDS_WINCREATEWINDOW); | 
|---|
| 1463 | else { | 
|---|
| 1464 | SetPresParams(hwndTool, | 
|---|
| 1465 | &RGBGREY, | 
|---|
| 1466 | &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT)); | 
|---|
| 1467 | } | 
|---|
| 1468 | } | 
|---|
| 1469 | ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L); | 
|---|
| 1470 | SetPresParams(WinWindowFromID(hwndT, tool->id), | 
|---|
| 1471 | NULL, NULL, NULL, GetPString(IDS_8HELVTEXT)); | 
|---|
| 1472 | tool = tool->next; | 
|---|
| 1473 | }                                     // while tool | 
|---|
| 1474 |  | 
|---|
| 1475 | hwndTool = WinCreateWindow(hwndT, | 
|---|
| 1476 | WC_BUTTON, | 
|---|
| 1477 | "#6010", | 
|---|
| 1478 | BS_NOPOINTERFOCUS | | 
|---|
| 1479 | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 1480 | 1, | 
|---|
| 1481 | 19, | 
|---|
| 1482 | 14, | 
|---|
| 1483 | 13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL); | 
|---|
| 1484 | if (!hwndTool) | 
|---|
| 1485 | Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1486 | IDS_WINCREATEWINDOW); | 
|---|
| 1487 | hwndTool = | 
|---|
| 1488 | WinCreateWindow(hwndT, WC_BUTTON, "#6011", | 
|---|
| 1489 | BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14, | 
|---|
| 1490 | 13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL); | 
|---|
| 1491 | if (!hwndTool) | 
|---|
| 1492 | Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1493 | IDS_WINCREATEWINDOW); | 
|---|
| 1494 | if (resize) | 
|---|
| 1495 | ResizeTools(hwndT); | 
|---|
| 1496 | } | 
|---|
| 1497 |  | 
|---|
| 1498 | static MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 1499 | MPARAM mp2) | 
|---|
| 1500 | { | 
|---|
| 1501 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 1502 | static BOOL lbup = FALSE; | 
|---|
| 1503 |  | 
|---|
| 1504 | switch (msg) { | 
|---|
| 1505 | case UM_FOCUSME: | 
|---|
| 1506 | WinSetFocus(HWND_DESKTOP, hwnd); | 
|---|
| 1507 | return 0; | 
|---|
| 1508 |  | 
|---|
| 1509 | case WM_SETFOCUS: | 
|---|
| 1510 | if (!mp2 && !lbup) { | 
|---|
| 1511 |  | 
|---|
| 1512 | PID pid; | 
|---|
| 1513 | TID tid; | 
|---|
| 1514 |  | 
|---|
| 1515 | if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON) | 
|---|
| 1516 | break; | 
|---|
| 1517 | if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || pid == mypid) | 
|---|
| 1518 | WinDestroyWindow(hwnd); | 
|---|
| 1519 | } | 
|---|
| 1520 | break; | 
|---|
| 1521 |  | 
|---|
| 1522 | case UM_RESCAN: | 
|---|
| 1523 | { | 
|---|
| 1524 | CHAR cl[1024]; | 
|---|
| 1525 |  | 
|---|
| 1526 | *cl = 0; | 
|---|
| 1527 | lbup = TRUE; | 
|---|
| 1528 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 1529 | hwnd, | 
|---|
| 1530 | CmdLine2DlgProc, | 
|---|
| 1531 | FM3ModHandle, EXEC2_FRAME, MPFROMP(cl))) { | 
|---|
| 1532 | lstrip(cl); | 
|---|
| 1533 | WinSetWindowText(hwnd, cl); | 
|---|
| 1534 | } | 
|---|
| 1535 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 1536 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 1537 | } | 
|---|
| 1538 | return 0; | 
|---|
| 1539 |  | 
|---|
| 1540 | case UM_SETUP: | 
|---|
| 1541 | lbup = FALSE; | 
|---|
| 1542 | return 0; | 
|---|
| 1543 |  | 
|---|
| 1544 | case WM_BUTTON1DBLCLK: | 
|---|
| 1545 | PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID); | 
|---|
| 1546 | return 0; | 
|---|
| 1547 |  | 
|---|
| 1548 | case WM_COMMAND: | 
|---|
| 1549 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 1550 | case COMMAND_BUTTON: | 
|---|
| 1551 | if (!lbup) | 
|---|
| 1552 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1553 | break; | 
|---|
| 1554 | } | 
|---|
| 1555 | return 0; | 
|---|
| 1556 |  | 
|---|
| 1557 | case UM_OPENWINDOWFORME: | 
|---|
| 1558 | { | 
|---|
| 1559 | static char directory[CCHMAXPATH], cl[1000]; | 
|---|
| 1560 | char **list = NULL; | 
|---|
| 1561 | ULONG len; | 
|---|
| 1562 | HWND hwndCnr; | 
|---|
| 1563 |  | 
|---|
| 1564 | *directory = *cl = 0; | 
|---|
| 1565 | strcpy(cl, GetCmdSpec(FALSE)); | 
|---|
| 1566 | strcat(cl, " /C "); | 
|---|
| 1567 | len = strlen(cl); | 
|---|
| 1568 | WinQueryWindowText(hwnd, 1000 - len, cl + len); | 
|---|
| 1569 | bstrip(cl + len); | 
|---|
| 1570 | if (strlen(cl) > len) { | 
|---|
| 1571 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1572 | UM_SETUP, MPFROMP(cl + len), MPVOID); | 
|---|
| 1573 | WinQueryWindowText(hwndStatus, CCHMAXPATH, directory); | 
|---|
| 1574 | bstrip(directory); | 
|---|
| 1575 | if (*directory && (IsRoot(directory) || !IsFile(directory))) { | 
|---|
| 1576 | if (!FM2Command(directory, cl + len)) { | 
|---|
| 1577 | hwndCnr = TopWindow(hwndMain, (HWND) 0); | 
|---|
| 1578 | if (hwndCnr) { | 
|---|
| 1579 | hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT); | 
|---|
| 1580 | if (hwndCnr) { | 
|---|
| 1581 | hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR); | 
|---|
| 1582 | if (hwndCnr) | 
|---|
| 1583 | list = BuildList(hwndCnr); | 
|---|
| 1584 | } | 
|---|
| 1585 | } | 
|---|
| 1586 | WinSetActiveWindow(HWND_DESKTOP, hwndCnr); | 
|---|
| 1587 | if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds) | 
|---|
| 1588 | save_cmdlines(FALSE); | 
|---|
| 1589 | ExecOnList(hwndCnr, | 
|---|
| 1590 | cl, | 
|---|
| 1591 | WINDOWED | ((fKeepCmdLine) ? | 
|---|
| 1592 | SEPARATEKEEP : SEPARATE), | 
|---|
| 1593 | directory, list, NULL); | 
|---|
| 1594 | if (list) | 
|---|
| 1595 | free(list); | 
|---|
| 1596 | WinDestroyWindow(hwnd); | 
|---|
| 1597 | break; | 
|---|
| 1598 | } | 
|---|
| 1599 | } | 
|---|
| 1600 | } | 
|---|
| 1601 | WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID); | 
|---|
| 1602 | } | 
|---|
| 1603 | return 0; | 
|---|
| 1604 |  | 
|---|
| 1605 | case WM_CHAR: | 
|---|
| 1606 | if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) { | 
|---|
| 1607 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) { | 
|---|
| 1608 | if ((SHORT1FROMMP(mp2) & 255) == '\r') | 
|---|
| 1609 | PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID); | 
|---|
| 1610 | else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b) | 
|---|
| 1611 | WinDestroyWindow(hwnd); | 
|---|
| 1612 | else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN) | 
|---|
| 1613 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1614 | } | 
|---|
| 1615 | } | 
|---|
| 1616 | else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) && | 
|---|
| 1617 | ((SHORT2FROMMP(mp2) == VK_UP || | 
|---|
| 1618 | SHORT2FROMMP(mp2) == VK_DOWN) || | 
|---|
| 1619 | (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r'))) | 
|---|
| 1620 | return 0; | 
|---|
| 1621 | break; | 
|---|
| 1622 |  | 
|---|
| 1623 | case WM_DESTROY: | 
|---|
| 1624 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 1625 | lbup = FALSE; | 
|---|
| 1626 | break; | 
|---|
| 1627 | } | 
|---|
| 1628 | return oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 1629 | } | 
|---|
| 1630 |  | 
|---|
| 1631 | MRESULT EXPENTRY DriveBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1632 | { | 
|---|
| 1633 | switch (msg) { | 
|---|
| 1634 | case WM_CREATE: | 
|---|
| 1635 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 1636 | break; | 
|---|
| 1637 |  | 
|---|
| 1638 | case UM_SETUP: | 
|---|
| 1639 | { | 
|---|
| 1640 | RGB2 rgb; | 
|---|
| 1641 |  | 
|---|
| 1642 | memset(&rgb, 0, sizeof(rgb)); | 
|---|
| 1643 | rgb.bRed = (BYTE)128; | 
|---|
| 1644 | SetPresParams(hwnd, | 
|---|
| 1645 | &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT)); | 
|---|
| 1646 | SetTargetDir(hwnd, TRUE); | 
|---|
| 1647 | } | 
|---|
| 1648 | return 0; | 
|---|
| 1649 |  | 
|---|
| 1650 | case WM_SETFOCUS: | 
|---|
| 1651 | case UM_FOCUSME: | 
|---|
| 1652 | case WM_BUTTON1DOWN: | 
|---|
| 1653 | case WM_BUTTON1UP: | 
|---|
| 1654 | case WM_BUTTON2DOWN: | 
|---|
| 1655 | case WM_BUTTON2UP: | 
|---|
| 1656 | case WM_BUTTON3DOWN: | 
|---|
| 1657 | case WM_BUTTON3UP: | 
|---|
| 1658 | return CommonTextButton(hwnd, msg, mp1, mp2); | 
|---|
| 1659 |  | 
|---|
| 1660 | case WM_MOUSEMOVE: | 
|---|
| 1661 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 1662 | break; | 
|---|
| 1663 |  | 
|---|
| 1664 | case UM_CLICKED: | 
|---|
| 1665 | case UM_CLICKED3: | 
|---|
| 1666 | PostMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_SETTARGET, 0), MPVOID); | 
|---|
| 1667 | return 0; | 
|---|
| 1668 |  | 
|---|
| 1669 | case WM_CHAR: | 
|---|
| 1670 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 1671 | break; | 
|---|
| 1672 |  | 
|---|
| 1673 | case WM_CONTROLPOINTER: | 
|---|
| 1674 | if (!fNoFinger && | 
|---|
| 1675 | (SHORT1FROMMP(mp1) >= IDM_DRIVEA && | 
|---|
| 1676 | SHORT1FROMMP(mp1) < IDM_DRIVEA + 26)) | 
|---|
| 1677 | return MRFROMLONG(hptrFinger); | 
|---|
| 1678 | break; | 
|---|
| 1679 |  | 
|---|
| 1680 | case WM_COMMAND: | 
|---|
| 1681 | { | 
|---|
| 1682 | CHAR dv[4]; | 
|---|
| 1683 |  | 
|---|
| 1684 | *dv = 0; | 
|---|
| 1685 | WinQueryWindowText(WinWindowFromID(hwnd, SHORT1FROMMP(mp1) + 50), | 
|---|
| 1686 | 2, dv); | 
|---|
| 1687 | if (isalpha(*dv)) { | 
|---|
| 1688 |  | 
|---|
| 1689 | HWND hwndActive; | 
|---|
| 1690 |  | 
|---|
| 1691 | dv[1] = ':'; | 
|---|
| 1692 | dv[2] = '\\'; | 
|---|
| 1693 | dv[3] = 0; | 
|---|
| 1694 | hwndActive = TopWindow(hwnd, (HWND) 0); | 
|---|
| 1695 | if (hwndActive) | 
|---|
| 1696 | WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT), | 
|---|
| 1697 | UM_DRIVECMD, MPFROMP(dv), MPVOID); | 
|---|
| 1698 | } | 
|---|
| 1699 | } | 
|---|
| 1700 | return 0; | 
|---|
| 1701 |  | 
|---|
| 1702 | case WM_PAINT: | 
|---|
| 1703 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE); | 
|---|
| 1704 | break; | 
|---|
| 1705 |  | 
|---|
| 1706 | case WM_CLOSE: | 
|---|
| 1707 | WinDestroyWindow(hwnd); | 
|---|
| 1708 | return 0; | 
|---|
| 1709 | } | 
|---|
| 1710 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 1711 | } | 
|---|
| 1712 |  | 
|---|
| 1713 | MRESULT EXPENTRY DriveProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 1714 | { | 
|---|
| 1715 | USHORT id; | 
|---|
| 1716 | CHAR szDrv[CCHMAXPATH]; | 
|---|
| 1717 |  | 
|---|
| 1718 | static BOOL emphasized = FALSE; | 
|---|
| 1719 | static HWND hwndMenu = NULLHANDLE; | 
|---|
| 1720 | static USHORT helpid = 0; | 
|---|
| 1721 |  | 
|---|
| 1722 | switch (msg) { | 
|---|
| 1723 | case WM_MOUSEMOVE: | 
|---|
| 1724 | if (fDrivebarHelp && | 
|---|
| 1725 | (!hwndBubble || | 
|---|
| 1726 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && | 
|---|
| 1727 | !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 1728 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1729 | if (helpid != id) { | 
|---|
| 1730 | helpid = id; | 
|---|
| 1731 | PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID); | 
|---|
| 1732 | } | 
|---|
| 1733 | else | 
|---|
| 1734 | helpid = 0; | 
|---|
| 1735 | } | 
|---|
| 1736 | break; | 
|---|
| 1737 |  | 
|---|
| 1738 | case UM_SETUP6: | 
|---|
| 1739 | if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) { | 
|---|
| 1740 | if ((char *)mp1 && | 
|---|
| 1741 | (!hwndBubble || | 
|---|
| 1742 | WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && | 
|---|
| 1743 | !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 1744 |  | 
|---|
| 1745 | RECTL rcl; | 
|---|
| 1746 | POINTL ptl; | 
|---|
| 1747 |  | 
|---|
| 1748 | WinQueryPointerPos(HWND_DESKTOP, &ptl); | 
|---|
| 1749 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1); | 
|---|
| 1750 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 1751 | if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl)) | 
|---|
| 1752 | BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1); | 
|---|
| 1753 | } | 
|---|
| 1754 | } | 
|---|
| 1755 | return 0; | 
|---|
| 1756 |  | 
|---|
| 1757 | case WM_MENUEND: | 
|---|
| 1758 | if (hwndMenu == (HWND) mp2) { | 
|---|
| 1759 | WinDestroyWindow(hwndMenu); | 
|---|
| 1760 | hwndMenu = (HWND) 0; | 
|---|
| 1761 | } | 
|---|
| 1762 | break; | 
|---|
| 1763 |  | 
|---|
| 1764 | case WM_CONTEXTMENU: | 
|---|
| 1765 | if (hwndMenu) | 
|---|
| 1766 | WinDestroyWindow(hwndMenu); | 
|---|
| 1767 | hwndMenu = (HWND) 0; | 
|---|
| 1768 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1769 | *szDrv = 0; | 
|---|
| 1770 | WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1771 | id + 50), sizeof(szDrv), szDrv); | 
|---|
| 1772 | if (isalpha(*szDrv)) { | 
|---|
| 1773 | hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES); | 
|---|
| 1774 | if (hwndMenu) { | 
|---|
| 1775 | BOOL rdy; | 
|---|
| 1776 | CHAR chDrv = *szDrv; | 
|---|
| 1777 | UINT iDrv; | 
|---|
| 1778 |  | 
|---|
| 1779 | strcpy(szDrv + 2, "\\"); | 
|---|
| 1780 | MakeValidDir(szDrv); | 
|---|
| 1781 | // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c | 
|---|
| 1782 | rdy = toupper(*szDrv) == toupper(chDrv); | 
|---|
| 1783 | iDrv = toupper(*szDrv) - 'A'; | 
|---|
| 1784 | if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE) | 
|---|
| 1785 | WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE); | 
|---|
| 1786 |  | 
|---|
| 1787 | if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) { | 
|---|
| 1788 | WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE); | 
|---|
| 1789 | WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE); | 
|---|
| 1790 | WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE); | 
|---|
| 1791 | WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE); | 
|---|
| 1792 | } | 
|---|
| 1793 | if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) { | 
|---|
| 1794 | WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE); | 
|---|
| 1795 | WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE); | 
|---|
| 1796 | WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE); | 
|---|
| 1797 | } | 
|---|
| 1798 | if (!rdy) { | 
|---|
| 1799 | WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE); | 
|---|
| 1800 | WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE); | 
|---|
| 1801 | WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE); | 
|---|
| 1802 | WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE); | 
|---|
| 1803 | WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE); | 
|---|
| 1804 | } | 
|---|
| 1805 | /* fixme to be gone? | 
|---|
| 1806 | if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) { | 
|---|
| 1807 | WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE); | 
|---|
| 1808 | } | 
|---|
| 1809 | */ | 
|---|
| 1810 | PopupMenu(hwnd, hwnd, hwndMenu); | 
|---|
| 1811 | } | 
|---|
| 1812 | } | 
|---|
| 1813 | return MRFROMSHORT(TRUE); | 
|---|
| 1814 |  | 
|---|
| 1815 | case WM_BUTTON2CLICK: | 
|---|
| 1816 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 1817 | if (!(shiftstate & KC_CTRL)) | 
|---|
| 1818 | break; | 
|---|
| 1819 |  | 
|---|
| 1820 | case WM_CHORD: | 
|---|
| 1821 | case WM_BUTTON3CLICK: | 
|---|
| 1822 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1823 | *szDrv = 0; | 
|---|
| 1824 | WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1825 | id + 50), sizeof(szDrv), szDrv); | 
|---|
| 1826 | if (isalpha(*szDrv)) { | 
|---|
| 1827 | strcat(szDrv, "\\"); | 
|---|
| 1828 | if (!FindDirCnrByName(szDrv, TRUE)) | 
|---|
| 1829 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv); | 
|---|
| 1830 | } | 
|---|
| 1831 | break; | 
|---|
| 1832 |  | 
|---|
| 1833 | case WM_COMMAND: | 
|---|
| 1834 | PostMsg(hwnd, UM_COMMAND, mp1, mp2); | 
|---|
| 1835 | return 0; | 
|---|
| 1836 |  | 
|---|
| 1837 | case UM_COMMAND: | 
|---|
| 1838 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1839 | *szDrv = 0; | 
|---|
| 1840 | WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1841 | id + 50), sizeof(szDrv), szDrv); | 
|---|
| 1842 | if (isalpha(*szDrv)) { | 
|---|
| 1843 | strcat(szDrv, "\\"); | 
|---|
| 1844 | CommonDriveCmd(hwnd, szDrv, SHORT1FROMMP(mp1)); | 
|---|
| 1845 | } | 
|---|
| 1846 | return 0; | 
|---|
| 1847 |  | 
|---|
| 1848 | case DM_DRAGOVER: | 
|---|
| 1849 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1850 | *szDrv = 0; | 
|---|
| 1851 | WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1852 | id + 50), sizeof(szDrv), szDrv); | 
|---|
| 1853 | if (isalpha(*szDrv) && | 
|---|
| 1854 | !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) { | 
|---|
| 1855 | if (!emphasized) { | 
|---|
| 1856 | emphasized = TRUE; | 
|---|
| 1857 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 1858 | } | 
|---|
| 1859 | if (AcceptOneDrop(hwnd, mp1, mp2)) | 
|---|
| 1860 | return MRFROM2SHORT(DOR_DROP, DO_MOVE); | 
|---|
| 1861 | return MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| 1862 | } | 
|---|
| 1863 | break; | 
|---|
| 1864 |  | 
|---|
| 1865 | case DM_DRAGLEAVE: | 
|---|
| 1866 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1867 | *szDrv = 0; | 
|---|
| 1868 | WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1869 | id + 50), sizeof(szDrv), szDrv); | 
|---|
| 1870 | if (isalpha(*szDrv) && | 
|---|
| 1871 | !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) { | 
|---|
| 1872 | if (emphasized) { | 
|---|
| 1873 | emphasized = FALSE; | 
|---|
| 1874 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 1875 | } | 
|---|
| 1876 | } | 
|---|
| 1877 | break; | 
|---|
| 1878 |  | 
|---|
| 1879 | case DM_DROPHELP: | 
|---|
| 1880 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1881 | *szDrv = 0; | 
|---|
| 1882 | WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1883 | id + 50), sizeof(szDrv), szDrv); | 
|---|
| 1884 | if (isalpha(*szDrv) && | 
|---|
| 1885 | !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) { | 
|---|
| 1886 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP)); | 
|---|
| 1887 | return 0; | 
|---|
| 1888 | } | 
|---|
| 1889 | break; | 
|---|
| 1890 |  | 
|---|
| 1891 | case DM_DROP: | 
|---|
| 1892 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 1893 | *szDrv = 0; | 
|---|
| 1894 | WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 1895 | id + 50), sizeof(szDrv), szDrv); | 
|---|
| 1896 | if (isalpha(*szDrv) && | 
|---|
| 1897 | !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) { | 
|---|
| 1898 |  | 
|---|
| 1899 | CNRDRAGINFO cnd; | 
|---|
| 1900 | LISTINFO *li; | 
|---|
| 1901 | ULONG action = UM_ACTION; | 
|---|
| 1902 |  | 
|---|
| 1903 | if (emphasized) { | 
|---|
| 1904 | emphasized = FALSE; | 
|---|
| 1905 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 1906 | } | 
|---|
| 1907 | memset(&cnd, 0, sizeof(cnd)); | 
|---|
| 1908 | cnd.pDragInfo = (PDRAGINFO) mp1; | 
|---|
| 1909 | cnd.pRecord = NULL; | 
|---|
| 1910 | li = DoFileDrop(hwnd, | 
|---|
| 1911 | NULL, | 
|---|
| 1912 | TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd)); | 
|---|
| 1913 | CheckPmDrgLimit(cnd.pDragInfo); | 
|---|
| 1914 | if (li) { | 
|---|
| 1915 | strcpy(li->targetpath, szDrv); | 
|---|
| 1916 | strcat(li->targetpath, "\\"); | 
|---|
| 1917 | if (li->list && li->list[0] && IsRoot(li->list[0])) | 
|---|
| 1918 | li->type = DO_LINK; | 
|---|
| 1919 | else if (fDragndropDlg && (!*li->arcname || !li->info)) { | 
|---|
| 1920 |  | 
|---|
| 1921 | CHECKLIST cl; | 
|---|
| 1922 |  | 
|---|
| 1923 | memset(&cl, 0, sizeof(cl)); | 
|---|
| 1924 | cl.size = sizeof(cl); | 
|---|
| 1925 | cl.flags = li->type; | 
|---|
| 1926 | cl.list = li->list; | 
|---|
| 1927 | cl.cmd = li->type; | 
|---|
| 1928 | cl.prompt = li->targetpath; | 
|---|
| 1929 | li->type = WinDlgBox(HWND_DESKTOP, | 
|---|
| 1930 | hwndMain, | 
|---|
| 1931 | DropListProc, | 
|---|
| 1932 | FM3ModHandle, DND_FRAME, MPFROMP(&cl)); | 
|---|
| 1933 | if (li->type == DID_ERROR) | 
|---|
| 1934 | Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 1935 | "Drag & Drop Dialog"); | 
|---|
| 1936 | if (!li->type) { | 
|---|
| 1937 | FreeListInfo(li); | 
|---|
| 1938 | return 0; | 
|---|
| 1939 | } | 
|---|
| 1940 | li->list = cl.list; | 
|---|
| 1941 | if (!li->list || !li->list[0]) { | 
|---|
| 1942 | FreeListInfo(li); | 
|---|
| 1943 | return 0; | 
|---|
| 1944 | } | 
|---|
| 1945 | } | 
|---|
| 1946 | else { | 
|---|
| 1947 | if (!WinDlgBox(HWND_DESKTOP, | 
|---|
| 1948 | hwndMain, | 
|---|
| 1949 | WalkDlgProc, | 
|---|
| 1950 | FM3ModHandle, | 
|---|
| 1951 | WALK_FRAME, | 
|---|
| 1952 | MPFROMP(li->targetpath)) || !*li->targetpath) { | 
|---|
| 1953 | FreeListInfo(li); | 
|---|
| 1954 | return 0; | 
|---|
| 1955 | } | 
|---|
| 1956 | } | 
|---|
| 1957 | switch (li->type) { | 
|---|
| 1958 | case DND_LAUNCH: | 
|---|
| 1959 | strcat(li->targetpath, " %a"); | 
|---|
| 1960 | ExecOnList(hwndMain, | 
|---|
| 1961 | li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL); | 
|---|
| 1962 | FreeList(li->list); | 
|---|
| 1963 | li->list = NULL; | 
|---|
| 1964 | break; | 
|---|
| 1965 | case DO_LINK: | 
|---|
| 1966 | if (fLinkSetsIcon) { | 
|---|
| 1967 | li->type = IDM_SETICON; | 
|---|
| 1968 | action = UM_MASSACTION; | 
|---|
| 1969 | } | 
|---|
| 1970 | else | 
|---|
| 1971 | li->type = IDM_COMPARE; | 
|---|
| 1972 | break; | 
|---|
| 1973 | case DND_EXTRACT: | 
|---|
| 1974 | if (*li->targetpath && !IsFile(li->targetpath)) | 
|---|
| 1975 | li->type = IDM_EXTRACT; | 
|---|
| 1976 | break; | 
|---|
| 1977 | case DND_MOVE: | 
|---|
| 1978 | li->type = IDM_MOVE; | 
|---|
| 1979 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 1980 | action = UM_MASSACTION; | 
|---|
| 1981 | li->type = IDM_ARCHIVEM; | 
|---|
| 1982 | } | 
|---|
| 1983 | break; | 
|---|
| 1984 | case DND_WILDMOVE: | 
|---|
| 1985 | li->type = IDM_WILDMOVE; | 
|---|
| 1986 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 1987 | action = UM_MASSACTION; | 
|---|
| 1988 | li->type = IDM_ARCHIVEM; | 
|---|
| 1989 | } | 
|---|
| 1990 | break; | 
|---|
| 1991 | case DND_OBJECT: | 
|---|
| 1992 | li->type = IDM_OBJECT; | 
|---|
| 1993 | action = UM_MASSACTION; | 
|---|
| 1994 | break; | 
|---|
| 1995 | case DND_SHADOW: | 
|---|
| 1996 | li->type = IDM_SHADOW; | 
|---|
| 1997 | action = UM_MASSACTION; | 
|---|
| 1998 | break; | 
|---|
| 1999 | case DND_COMPARE: | 
|---|
| 2000 | li->type = IDM_COMPARE; | 
|---|
| 2001 | break; | 
|---|
| 2002 | case DND_SETICON: | 
|---|
| 2003 | action = UM_MASSACTION; | 
|---|
| 2004 | li->type = IDM_SETICON; | 
|---|
| 2005 | break; | 
|---|
| 2006 | case DND_COPY: | 
|---|
| 2007 | li->type = IDM_COPY; | 
|---|
| 2008 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2009 | action = UM_MASSACTION; | 
|---|
| 2010 | li->type = IDM_ARCHIVE; | 
|---|
| 2011 | } | 
|---|
| 2012 | break; | 
|---|
| 2013 | case DND_WILDCOPY: | 
|---|
| 2014 | li->type = IDM_WILDCOPY; | 
|---|
| 2015 | if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2016 | action = UM_MASSACTION; | 
|---|
| 2017 | li->type = IDM_ARCHIVE; | 
|---|
| 2018 | } | 
|---|
| 2019 | break; | 
|---|
| 2020 | default: | 
|---|
| 2021 | if (*li->arcname && li->info) { | 
|---|
| 2022 | action = UM_MASSACTION; | 
|---|
| 2023 | li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : | 
|---|
| 2024 | IDM_FAKEEXTRACT; | 
|---|
| 2025 | } | 
|---|
| 2026 | else if (*li->targetpath && IsFile(li->targetpath) == 1) { | 
|---|
| 2027 | action = UM_MASSACTION; | 
|---|
| 2028 | li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE; | 
|---|
| 2029 | } | 
|---|
| 2030 | else | 
|---|
| 2031 | li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY; | 
|---|
| 2032 | break; | 
|---|
| 2033 | } | 
|---|
| 2034 | if (!li->list || !li->list[0]) | 
|---|
| 2035 | FreeListInfo(li); | 
|---|
| 2036 | else | 
|---|
| 2037 | WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action)); | 
|---|
| 2038 | } | 
|---|
| 2039 | return 0; | 
|---|
| 2040 | } | 
|---|
| 2041 | break; | 
|---|
| 2042 |  | 
|---|
| 2043 | case WM_DESTROY: | 
|---|
| 2044 | if (hwndMenu) | 
|---|
| 2045 | WinDestroyWindow(hwndMenu); | 
|---|
| 2046 | hwndMenu = (HWND) 0; | 
|---|
| 2047 | break; | 
|---|
| 2048 | } | 
|---|
| 2049 | return PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 2050 | } | 
|---|
| 2051 |  | 
|---|
| 2052 | VOID BuildDriveBarButtons(HWND hwndT) | 
|---|
| 2053 | { | 
|---|
| 2054 | register ULONG x, y = 0; | 
|---|
| 2055 | ULONG ulDriveNum, ulDriveMap, iconid; | 
|---|
| 2056 | CHAR s[8]; | 
|---|
| 2057 | HENUM henum; | 
|---|
| 2058 | HWND hwndB; | 
|---|
| 2059 |  | 
|---|
| 2060 | henum = WinBeginEnumWindows(hwndT); | 
|---|
| 2061 |  | 
|---|
| 2062 | while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) | 
|---|
| 2063 | WinDestroyWindow(hwndB); | 
|---|
| 2064 |  | 
|---|
| 2065 | WinEndEnumWindows(henum); | 
|---|
| 2066 | if (fDrivebar) { | 
|---|
| 2067 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 2068 | DosQCurDisk(&ulDriveNum, &ulDriveMap); | 
|---|
| 2069 | for (x = 0; x < 26; x++) { | 
|---|
| 2070 | if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) { | 
|---|
| 2071 | if (x > 1) { | 
|---|
| 2072 | if (driveflags[x] & DRIVE_CDROM) | 
|---|
| 2073 | iconid = CDROM_ICON; | 
|---|
| 2074 | else | 
|---|
| 2075 | iconid = (driveflags[x] & DRIVE_REMOVABLE) ? | 
|---|
| 2076 | REMOVABLE_ICON : | 
|---|
| 2077 | (driveflags[x] & DRIVE_VIRTUAL) ? | 
|---|
| 2078 | VIRTUAL_ICON : | 
|---|
| 2079 | (driveflags[x] & DRIVE_REMOTE) ? | 
|---|
| 2080 | REMOTE_ICON : | 
|---|
| 2081 | (driveflags[x] & DRIVE_RAMDISK) ? | 
|---|
| 2082 | RAMDISK_ICON : | 
|---|
| 2083 | (driveflags[x] & DRIVE_ZIPSTREAM) ? | 
|---|
| 2084 | ZIPSTREAM_ICON :DRIVE_ICON; | 
|---|
| 2085 | } | 
|---|
| 2086 | else | 
|---|
| 2087 | iconid = FLOPPY_ICON; | 
|---|
| 2088 | sprintf(s, "#%lu", iconid); | 
|---|
| 2089 | hwndB = WinCreateWindow(hwndT, | 
|---|
| 2090 | WC_DRIVEBUTTONS, | 
|---|
| 2091 | s, | 
|---|
| 2092 | BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, | 
|---|
| 2093 | 0, | 
|---|
| 2094 | 0, | 
|---|
| 2095 | 28, | 
|---|
| 2096 | 18, | 
|---|
| 2097 | hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL); | 
|---|
| 2098 | if (!hwndB) | 
|---|
| 2099 | Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 2100 | IDS_WINCREATEWINDOW); | 
|---|
| 2101 | else { | 
|---|
| 2102 | WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); | 
|---|
| 2103 | sprintf(s, "%c:", (CHAR) x + 'A'); | 
|---|
| 2104 | hwndB = WinCreateWindow(hwndT, | 
|---|
| 2105 | WC_STATIC, | 
|---|
| 2106 | s, | 
|---|
| 2107 | SS_TEXT | DT_LEFT | DT_VCENTER, | 
|---|
| 2108 | 0, | 
|---|
| 2109 | 0, | 
|---|
| 2110 | 10, | 
|---|
| 2111 | 18, | 
|---|
| 2112 | hwndT, | 
|---|
| 2113 | HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL); | 
|---|
| 2114 | if (!hwndB) | 
|---|
| 2115 | Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 2116 | IDS_WINCREATEWINDOW); | 
|---|
| 2117 | else { | 
|---|
| 2118 | SetPresParams(hwndB, | 
|---|
| 2119 | &RGBGREY, | 
|---|
| 2120 | &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT)); | 
|---|
| 2121 | WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); | 
|---|
| 2122 | } | 
|---|
| 2123 | y++; | 
|---|
| 2124 | } | 
|---|
| 2125 | } | 
|---|
| 2126 | }                                   // for | 
|---|
| 2127 | }                                     // if drivebar | 
|---|
| 2128 | PostMsg(WinQueryWindow(hwndT, QW_PARENT), | 
|---|
| 2129 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 2130 | } | 
|---|
| 2131 |  | 
|---|
| 2132 | VOID ResizeDrives(HWND hwndT, long xwidth) | 
|---|
| 2133 | { | 
|---|
| 2134 | register ULONG ctrlxpos = 2, ctrlypos = 0, ctrlxsize; | 
|---|
| 2135 | HENUM henum; | 
|---|
| 2136 | HWND hwndB; | 
|---|
| 2137 | RECTL rcl; | 
|---|
| 2138 |  | 
|---|
| 2139 | DriveLines = 0; | 
|---|
| 2140 | if (!fDrivebar) | 
|---|
| 2141 | return; | 
|---|
| 2142 | if (!xwidth) { | 
|---|
| 2143 | WinQueryWindowRect(hwndT, &rcl); | 
|---|
| 2144 | xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 2145 | SV_CYSIZEBORDER) * 2) + 2); | 
|---|
| 2146 | } | 
|---|
| 2147 | henum = WinBeginEnumWindows(hwndT); | 
|---|
| 2148 | while ((hwndB = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 2149 | if (WinQueryWindowUShort(hwndB, QWS_ID) > IDM_DRIVEA + 27) | 
|---|
| 2150 | ctrlxsize = 10; | 
|---|
| 2151 | else | 
|---|
| 2152 | ctrlxsize = 28; | 
|---|
| 2153 | WinSetWindowPos(hwndB, | 
|---|
| 2154 | HWND_TOP, | 
|---|
| 2155 | ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW); | 
|---|
| 2156 | ctrlxpos += (ctrlxsize + 2); | 
|---|
| 2157 | if (ctrlxsize == 10) { | 
|---|
| 2158 | if (ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ? | 
|---|
| 2159 | 256 : 0)) > xwidth) { | 
|---|
| 2160 | ctrlxpos = 2; | 
|---|
| 2161 | ctrlypos += 18; | 
|---|
| 2162 | DriveLines++; | 
|---|
| 2163 | } | 
|---|
| 2164 | } | 
|---|
| 2165 | } | 
|---|
| 2166 | if (ctrlxpos == 2 && DriveLines) | 
|---|
| 2167 | DriveLines--; | 
|---|
| 2168 | } | 
|---|
| 2169 |  | 
|---|
| 2170 | MRESULT EXPENTRY StatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2171 | { | 
|---|
| 2172 | static HWND hwndE = (HWND) 0, hwndB = (HWND) 0; | 
|---|
| 2173 | static CHAR lastcmd[1024] = ""; | 
|---|
| 2174 |  | 
|---|
| 2175 | switch (msg) { | 
|---|
| 2176 | case WM_CREATE: | 
|---|
| 2177 | { | 
|---|
| 2178 | MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 2179 |  | 
|---|
| 2180 | SetPresParams(hwnd, | 
|---|
| 2181 | &RGBGREY, | 
|---|
| 2182 | &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT)); | 
|---|
| 2183 | return mr; | 
|---|
| 2184 | } | 
|---|
| 2185 |  | 
|---|
| 2186 | case WM_PRESPARAMCHANGED: | 
|---|
| 2187 | if (fRunning) { | 
|---|
| 2188 |  | 
|---|
| 2189 | ULONG AttrFound, AttrValue[64], cbRetLen; | 
|---|
| 2190 |  | 
|---|
| 2191 | cbRetLen = WinQueryPresParam(hwnd, | 
|---|
| 2192 | (ULONG) mp1, | 
|---|
| 2193 | 0, | 
|---|
| 2194 | &AttrFound, | 
|---|
| 2195 | (ULONG) sizeof(AttrValue), &AttrValue, 0); | 
|---|
| 2196 | if (cbRetLen) { | 
|---|
| 2197 | switch (AttrFound) { | 
|---|
| 2198 | case PP_FONTNAMESIZE: | 
|---|
| 2199 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2200 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 2201 | break; | 
|---|
| 2202 | } | 
|---|
| 2203 | } | 
|---|
| 2204 | } | 
|---|
| 2205 | break; | 
|---|
| 2206 |  | 
|---|
| 2207 | case WM_CONTEXTMENU: | 
|---|
| 2208 | PostMsg(hwndMain, UM_CONTEXTMENU, MPVOID, MPVOID); | 
|---|
| 2209 | return MRFROMSHORT(TRUE); | 
|---|
| 2210 |  | 
|---|
| 2211 | case WM_BEGINDRAG: | 
|---|
| 2212 | if (hwndTree) { | 
|---|
| 2213 |  | 
|---|
| 2214 | SWP swp; | 
|---|
| 2215 | ULONG fl = SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER; | 
|---|
| 2216 |  | 
|---|
| 2217 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 2218 | if (!(swp.fl & SWP_MAXIMIZE)) | 
|---|
| 2219 | fl |= SWP_RESTORE; | 
|---|
| 2220 | WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl); | 
|---|
| 2221 | } | 
|---|
| 2222 | break; | 
|---|
| 2223 |  | 
|---|
| 2224 | case UM_SETUP: | 
|---|
| 2225 | if (mp1) | 
|---|
| 2226 | strcpy(lastcmd, (CHAR *) mp1); | 
|---|
| 2227 | return 0; | 
|---|
| 2228 |  | 
|---|
| 2229 | case UM_RESCAN: | 
|---|
| 2230 | if (hwndE && WinIsWindow(WinQueryAnchorBlock(hwnd), hwndE)) | 
|---|
| 2231 | WinDestroyWindow(hwndE); | 
|---|
| 2232 | if (hwndB && WinIsWindow(WinQueryAnchorBlock(hwnd), hwndB)) | 
|---|
| 2233 | WinDestroyWindow(hwndB); | 
|---|
| 2234 | hwndE = hwndB = (HWND) 0; | 
|---|
| 2235 | return 0; | 
|---|
| 2236 |  | 
|---|
| 2237 | case WM_COMMAND: | 
|---|
| 2238 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 2239 | case COMMAND_BUTTON: | 
|---|
| 2240 | PostMsg(hwndE, msg, mp1, mp2); | 
|---|
| 2241 | break; | 
|---|
| 2242 | } | 
|---|
| 2243 | return 0; | 
|---|
| 2244 |  | 
|---|
| 2245 | case WM_MOUSEMOVE: | 
|---|
| 2246 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 2247 | { | 
|---|
| 2248 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2249 | char *s = NULL; | 
|---|
| 2250 |  | 
|---|
| 2251 | if (fOtherHelp) { | 
|---|
| 2252 | if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) | 
|---|
| 2253 | && !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 2254 | switch (id) { | 
|---|
| 2255 | case IDM_ATTRS: | 
|---|
| 2256 | if (WinQueryWindowTextLength(hwnd)) | 
|---|
| 2257 | s = GetPString(IDS_ATTRSBUTTONHELP); | 
|---|
| 2258 | break; | 
|---|
| 2259 | case IDM_INFO: | 
|---|
| 2260 | if (WinQueryWindowTextLength(hwnd)) | 
|---|
| 2261 | s = GetPString(IDS_INFOBUTTONHELP); | 
|---|
| 2262 | break; | 
|---|
| 2263 | case IDM_RENAME: | 
|---|
| 2264 | if (WinQueryWindowTextLength(hwnd)) | 
|---|
| 2265 | s = GetPString(IDS_NAMEBUTTONHELP); | 
|---|
| 2266 | break; | 
|---|
| 2267 | case MAIN_STATUS2: | 
|---|
| 2268 | if (!hwndE) | 
|---|
| 2269 | s = GetPString(IDS_STATUS2HELP); | 
|---|
| 2270 | break; | 
|---|
| 2271 | default: | 
|---|
| 2272 | break; | 
|---|
| 2273 | } | 
|---|
| 2274 | if (s) | 
|---|
| 2275 | MakeBubble(hwnd, FALSE, s); | 
|---|
| 2276 | else if (hwndBubble) | 
|---|
| 2277 | WinDestroyWindow(hwndBubble); | 
|---|
| 2278 | } | 
|---|
| 2279 | } | 
|---|
| 2280 | switch (id) { | 
|---|
| 2281 | case IDM_ATTRS: | 
|---|
| 2282 | case IDM_INFO: | 
|---|
| 2283 | case IDM_RENAME: | 
|---|
| 2284 | case MAIN_STATUS2: | 
|---|
| 2285 | return CommonTextProc(hwnd, msg, mp1, mp2); | 
|---|
| 2286 | default: | 
|---|
| 2287 | break; | 
|---|
| 2288 | } | 
|---|
| 2289 | } | 
|---|
| 2290 | break; | 
|---|
| 2291 |  | 
|---|
| 2292 | case WM_BUTTON2DOWN: | 
|---|
| 2293 | case WM_BUTTON2UP: | 
|---|
| 2294 | case UM_FOCUSME: | 
|---|
| 2295 | return CommonTextButton(hwnd, msg, mp1, mp2); | 
|---|
| 2296 |  | 
|---|
| 2297 | case WM_BUTTON1DOWN: | 
|---|
| 2298 | case WM_BUTTON1UP: | 
|---|
| 2299 | case WM_BUTTON3DOWN: | 
|---|
| 2300 | case WM_BUTTON3UP: | 
|---|
| 2301 | { | 
|---|
| 2302 | USHORT id; | 
|---|
| 2303 |  | 
|---|
| 2304 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2305 | switch (id) { | 
|---|
| 2306 | case IDM_ATTRS: | 
|---|
| 2307 | case IDM_INFO: | 
|---|
| 2308 | case IDM_RENAME: | 
|---|
| 2309 | case MAIN_STATUS2: | 
|---|
| 2310 | return CommonTextButton(hwnd, msg, mp1, mp2); | 
|---|
| 2311 | default: | 
|---|
| 2312 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 2313 | break; | 
|---|
| 2314 | } | 
|---|
| 2315 | } | 
|---|
| 2316 | break; | 
|---|
| 2317 |  | 
|---|
| 2318 | case WM_SETFOCUS: | 
|---|
| 2319 | if (mp2) { | 
|---|
| 2320 |  | 
|---|
| 2321 | USHORT id; | 
|---|
| 2322 |  | 
|---|
| 2323 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2324 | if (id == MAIN_STATUS2 && hwndE) | 
|---|
| 2325 | WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2326 | else | 
|---|
| 2327 | return CommonTextButton(hwnd, msg, mp1, mp2); | 
|---|
| 2328 | } | 
|---|
| 2329 | break; | 
|---|
| 2330 |  | 
|---|
| 2331 | case WM_BUTTON1CLICK: | 
|---|
| 2332 | { | 
|---|
| 2333 | USHORT id; | 
|---|
| 2334 |  | 
|---|
| 2335 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2336 | if (id == MAIN_STATUS) { | 
|---|
| 2337 | if (SHORT2FROMMP(mp2) & KC_CTRL) | 
|---|
| 2338 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2339 | FID_CLIENT), | 
|---|
| 2340 | WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID); | 
|---|
| 2341 | else if (hwndTree) | 
|---|
| 2342 | PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID); | 
|---|
| 2343 | } | 
|---|
| 2344 | } | 
|---|
| 2345 | break; | 
|---|
| 2346 |  | 
|---|
| 2347 | case UM_CLICKED: | 
|---|
| 2348 | case UM_CLICKED3: | 
|---|
| 2349 | { | 
|---|
| 2350 | USHORT id; | 
|---|
| 2351 |  | 
|---|
| 2352 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2353 | if (id == MAIN_STATUS2 && !hwndE) { | 
|---|
| 2354 |  | 
|---|
| 2355 | SWP swp; | 
|---|
| 2356 | CHAR directory[CCHMAXPATH]; | 
|---|
| 2357 | PFNWP oldproce; | 
|---|
| 2358 |  | 
|---|
| 2359 | *directory = 0; | 
|---|
| 2360 | TopWindowName(hwndMain, (HWND) 0, directory); | 
|---|
| 2361 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 2362 | hwndB = WinCreateWindow(hwnd, | 
|---|
| 2363 | WC_BUTTON, | 
|---|
| 2364 | "+", | 
|---|
| 2365 | WS_VISIBLE | BS_PUSHBUTTON | | 
|---|
| 2366 | BS_NOPOINTERFOCUS, | 
|---|
| 2367 | swp.cx - swp.cy, | 
|---|
| 2368 | 0, | 
|---|
| 2369 | swp.cy, | 
|---|
| 2370 | swp.cy, | 
|---|
| 2371 | hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL); | 
|---|
| 2372 | if (!hwndB) | 
|---|
| 2373 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 2374 | hwndE = WinCreateWindow(hwnd, | 
|---|
| 2375 | WC_ENTRYFIELD, | 
|---|
| 2376 | NULL, | 
|---|
| 2377 | WS_VISIBLE | ES_AUTOSCROLL, | 
|---|
| 2378 | 0, | 
|---|
| 2379 | 0, | 
|---|
| 2380 | swp.cx - swp.cy, | 
|---|
| 2381 | swp.cy, | 
|---|
| 2382 | hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL); | 
|---|
| 2383 | if (!hwndE) | 
|---|
| 2384 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 2385 | if (!hwndE || !hwndB) { | 
|---|
| 2386 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); | 
|---|
| 2387 | return 0; | 
|---|
| 2388 | } | 
|---|
| 2389 | WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID); | 
|---|
| 2390 | WinSetWindowText(hwndStatus, directory); | 
|---|
| 2391 | if (*lastcmd) | 
|---|
| 2392 | WinSetWindowText(hwndE, lastcmd); | 
|---|
| 2393 | else | 
|---|
| 2394 | WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT)); | 
|---|
| 2395 | oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc); | 
|---|
| 2396 | if (oldproce) | 
|---|
| 2397 | WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce); | 
|---|
| 2398 | PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 2399 | PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID); | 
|---|
| 2400 | return 0; | 
|---|
| 2401 | } | 
|---|
| 2402 | if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) { | 
|---|
| 2403 | switch (id) { | 
|---|
| 2404 | case IDM_ATTRS: | 
|---|
| 2405 | id = IDM_SORTSIZE; | 
|---|
| 2406 | break; | 
|---|
| 2407 | case IDM_INFO: | 
|---|
| 2408 | id = IDM_SORTLWDATE; | 
|---|
| 2409 | break; | 
|---|
| 2410 | case IDM_RENAME: | 
|---|
| 2411 | id = IDM_SORTFILENAME; | 
|---|
| 2412 | break; | 
|---|
| 2413 | } | 
|---|
| 2414 | } | 
|---|
| 2415 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2416 | WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID); | 
|---|
| 2417 | } | 
|---|
| 2418 | return 0; | 
|---|
| 2419 |  | 
|---|
| 2420 | case WM_PAINT: | 
|---|
| 2421 | { | 
|---|
| 2422 | USHORT id; | 
|---|
| 2423 |  | 
|---|
| 2424 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 2425 | switch (id) { | 
|---|
| 2426 | case IDM_ATTRS: | 
|---|
| 2427 | case IDM_INFO: | 
|---|
| 2428 | case IDM_RENAME: | 
|---|
| 2429 | case MAIN_STATUS2: | 
|---|
| 2430 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE); | 
|---|
| 2431 | break; | 
|---|
| 2432 | default: | 
|---|
| 2433 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE); | 
|---|
| 2434 | break; | 
|---|
| 2435 | } | 
|---|
| 2436 | if (id == IDM_RENAME) { | 
|---|
| 2437 |  | 
|---|
| 2438 | HPS hps; | 
|---|
| 2439 |  | 
|---|
| 2440 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL); | 
|---|
| 2441 | if (hps) { | 
|---|
| 2442 | PaintSTextWindow(hwnd, hps); | 
|---|
| 2443 | WinEndPaint(hps); | 
|---|
| 2444 | } | 
|---|
| 2445 | return 0; | 
|---|
| 2446 | } | 
|---|
| 2447 | } | 
|---|
| 2448 | break; | 
|---|
| 2449 |  | 
|---|
| 2450 | } | 
|---|
| 2451 | return PFNWPStatic(hwnd, msg, mp1, mp2); | 
|---|
| 2452 | } | 
|---|
| 2453 |  | 
|---|
| 2454 | MRESULT EXPENTRY ToolBackProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 2455 | { | 
|---|
| 2456 | switch (msg) { | 
|---|
| 2457 | case WM_CREATE: | 
|---|
| 2458 | hwndToolback = hwnd; | 
|---|
| 2459 | SetPresParams(hwnd, | 
|---|
| 2460 | &RGBGREY, &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVTEXT)); | 
|---|
| 2461 | break; | 
|---|
| 2462 |  | 
|---|
| 2463 | case WM_MOUSEMOVE: | 
|---|
| 2464 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 2465 | break; | 
|---|
| 2466 |  | 
|---|
| 2467 | case WM_CONTROLPOINTER: | 
|---|
| 2468 | if (!fNoFinger && SHORT1FROMMP(mp1) < 25000) | 
|---|
| 2469 | return MRFROMLONG(hptrFinger); | 
|---|
| 2470 | break; | 
|---|
| 2471 |  | 
|---|
| 2472 | case WM_CHAR: | 
|---|
| 2473 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 2474 | break; | 
|---|
| 2475 |  | 
|---|
| 2476 | case WM_COMMAND: | 
|---|
| 2477 | case UM_COMMAND: | 
|---|
| 2478 | return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2479 | FID_CLIENT), msg, mp1, mp2); | 
|---|
| 2480 |  | 
|---|
| 2481 | case WM_PAINT: | 
|---|
| 2482 | { | 
|---|
| 2483 | HPS hps; | 
|---|
| 2484 | RECTL rcl; | 
|---|
| 2485 |  | 
|---|
| 2486 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL); | 
|---|
| 2487 | if (hps) { | 
|---|
| 2488 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 2489 | WinFillRect(hps, &rcl, CLR_PALEGRAY); | 
|---|
| 2490 | WinEndPaint(hps); | 
|---|
| 2491 | } | 
|---|
| 2492 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE); | 
|---|
| 2493 | } | 
|---|
| 2494 | break; | 
|---|
| 2495 |  | 
|---|
| 2496 | case UM_SETUP: | 
|---|
| 2497 | { | 
|---|
| 2498 | USHORT id; | 
|---|
| 2499 | TOOL *tool; | 
|---|
| 2500 |  | 
|---|
| 2501 | id = SHORT1FROMMP(mp1); | 
|---|
| 2502 | tool = find_tool(id); | 
|---|
| 2503 | if (tool) { | 
|---|
| 2504 | del_tool(tool); | 
|---|
| 2505 | WinShowWindow(WinWindowFromID(hwnd, id), FALSE); | 
|---|
| 2506 | if (fToolTitles) | 
|---|
| 2507 | WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE); | 
|---|
| 2508 | ResizeTools(hwnd); | 
|---|
| 2509 | } | 
|---|
| 2510 | } | 
|---|
| 2511 | return 0; | 
|---|
| 2512 |  | 
|---|
| 2513 | case WM_CHORD: | 
|---|
| 2514 | { | 
|---|
| 2515 | USHORT id; | 
|---|
| 2516 |  | 
|---|
| 2517 | id = (USHORT) WinDlgBox(HWND_DESKTOP, | 
|---|
| 2518 | hwnd, | 
|---|
| 2519 | AddToolProc, | 
|---|
| 2520 | FM3ModHandle, ADDBTN_FRAME, MPVOID); | 
|---|
| 2521 | if (id && id != (USHORT) - 1) | 
|---|
| 2522 | WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 2523 | FID_CLIENT), | 
|---|
| 2524 | WM_COMMAND, | 
|---|
| 2525 | MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0)); | 
|---|
| 2526 | } | 
|---|
| 2527 | break; | 
|---|
| 2528 |  | 
|---|
| 2529 | case WM_CONTEXTMENU: | 
|---|
| 2530 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 2531 | hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID)) | 
|---|
| 2532 | BuildTools(hwnd, TRUE); | 
|---|
| 2533 | return MRFROMSHORT(TRUE); | 
|---|
| 2534 |  | 
|---|
| 2535 | case WM_CLOSE: | 
|---|
| 2536 | WinDestroyWindow(hwnd); | 
|---|
| 2537 | return 0; | 
|---|
| 2538 |  | 
|---|
| 2539 | case WM_DESTROY: | 
|---|
| 2540 | break; | 
|---|
| 2541 | } | 
|---|
| 2542 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 2543 | } | 
|---|
| 2544 |  | 
|---|
| 2545 | static VOID AdjustSizeOfClient(PSWP pswp, PRECTL prectl) | 
|---|
| 2546 | { | 
|---|
| 2547 | SWP swp; | 
|---|
| 2548 | RECTL rectl; | 
|---|
| 2549 |  | 
|---|
| 2550 | if (fFreeTree) | 
|---|
| 2551 | return; | 
|---|
| 2552 | if (pswp) { | 
|---|
| 2553 | if (WinQueryWindowPos(hwndTree, &swp) && | 
|---|
| 2554 | !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) { | 
|---|
| 2555 | pswp->x = swp.cx; | 
|---|
| 2556 | pswp->cx -= swp.cx; | 
|---|
| 2557 | } | 
|---|
| 2558 | } | 
|---|
| 2559 | if (prectl) { | 
|---|
| 2560 | if (WinQueryWindowPos(hwndTree, &swp) && | 
|---|
| 2561 | !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) && | 
|---|
| 2562 | WinQueryWindowRect(hwndTree, &rectl)) { | 
|---|
| 2563 | prectl->xLeft = rectl.xRight; | 
|---|
| 2564 | prectl->xRight -= rectl.xRight; | 
|---|
| 2565 | } | 
|---|
| 2566 | } | 
|---|
| 2567 | } | 
|---|
| 2568 |  | 
|---|
| 2569 | VOID FillClient(HWND hwndClient, PSWP pswp, PRECTL prectl, BOOL avoidtree) | 
|---|
| 2570 | { | 
|---|
| 2571 | ULONG adjust; | 
|---|
| 2572 |  | 
|---|
| 2573 | adjust = WinQuerySysValue(HWND_DESKTOP, SV_CYICON); | 
|---|
| 2574 | if (pswp) | 
|---|
| 2575 | WinQueryWindowPos(hwndClient, pswp); | 
|---|
| 2576 | if (prectl) | 
|---|
| 2577 | WinQueryWindowRect(hwndClient, prectl); | 
|---|
| 2578 | if (avoidtree && !fFreeTree) | 
|---|
| 2579 | AdjustSizeOfClient(pswp, prectl); | 
|---|
| 2580 | if (prectl) | 
|---|
| 2581 | prectl->yBottom += adjust; | 
|---|
| 2582 | if (pswp) { | 
|---|
| 2583 | if (!avoidtree || fFreeTree) | 
|---|
| 2584 | pswp->x = 0; | 
|---|
| 2585 | pswp->y = adjust; | 
|---|
| 2586 | if (pswp->cy >= adjust) | 
|---|
| 2587 | pswp->cy -= adjust; | 
|---|
| 2588 | else | 
|---|
| 2589 | pswp->cy = 0; | 
|---|
| 2590 | } | 
|---|
| 2591 | } | 
|---|
| 2592 |  | 
|---|
| 2593 | static VOID MoveChildrenAwayFromTree(HWND hwndClient) | 
|---|
| 2594 | { | 
|---|
| 2595 | SWP swpC, swpT, swp; | 
|---|
| 2596 | USHORT id; | 
|---|
| 2597 | HWND hwndChild; | 
|---|
| 2598 | HENUM henum; | 
|---|
| 2599 |  | 
|---|
| 2600 | if (fFreeTree) | 
|---|
| 2601 | return; | 
|---|
| 2602 | WinQueryWindowPos(hwndClient, &swpC); | 
|---|
| 2603 | if (swpC.fl & (SWP_MINIMIZE | SWP_HIDE)) | 
|---|
| 2604 | return; | 
|---|
| 2605 | WinQueryWindowPos(hwndTree, &swpT); | 
|---|
| 2606 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 2607 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 2608 | id = WinQueryWindowUShort(hwndChild, QWS_ID); | 
|---|
| 2609 | if (!id || id == TREE_FRAME) | 
|---|
| 2610 | continue; | 
|---|
| 2611 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 2612 | if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 2613 | if (swp.x < swpT.cx) { | 
|---|
| 2614 | swp.x = swpT.cx; | 
|---|
| 2615 | if (swp.x + swp.cx > swpC.cx) | 
|---|
| 2616 | swp.cx = swpC.cx - swp.x; | 
|---|
| 2617 | if (swp.cx > 24) | 
|---|
| 2618 | WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 2619 | SWP_SIZE | SWP_MOVE | SWP_SHOW); | 
|---|
| 2620 | } | 
|---|
| 2621 | } | 
|---|
| 2622 | } | 
|---|
| 2623 | WinEndEnumWindows(henum); | 
|---|
| 2624 | } | 
|---|
| 2625 |  | 
|---|
| 2626 | static VOID ArrangeIcons(HWND hwndClient) | 
|---|
| 2627 | { | 
|---|
| 2628 | HENUM henum; | 
|---|
| 2629 | HWND hwndChild; | 
|---|
| 2630 | SWP swp; | 
|---|
| 2631 |  | 
|---|
| 2632 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 2633 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 2634 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 2635 | if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) { | 
|---|
| 2636 | WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1); | 
|---|
| 2637 | WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1); | 
|---|
| 2638 | WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, | 
|---|
| 2639 | SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE); | 
|---|
| 2640 | } | 
|---|
| 2641 | } | 
|---|
| 2642 | WinEndEnumWindows(henum); | 
|---|
| 2643 | } | 
|---|
| 2644 |  | 
|---|
| 2645 | static VOID NextChild(HWND hwndClient, BOOL previous) | 
|---|
| 2646 | { | 
|---|
| 2647 | HENUM henum; | 
|---|
| 2648 | HWND hwndActive, hwndNext, hwndPrev = (HWND) 0; | 
|---|
| 2649 | BOOL next = FALSE, once = FALSE; | 
|---|
| 2650 |  | 
|---|
| 2651 | previous = !previous; | 
|---|
| 2652 |  | 
|---|
| 2653 | hwndActive = WinQueryActiveWindow(hwndClient); | 
|---|
| 2654 | if (!hwndActive) | 
|---|
| 2655 | next = TRUE; | 
|---|
| 2656 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 2657 | for (;;) { | 
|---|
| 2658 | hwndNext = WinGetNextWindow(henum); | 
|---|
| 2659 | if (hwndNext) { | 
|---|
| 2660 | if (!WinQueryWindowUShort(hwndNext, QWS_ID)) | 
|---|
| 2661 | continue; | 
|---|
| 2662 | if (next) | 
|---|
| 2663 | break; | 
|---|
| 2664 | if (hwndNext == hwndActive) { | 
|---|
| 2665 | if (!previous && hwndPrev) { | 
|---|
| 2666 | hwndNext = hwndPrev; | 
|---|
| 2667 | break; | 
|---|
| 2668 | } | 
|---|
| 2669 | else if (previous) | 
|---|
| 2670 | next = TRUE; | 
|---|
| 2671 | } | 
|---|
| 2672 | hwndPrev = hwndNext; | 
|---|
| 2673 | } | 
|---|
| 2674 | else { | 
|---|
| 2675 | if ((!next && previous) || once) | 
|---|
| 2676 | break; | 
|---|
| 2677 | else if (!previous) { | 
|---|
| 2678 | hwndNext = hwndPrev; | 
|---|
| 2679 | break; | 
|---|
| 2680 | } | 
|---|
| 2681 | else | 
|---|
| 2682 | once = next = TRUE; | 
|---|
| 2683 | } | 
|---|
| 2684 | } | 
|---|
| 2685 | WinEndEnumWindows(henum); | 
|---|
| 2686 |  | 
|---|
| 2687 | if (hwndNext && hwndNext != hwndActive) { | 
|---|
| 2688 | WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0, | 
|---|
| 2689 | SWP_ZORDER | SWP_ACTIVATE); | 
|---|
| 2690 | WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0, | 
|---|
| 2691 | 0, 0, SWP_ZORDER); | 
|---|
| 2692 | } | 
|---|
| 2693 | } | 
|---|
| 2694 |  | 
|---|
| 2695 | BOOL CloseChildren(HWND hwndClient) | 
|---|
| 2696 | { | 
|---|
| 2697 | HENUM henum; | 
|---|
| 2698 | HWND hwndChild; | 
|---|
| 2699 | BOOL ret = FALSE; | 
|---|
| 2700 |  | 
|---|
| 2701 | fNoTileUpdate = TRUE; | 
|---|
| 2702 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 2703 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 2704 | if (hwndChild != hwndTree) { | 
|---|
| 2705 | WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), | 
|---|
| 2706 | WM_SAVEAPPLICATION, MPVOID, MPVOID); | 
|---|
| 2707 | if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), | 
|---|
| 2708 | WM_CLOSE, MPVOID, MPVOID)) { | 
|---|
| 2709 | ret = TRUE; | 
|---|
| 2710 | break; | 
|---|
| 2711 | } | 
|---|
| 2712 | } | 
|---|
| 2713 | } | 
|---|
| 2714 | WinEndEnumWindows(henum); | 
|---|
| 2715 | fNoTileUpdate = FALSE; | 
|---|
| 2716 | return ret; | 
|---|
| 2717 | } | 
|---|
| 2718 |  | 
|---|
| 2719 | BOOL CloseDirCnrChildren(HWND hwndClient) | 
|---|
| 2720 | { | 
|---|
| 2721 | /* returns TRUE if a directory container window was told to close */ | 
|---|
| 2722 |  | 
|---|
| 2723 | HENUM henum; | 
|---|
| 2724 | HWND hwndChild, hwndDir, hwndTemp; | 
|---|
| 2725 | BOOL ret = FALSE; | 
|---|
| 2726 |  | 
|---|
| 2727 | fNoTileUpdate = TRUE; | 
|---|
| 2728 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 2729 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 2730 | if (hwndChild != hwndTree) { | 
|---|
| 2731 | hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT); | 
|---|
| 2732 | if (hwndTemp) { | 
|---|
| 2733 | hwndDir = WinWindowFromID(hwndTemp, DIR_CNR); | 
|---|
| 2734 | if (hwndDir) { | 
|---|
| 2735 | WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT), | 
|---|
| 2736 | WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 2737 | ret = TRUE; | 
|---|
| 2738 | } | 
|---|
| 2739 | } | 
|---|
| 2740 | } | 
|---|
| 2741 | } | 
|---|
| 2742 | WinEndEnumWindows(henum); | 
|---|
| 2743 | fNoTileUpdate = FALSE; | 
|---|
| 2744 | return ret; | 
|---|
| 2745 | } | 
|---|
| 2746 |  | 
|---|
| 2747 | /** Save directory container state | 
|---|
| 2748 | * @param hwndClient Client window handle | 
|---|
| 2749 | * @param pszStateName State name to save, NULL to save global state | 
|---|
| 2750 | * @returns Number of directory container windows that were saved or -1 if error | 
|---|
| 2751 | * @seealso RestoreDirCnrState | 
|---|
| 2752 | */ | 
|---|
| 2753 |  | 
|---|
| 2754 | #define STATE_NAME_MAX_BYTES    256 | 
|---|
| 2755 |  | 
|---|
| 2756 | INT SaveDirCnrState(HWND hwndClient, PSZ pszStateName) | 
|---|
| 2757 | { | 
|---|
| 2758 | HENUM henum; | 
|---|
| 2759 | HWND hwndChild, hwndDir, hwndC; | 
|---|
| 2760 | ULONG numsaves = 0, flWindowAttr; | 
|---|
| 2761 | CHAR szPrefix[STATE_NAME_MAX_BYTES + 1]; | 
|---|
| 2762 | CHAR szKey[STATE_NAME_MAX_BYTES + 80]; | 
|---|
| 2763 | CHAR szDir[CCHMAXPATH]; | 
|---|
| 2764 | SWP swp; | 
|---|
| 2765 | INT nSaved = 0; | 
|---|
| 2766 | DIRCNRDATA *dcd; | 
|---|
| 2767 |  | 
|---|
| 2768 | if (!pszStateName) | 
|---|
| 2769 | strcpy(szPrefix, NullStr); | 
|---|
| 2770 | else { | 
|---|
| 2771 | if (strlen(pszStateName) > sizeof(szPrefix) - 2) { | 
|---|
| 2772 | Runtime_Error(pszSrcFile, __LINE__, "SaveDirCnrState"); | 
|---|
| 2773 | return -1; | 
|---|
| 2774 | } | 
|---|
| 2775 | sprintf(szPrefix, "%s.", pszStateName); | 
|---|
| 2776 | } | 
|---|
| 2777 |  | 
|---|
| 2778 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 2779 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 2780 | if (hwndChild != hwndTree) { | 
|---|
| 2781 | hwndC = WinWindowFromID(hwndChild, FID_CLIENT); | 
|---|
| 2782 | if (hwndC) { | 
|---|
| 2783 | hwndDir = WinWindowFromID(hwndC, DIR_CNR); | 
|---|
| 2784 | if (hwndDir) { | 
|---|
| 2785 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 2786 | *szDir = 0; | 
|---|
| 2787 | WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID); | 
|---|
| 2788 | if (*szDir) { | 
|---|
| 2789 | if (driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) | 
|---|
| 2790 | continue; | 
|---|
| 2791 | sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves); | 
|---|
| 2792 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, | 
|---|
| 2793 | sizeof(SWP)); | 
|---|
| 2794 | dcd = | 
|---|
| 2795 | WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER); | 
|---|
| 2796 | if (dcd) { | 
|---|
| 2797 | sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves); | 
|---|
| 2798 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags, | 
|---|
| 2799 | sizeof(INT)); | 
|---|
| 2800 | sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves); | 
|---|
| 2801 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask, | 
|---|
| 2802 | sizeof(MASK)); | 
|---|
| 2803 | sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves); | 
|---|
| 2804 | flWindowAttr = dcd->flWindowAttr; | 
|---|
| 2805 | if (!fLeaveTree && (flWindowAttr & CV_TREE)) { | 
|---|
| 2806 | flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT)); | 
|---|
| 2807 | if (dcd->lastattr) { | 
|---|
| 2808 | if (dcd->lastattr & CV_TEXT) | 
|---|
| 2809 | flWindowAttr |= CV_TEXT; | 
|---|
| 2810 | else if (dcd->lastattr & CV_DETAIL) | 
|---|
| 2811 | flWindowAttr |= CV_DETAIL; | 
|---|
| 2812 | else if (dcd->lastattr & CV_ICON) | 
|---|
| 2813 | flWindowAttr |= CV_ICON; | 
|---|
| 2814 | else | 
|---|
| 2815 | flWindowAttr |= CV_NAME; | 
|---|
| 2816 | } | 
|---|
| 2817 | else | 
|---|
| 2818 | flWindowAttr |= CV_NAME; | 
|---|
| 2819 | } | 
|---|
| 2820 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr, | 
|---|
| 2821 | sizeof(ULONG)); | 
|---|
| 2822 | } | 
|---|
| 2823 | sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++); | 
|---|
| 2824 | PrfWriteProfileString(fmprof, FM3Str, szKey, szDir); | 
|---|
| 2825 | nSaved++; | 
|---|
| 2826 | } | 
|---|
| 2827 | } | 
|---|
| 2828 | } | 
|---|
| 2829 | } | 
|---|
| 2830 | } // while | 
|---|
| 2831 | WinEndEnumWindows(henum); | 
|---|
| 2832 |  | 
|---|
| 2833 | if (nSaved) { | 
|---|
| 2834 | if (WinQueryWindowPos(hwndTree, &swp)) { | 
|---|
| 2835 | sprintf(szKey, "%sLastTreePos", szPrefix); | 
|---|
| 2836 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, sizeof(SWP)); | 
|---|
| 2837 | } | 
|---|
| 2838 | sprintf(szKey, "%sNumDirsLastTime", szPrefix); | 
|---|
| 2839 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & numsaves, sizeof(ULONG)); | 
|---|
| 2840 | WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swp); | 
|---|
| 2841 | sprintf(szKey, "%sMySizeLastTime", szPrefix); | 
|---|
| 2842 | PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, sizeof(SWP)); | 
|---|
| 2843 | } | 
|---|
| 2844 |  | 
|---|
| 2845 | return nSaved; | 
|---|
| 2846 | } | 
|---|
| 2847 |  | 
|---|
| 2848 | static VOID TransformSwp(PSWP pswp, double xtrans, double ytrans) | 
|---|
| 2849 | { | 
|---|
| 2850 | SWP swp; | 
|---|
| 2851 | HWND hwnd; | 
|---|
| 2852 |  | 
|---|
| 2853 | if ((LONG) pswp->x < 0L) { | 
|---|
| 2854 | pswp->cx -= abs(pswp->x); | 
|---|
| 2855 | pswp->x = 0; | 
|---|
| 2856 | } | 
|---|
| 2857 | if ((LONG) pswp->y < 0L) { | 
|---|
| 2858 | pswp->cy -= abs(pswp->y); | 
|---|
| 2859 | pswp->y = 0; | 
|---|
| 2860 | } | 
|---|
| 2861 | pswp->x = (LONG) (((double)pswp->x * 100.0) / xtrans); | 
|---|
| 2862 | pswp->cx = (LONG) (((double)pswp->cx * 100.0) / xtrans); | 
|---|
| 2863 | pswp->y = (LONG) (((double)pswp->y * 100.0) / ytrans); | 
|---|
| 2864 | pswp->cy = (LONG) (((double)pswp->cy * 100.0) / ytrans); | 
|---|
| 2865 | if (pswp->hwnd) { | 
|---|
| 2866 | hwnd = WinQueryWindow(pswp->hwnd, QW_PARENT); | 
|---|
| 2867 | if (hwnd) { | 
|---|
| 2868 | if (WinQueryWindowPos(hwnd, &swp)) { | 
|---|
| 2869 | if (pswp->x > swp.cx) | 
|---|
| 2870 | pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx; | 
|---|
| 2871 | if (pswp->y > swp.cy) | 
|---|
| 2872 | pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy; | 
|---|
| 2873 | if (pswp->x + pswp->cx > swp.cx) | 
|---|
| 2874 | pswp->cx = swp.cx - pswp->x; | 
|---|
| 2875 | if (pswp->y + pswp->cy > swp.cy) | 
|---|
| 2876 | pswp->cy = swp.cy - pswp->y; | 
|---|
| 2877 | } | 
|---|
| 2878 | } | 
|---|
| 2879 | } | 
|---|
| 2880 | } | 
|---|
| 2881 |  | 
|---|
| 2882 | /** Restore directory container state | 
|---|
| 2883 | * @param hwndClient Client window handle | 
|---|
| 2884 | * @param pszStateName State name to restore, NULL to restore global state | 
|---|
| 2885 | * @returns TRUE if one or more directory containers were opened | 
|---|
| 2886 | * @seealso SaveDirCnrState | 
|---|
| 2887 | */ | 
|---|
| 2888 |  | 
|---|
| 2889 | static BOOL RestoreDirCnrState(HWND hwndClient, PSZ pszStateName, BOOL noview) | 
|---|
| 2890 | { | 
|---|
| 2891 | CHAR szKey[STATE_NAME_MAX_BYTES + 80]; | 
|---|
| 2892 | CHAR szDir[CCHMAXPATH]; | 
|---|
| 2893 | CHAR szPrefix[STATE_NAME_MAX_BYTES + 2]; | 
|---|
| 2894 | HWND hwndDir, hwndC; | 
|---|
| 2895 | SWP swp, swpO, swpN; | 
|---|
| 2896 | ULONG size, numsaves = 0L, x; | 
|---|
| 2897 | double xtrans, ytrans; | 
|---|
| 2898 | BOOL fRestored = FALSE; | 
|---|
| 2899 | DIRCNRDATA *dcd; | 
|---|
| 2900 |  | 
|---|
| 2901 | if (!pszStateName) | 
|---|
| 2902 | strcpy(szPrefix, NullStr); | 
|---|
| 2903 | else { | 
|---|
| 2904 | if (strlen(pszStateName) > sizeof(szPrefix) - 2) { | 
|---|
| 2905 | Runtime_Error(pszSrcFile, __LINE__, "RestoreDirCnrState"); | 
|---|
| 2906 | return fRestored; | 
|---|
| 2907 | } | 
|---|
| 2908 | sprintf(szPrefix, "%s.", pszStateName); | 
|---|
| 2909 | } | 
|---|
| 2910 |  | 
|---|
| 2911 | size = sizeof(SWP); | 
|---|
| 2912 | sprintf(szKey, "%sMySizeLastTime", szPrefix); | 
|---|
| 2913 | if (!PrfQueryProfileData(fmprof, | 
|---|
| 2914 | FM3Str, | 
|---|
| 2915 | szKey, | 
|---|
| 2916 | (PVOID) & swpO, | 
|---|
| 2917 | &size) || | 
|---|
| 2918 | size != sizeof(SWP) || !swp.cx || !swp.cy) | 
|---|
| 2919 | { | 
|---|
| 2920 | WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpO); | 
|---|
| 2921 | } | 
|---|
| 2922 | if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT))) | 
|---|
| 2923 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 2924 | WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpN); | 
|---|
| 2925 | if (swpN.fl & (SWP_MINIMIZE | SWP_HIDE)) | 
|---|
| 2926 | swpN = swpO; | 
|---|
| 2927 | xtrans = ((double)swpO.cx * 100.0) / (double)swpN.cx; | 
|---|
| 2928 | ytrans = ((double)swpO.cy * 100.0) / (double)swpN.cy; | 
|---|
| 2929 | size = sizeof(SWP); | 
|---|
| 2930 | sprintf(szKey, "%sLastTreePos", szPrefix); | 
|---|
| 2931 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, &size)) { | 
|---|
| 2932 | if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT))) | 
|---|
| 2933 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 2934 | swp.hwnd = hwndTree; | 
|---|
| 2935 | TransformSwp(&swp, xtrans, ytrans); | 
|---|
| 2936 | if (!fFreeTree) { | 
|---|
| 2937 | WinQueryWindowPos(hwndClient, &swpN); | 
|---|
| 2938 | swp.x = 0; | 
|---|
| 2939 | swp.y = (swpN.cy - swp.cy); | 
|---|
| 2940 | } | 
|---|
| 2941 | if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) { | 
|---|
| 2942 | swp.fl &= (~SWP_ACTIVATE); | 
|---|
| 2943 | WinSetWindowPos(hwndTree, | 
|---|
| 2944 | HWND_TOP, | 
|---|
| 2945 | swp.x, | 
|---|
| 2946 | swp.y, | 
|---|
| 2947 | swp.cx, | 
|---|
| 2948 | swp.cy, | 
|---|
| 2949 | swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER); | 
|---|
| 2950 | } | 
|---|
| 2951 | else { | 
|---|
| 2952 | WinSetWindowPos(hwndTree, | 
|---|
| 2953 | HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW); | 
|---|
| 2954 | WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x); | 
|---|
| 2955 | WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx); | 
|---|
| 2956 | WinSetWindowUShort(hwndTree, QWS_YRESTORE, (USHORT) swp.y); | 
|---|
| 2957 | WinSetWindowUShort(hwndTree, QWS_CYRESTORE, (USHORT) swp.cy); | 
|---|
| 2958 | } | 
|---|
| 2959 | } | 
|---|
| 2960 | size = sizeof(ULONG); | 
|---|
| 2961 | sprintf(szKey, "%sNumDirsLastTime", szPrefix); | 
|---|
| 2962 | if (PrfQueryProfileData(fmprof, | 
|---|
| 2963 | FM3Str, szKey, (PVOID) & numsaves, &size) && numsaves) { | 
|---|
| 2964 | if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT))) | 
|---|
| 2965 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 2966 | for (x = 0; x < numsaves; x++) { | 
|---|
| 2967 | sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, x); | 
|---|
| 2968 | size = sizeof(SWP); | 
|---|
| 2969 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, &size)) { | 
|---|
| 2970 | if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT))) | 
|---|
| 2971 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 2972 | sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x); | 
|---|
| 2973 | size = sizeof(szDir); | 
|---|
| 2974 | if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) { | 
|---|
| 2975 | if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT))) | 
|---|
| 2976 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 2977 | if (driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) { | 
|---|
| 2978 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 2979 | continue; | 
|---|
| 2980 | } | 
|---|
| 2981 | hwndDir = (HWND) WinSendMsg(hwndClient, | 
|---|
| 2982 | UM_SETDIR, | 
|---|
| 2983 | MPFROMP(szDir), MPFROMLONG(1)); | 
|---|
| 2984 | if (hwndDir) { | 
|---|
| 2985 | hwndC = WinWindowFromID(hwndDir, FID_CLIENT); | 
|---|
| 2986 | if (hwndC) { | 
|---|
| 2987 | dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 2988 | QWL_USER); | 
|---|
| 2989 | if (dcd) { | 
|---|
| 2990 | size = sizeof(INT); | 
|---|
| 2991 | sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x); | 
|---|
| 2992 | if (PrfQueryProfileData(fmprof, | 
|---|
| 2993 | FM3Str, | 
|---|
| 2994 | szKey, | 
|---|
| 2995 | (PVOID) & dcd->sortFlags, | 
|---|
| 2996 | &size) && size == sizeof(INT)) { | 
|---|
| 2997 | if (!dcd->sortFlags) | 
|---|
| 2998 | dcd->sortFlags = SORT_PATHNAME; | 
|---|
| 2999 | } | 
|---|
| 3000 | if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT))) | 
|---|
| 3001 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 3002 | size = sizeof(MASK); | 
|---|
| 3003 | sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x); | 
|---|
| 3004 | if (PrfQueryProfileData(fmprof, | 
|---|
| 3005 | FM3Str, | 
|---|
| 3006 | szKey, | 
|---|
| 3007 | (PVOID) & dcd->mask, &size) && size) { | 
|---|
| 3008 | if (*dcd->mask.szMask) | 
|---|
| 3009 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 3010 | UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID); | 
|---|
| 3011 | } | 
|---|
| 3012 | *(dcd->mask.prompt) = 0; | 
|---|
| 3013 | if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT))) | 
|---|
| 3014 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 3015 | size = sizeof(ULONG); | 
|---|
| 3016 | sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x); | 
|---|
| 3017 | if (!noview) { | 
|---|
| 3018 | if (PrfQueryProfileData(fmprof, | 
|---|
| 3019 | FM3Str, | 
|---|
| 3020 | szKey, | 
|---|
| 3021 | (PVOID) & dcd->flWindowAttr, | 
|---|
| 3022 | &size) && size == sizeof(ULONG)) { | 
|---|
| 3023 |  | 
|---|
| 3024 | CNRINFO cnri; | 
|---|
| 3025 |  | 
|---|
| 3026 | memset(&cnri, 0, sizeof(CNRINFO)); | 
|---|
| 3027 | cnri.cb = sizeof(CNRINFO); | 
|---|
| 3028 | if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 3029 | CM_QUERYCNRINFO, | 
|---|
| 3030 | MPFROMP(&cnri), | 
|---|
| 3031 | MPFROMLONG(sizeof(CNRINFO)))) { | 
|---|
| 3032 | cnri.flWindowAttr = dcd->flWindowAttr; | 
|---|
| 3033 | WinSendMsg(WinWindowFromID(hwndC, DIR_CNR), | 
|---|
| 3034 | CM_SETCNRINFO, | 
|---|
| 3035 | MPFROMP(&cnri), | 
|---|
| 3036 | MPFROMLONG(CMA_FLWINDOWATTR)); | 
|---|
| 3037 | } | 
|---|
| 3038 | } | 
|---|
| 3039 | } | 
|---|
| 3040 | if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT))) | 
|---|
| 3041 | PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L); | 
|---|
| 3042 | } | 
|---|
| 3043 | } | 
|---|
| 3044 | fRestored = TRUE; | 
|---|
| 3045 | swp.hwnd = hwndDir; | 
|---|
| 3046 | TransformSwp(&swp, xtrans, ytrans); | 
|---|
| 3047 | if (!fAutoTile && !(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) | 
|---|
| 3048 | WinSetWindowPos(hwndDir, | 
|---|
| 3049 | HWND_TOP, | 
|---|
| 3050 | swp.x, | 
|---|
| 3051 | swp.y, | 
|---|
| 3052 | swp.cx, | 
|---|
| 3053 | swp.cy, | 
|---|
| 3054 | swp.fl | SWP_MOVE | | 
|---|
| 3055 | SWP_SIZE | SWP_SHOW | SWP_ZORDER | | 
|---|
| 3056 | SWP_ACTIVATE); | 
|---|
| 3057 | else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) { | 
|---|
| 3058 | WinSetWindowPos(hwndDir, | 
|---|
| 3059 | HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW); | 
|---|
| 3060 | WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x); | 
|---|
| 3061 | WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx); | 
|---|
| 3062 | WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y); | 
|---|
| 3063 | WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy); | 
|---|
| 3064 | } | 
|---|
| 3065 | else | 
|---|
| 3066 | WinSetWindowPos(hwndDir, | 
|---|
| 3067 | HWND_TOP, | 
|---|
| 3068 | 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE); | 
|---|
| 3069 | } | 
|---|
| 3070 | } | 
|---|
| 3071 | } | 
|---|
| 3072 | } // for | 
|---|
| 3073 | } | 
|---|
| 3074 | return fRestored; | 
|---|
| 3075 | } | 
|---|
| 3076 |  | 
|---|
| 3077 | static ULONG CountChildren(HWND hwndClient, ULONG * ulNumMinChildren) | 
|---|
| 3078 | { | 
|---|
| 3079 | HENUM henum; | 
|---|
| 3080 | HWND hwndChild; | 
|---|
| 3081 | SWP swp; | 
|---|
| 3082 | register ULONG ulCnt = 0L; | 
|---|
| 3083 | USHORT id; | 
|---|
| 3084 |  | 
|---|
| 3085 | if (ulNumMinChildren) | 
|---|
| 3086 | *ulNumMinChildren = 0L; | 
|---|
| 3087 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3088 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3089 | id = WinQueryWindowUShort(hwndChild, QWS_ID); | 
|---|
| 3090 | if (!id || (!fFreeTree && id == TREE_FRAME)) | 
|---|
| 3091 | continue; | 
|---|
| 3092 | ulCnt++; | 
|---|
| 3093 | if (ulNumMinChildren) { | 
|---|
| 3094 | if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE)) | 
|---|
| 3095 | (*ulNumMinChildren)++; | 
|---|
| 3096 | } | 
|---|
| 3097 | } | 
|---|
| 3098 | WinEndEnumWindows(henum); | 
|---|
| 3099 | return ulCnt; | 
|---|
| 3100 | } | 
|---|
| 3101 |  | 
|---|
| 3102 | VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR, | 
|---|
| 3103 | ULONG * ulNumMinChildrenR) | 
|---|
| 3104 | { | 
|---|
| 3105 | register ULONG ulCnt; | 
|---|
| 3106 | ULONG ulNumMinChildren; | 
|---|
| 3107 | RECTL Rectl; | 
|---|
| 3108 | register ULONG ulXDiff, ulYDiff, ulWindowsPerStack; | 
|---|
| 3109 |  | 
|---|
| 3110 | if (!ulCntR || !ulNumMinChildrenR) | 
|---|
| 3111 | ulCnt = CountChildren(hwndClient, &ulNumMinChildren); | 
|---|
| 3112 | else { | 
|---|
| 3113 | ulCnt = *ulCntR; | 
|---|
| 3114 | ulNumMinChildren = *ulNumMinChildrenR; | 
|---|
| 3115 | if (ulCnt == (ULONG) - 1) { | 
|---|
| 3116 | ulCnt = CountChildren(hwndClient, &ulNumMinChildren); | 
|---|
| 3117 | /* return these values to the caller for later use */ | 
|---|
| 3118 | *ulCntR = ulCnt; | 
|---|
| 3119 | *ulNumMinChildrenR = ulNumMinChildren; | 
|---|
| 3120 | } | 
|---|
| 3121 | } | 
|---|
| 3122 | WinQueryWindowRect(hwndClient, &Rectl); | 
|---|
| 3123 | AdjustSizeOfClient(NULL, &Rectl); | 
|---|
| 3124 | if (!fFreeTree) { | 
|---|
| 3125 |  | 
|---|
| 3126 | SWP swp; | 
|---|
| 3127 |  | 
|---|
| 3128 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3129 | if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE))) | 
|---|
| 3130 | Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 3131 | } | 
|---|
| 3132 | else if (ulNumMinChildren) | 
|---|
| 3133 | Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 3134 |  | 
|---|
| 3135 | ulXDiff = WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER) + | 
|---|
| 3136 | WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON) / 2; | 
|---|
| 3137 | ulYDiff = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER) + | 
|---|
| 3138 | WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON); | 
|---|
| 3139 | ulWindowsPerStack = (Rectl.yTop - Rectl.yBottom) / (3 * ulYDiff); | 
|---|
| 3140 | pswp->cx = Rectl.xRight - (ulWindowsPerStack * ulXDiff); | 
|---|
| 3141 | pswp->cy = (Rectl.yTop - Rectl.yBottom) - (ulWindowsPerStack * ulYDiff); | 
|---|
| 3142 | ulWindowsPerStack++; | 
|---|
| 3143 | pswp->x = Rectl.xLeft + ((ulCnt % ulWindowsPerStack) * ulXDiff); | 
|---|
| 3144 | pswp->y = (Rectl.yTop - pswp->cy - ((ulCnt % ulWindowsPerStack) * ulYDiff)); | 
|---|
| 3145 | } | 
|---|
| 3146 |  | 
|---|
| 3147 | static VOID CascadeChildren(HWND hwndClient) | 
|---|
| 3148 | { | 
|---|
| 3149 | ULONG ulCnt = 0L, ulNumMinChildren; | 
|---|
| 3150 | HWND hwndChild; | 
|---|
| 3151 | HENUM henum; | 
|---|
| 3152 | SWP swp; | 
|---|
| 3153 | USHORT id; | 
|---|
| 3154 | RECTL Rectl; | 
|---|
| 3155 |  | 
|---|
| 3156 | WinQueryWindowPos(hwndClient, &swp); | 
|---|
| 3157 | if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 3158 | return; | 
|---|
| 3159 |  | 
|---|
| 3160 | CountChildren(hwndClient, &ulNumMinChildren); | 
|---|
| 3161 | if (!fFreeTree) { | 
|---|
| 3162 | WinQueryWindowRect(hwndClient, &Rectl); | 
|---|
| 3163 | AdjustSizeOfClient(NULL, &Rectl); | 
|---|
| 3164 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3165 | if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 3166 | if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) | 
|---|
| 3167 | swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; | 
|---|
| 3168 | if (swp.x != 0) | 
|---|
| 3169 | swp.x = 0; | 
|---|
| 3170 | if (swp.y < 0) | 
|---|
| 3171 | swp.y = 0; | 
|---|
| 3172 | if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) | 
|---|
| 3173 | swp.cx = Rectl.xRight - Rectl.xLeft; | 
|---|
| 3174 | WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 3175 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); | 
|---|
| 3176 | } | 
|---|
| 3177 | } | 
|---|
| 3178 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3179 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3180 | id = WinQueryWindowUShort(hwndChild, QWS_ID); | 
|---|
| 3181 | if (!id || (!fFreeTree && id == TREE_FRAME)) | 
|---|
| 3182 | continue; | 
|---|
| 3183 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 3184 | if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE))) { | 
|---|
| 3185 | GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren); | 
|---|
| 3186 | WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 3187 | SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE | | 
|---|
| 3188 | SWP_ZORDER | SWP_ACTIVATE); | 
|---|
| 3189 | ulCnt++; | 
|---|
| 3190 | } | 
|---|
| 3191 | } | 
|---|
| 3192 | WinEndEnumWindows(henum); | 
|---|
| 3193 | } | 
|---|
| 3194 |  | 
|---|
| 3195 | VOID TileChildren(HWND hwndClient, BOOL absolute) | 
|---|
| 3196 | { | 
|---|
| 3197 | register ULONG ulChildCnt, ulSquare, ulNumRows, ulNumCols, ulExtraCols, | 
|---|
| 3198 | ulWidth, ulHeight; | 
|---|
| 3199 | ULONG ulNumMinChildren; | 
|---|
| 3200 | RECTL Rectl; | 
|---|
| 3201 | HWND hwndChild; | 
|---|
| 3202 |  | 
|---|
| 3203 | if (fNoTileUpdate || hwndClient == HWND_DESKTOP) | 
|---|
| 3204 | return; | 
|---|
| 3205 | { | 
|---|
| 3206 | SWP swp; | 
|---|
| 3207 |  | 
|---|
| 3208 | WinQueryWindowPos(hwndClient, &swp); | 
|---|
| 3209 | if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 3210 | return; | 
|---|
| 3211 | } | 
|---|
| 3212 | ulChildCnt = CountChildren(hwndClient, &ulNumMinChildren); | 
|---|
| 3213 | ulChildCnt -= ulNumMinChildren; | 
|---|
| 3214 | if (!ulChildCnt) | 
|---|
| 3215 | return; | 
|---|
| 3216 |  | 
|---|
| 3217 | fNoTileUpdate = TRUE; | 
|---|
| 3218 |  | 
|---|
| 3219 | for (ulSquare = 2; ulSquare * ulSquare <= ulChildCnt; ulSquare++) { | 
|---|
| 3220 | ; | 
|---|
| 3221 | } | 
|---|
| 3222 | if (!fTileBackwards) { | 
|---|
| 3223 | ulNumCols = ulSquare - 1; | 
|---|
| 3224 | ulNumRows = ulChildCnt / ulNumCols; | 
|---|
| 3225 | } | 
|---|
| 3226 | else { | 
|---|
| 3227 | ulNumRows = ulSquare - 1; | 
|---|
| 3228 | ulNumCols = ulChildCnt / ulNumRows; | 
|---|
| 3229 | } | 
|---|
| 3230 | ulExtraCols = ulChildCnt % ulNumCols; | 
|---|
| 3231 |  | 
|---|
| 3232 | WinQueryWindowRect(hwndClient, &Rectl); | 
|---|
| 3233 |  | 
|---|
| 3234 | if (!fFreeTree) { | 
|---|
| 3235 |  | 
|---|
| 3236 | SWP swp; | 
|---|
| 3237 |  | 
|---|
| 3238 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3239 | if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 3240 | if (swp.y < 0) | 
|---|
| 3241 | swp.y = 0; | 
|---|
| 3242 | if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) | 
|---|
| 3243 | swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; | 
|---|
| 3244 | if (swp.x != 0) | 
|---|
| 3245 | swp.x = 0; | 
|---|
| 3246 | if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) | 
|---|
| 3247 | swp.cx = Rectl.xRight - Rectl.xLeft; | 
|---|
| 3248 | WinSetWindowPos(hwndTree, | 
|---|
| 3249 | HWND_TOP, | 
|---|
| 3250 | swp.x, | 
|---|
| 3251 | swp.y, | 
|---|
| 3252 | swp.cx, | 
|---|
| 3253 | swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); | 
|---|
| 3254 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3255 | } | 
|---|
| 3256 | if (ulNumMinChildren || (swp.fl & (SWP_HIDE | SWP_MINIMIZE))) | 
|---|
| 3257 | Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 3258 | } | 
|---|
| 3259 | else if (ulNumMinChildren) | 
|---|
| 3260 | Rectl.yBottom += WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 3261 |  | 
|---|
| 3262 | AdjustSizeOfClient(NULL, &Rectl); | 
|---|
| 3263 |  | 
|---|
| 3264 | if (Rectl.xRight > 0L && (Rectl.yBottom < Rectl.yTop)) { | 
|---|
| 3265 |  | 
|---|
| 3266 | HENUM henum; | 
|---|
| 3267 |  | 
|---|
| 3268 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3269 | if ((hwndChild = WinGetNextWindow(henum)) != (HWND) 0) { | 
|---|
| 3270 |  | 
|---|
| 3271 | ULONG ulCurRow, ulCurCol; | 
|---|
| 3272 | SWP swp; | 
|---|
| 3273 | USHORT id; | 
|---|
| 3274 |  | 
|---|
| 3275 | ulHeight = (Rectl.yTop - Rectl.yBottom) / ulNumRows; | 
|---|
| 3276 |  | 
|---|
| 3277 | for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) { | 
|---|
| 3278 | if ((ulNumRows - ulCurRow) <= ulExtraCols) | 
|---|
| 3279 | ulNumCols++; | 
|---|
| 3280 | for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) { | 
|---|
| 3281 | ulWidth = Rectl.xRight / ulNumCols; | 
|---|
| 3282 |  | 
|---|
| 3283 | while (hwndChild) { | 
|---|
| 3284 | id = WinQueryWindowUShort(hwndChild, QWS_ID); | 
|---|
| 3285 | if (id && (id != TREE_FRAME || fFreeTree)) { | 
|---|
| 3286 | WinQueryWindowPos(hwndChild, &swp); | 
|---|
| 3287 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) | 
|---|
| 3288 | break; | 
|---|
| 3289 | } | 
|---|
| 3290 | hwndChild = WinGetNextWindow(henum); | 
|---|
| 3291 | } | 
|---|
| 3292 |  | 
|---|
| 3293 | if (hwndChild) { | 
|---|
| 3294 | if (!absolute && (swp.fl & SWP_MAXIMIZE)) { | 
|---|
| 3295 | WinGetMaxPosition(hwndChild, &swp); | 
|---|
| 3296 | WinSetWindowPos(hwndChild, | 
|---|
| 3297 | HWND_TOP, | 
|---|
| 3298 | swp.x, | 
|---|
| 3299 | swp.y, | 
|---|
| 3300 | swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW); | 
|---|
| 3301 | WinSetWindowUShort(hwndChild, | 
|---|
| 3302 | QWS_XRESTORE, | 
|---|
| 3303 | (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft); | 
|---|
| 3304 | WinSetWindowUShort(hwndChild, | 
|---|
| 3305 | QWS_YRESTORE, | 
|---|
| 3306 | (USHORT) (Rectl.yTop - | 
|---|
| 3307 | (ulHeight * (ulCurRow + 1)))); | 
|---|
| 3308 | WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth); | 
|---|
| 3309 | WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight); | 
|---|
| 3310 | } | 
|---|
| 3311 | else | 
|---|
| 3312 | WinSetWindowPos(hwndChild, | 
|---|
| 3313 | HWND_TOP, | 
|---|
| 3314 | (ulWidth * ulCurCol) + Rectl.xLeft, | 
|---|
| 3315 | Rectl.yTop - (ulHeight * (ulCurRow + 1)), | 
|---|
| 3316 | ulWidth, | 
|---|
| 3317 | ulHeight, | 
|---|
| 3318 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); | 
|---|
| 3319 | hwndChild = WinGetNextWindow(henum); | 
|---|
| 3320 | } | 
|---|
| 3321 | } | 
|---|
| 3322 | if ((ulNumRows - ulCurRow) <= ulExtraCols) { | 
|---|
| 3323 | ulNumCols--; | 
|---|
| 3324 | ulExtraCols--; | 
|---|
| 3325 | } | 
|---|
| 3326 | } | 
|---|
| 3327 | } | 
|---|
| 3328 | WinEndEnumWindows(henum); | 
|---|
| 3329 | } | 
|---|
| 3330 |  | 
|---|
| 3331 | fNoTileUpdate = FALSE; | 
|---|
| 3332 | } | 
|---|
| 3333 |  | 
|---|
| 3334 | static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy, | 
|---|
| 3335 | SHORT newcx, SHORT newcy) | 
|---|
| 3336 | { | 
|---|
| 3337 | /* | 
|---|
| 3338 | * resize all children of the client to maintain their proportional | 
|---|
| 3339 | * sizes and positions | 
|---|
| 3340 | */ | 
|---|
| 3341 |  | 
|---|
| 3342 | if (!newcx || !newcy || !oldcx || !oldcy) | 
|---|
| 3343 | return; | 
|---|
| 3344 | { | 
|---|
| 3345 | HENUM henum; | 
|---|
| 3346 | HWND hwndChild; | 
|---|
| 3347 | register LONG x, y, cx, cy, ucx, ucy, ux, uy; | 
|---|
| 3348 | SWP swp; | 
|---|
| 3349 |  | 
|---|
| 3350 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3351 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3352 | if (!WinQueryWindowUShort(hwndChild, QWS_ID)) | 
|---|
| 3353 | continue; | 
|---|
| 3354 | if (WinQueryWindowPos(hwndChild, &swp)) { | 
|---|
| 3355 | if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) { | 
|---|
| 3356 | swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE); | 
|---|
| 3357 | swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE); | 
|---|
| 3358 | swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE); | 
|---|
| 3359 | swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE); | 
|---|
| 3360 | } | 
|---|
| 3361 | else if (swp.fl & SWP_MAXIMIZE) { | 
|---|
| 3362 | swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE); | 
|---|
| 3363 | swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE); | 
|---|
| 3364 | swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE); | 
|---|
| 3365 | swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE); | 
|---|
| 3366 | } | 
|---|
| 3367 | cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0; | 
|---|
| 3368 | cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0; | 
|---|
| 3369 | x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0; | 
|---|
| 3370 | y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0; | 
|---|
| 3371 | if (x < 0) | 
|---|
| 3372 | x = 0; | 
|---|
| 3373 | if (y < 0) | 
|---|
| 3374 | y = 0; | 
|---|
| 3375 | ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0; | 
|---|
| 3376 | uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0; | 
|---|
| 3377 | ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0; | 
|---|
| 3378 | ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0; | 
|---|
| 3379 | if (ux + ucx > newcx) | 
|---|
| 3380 | ucx = newcx - ux; | 
|---|
| 3381 | if (uy + ucy > newcy) | 
|---|
| 3382 | ucy = newcy - uy; | 
|---|
| 3383 |  | 
|---|
| 3384 | if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) | 
|---|
| 3385 | WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy, | 
|---|
| 3386 | SWP_MOVE | SWP_SIZE | SWP_SHOW); | 
|---|
| 3387 | else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) { | 
|---|
| 3388 | WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1); | 
|---|
| 3389 | WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1); | 
|---|
| 3390 | WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, | 
|---|
| 3391 | SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE); | 
|---|
| 3392 | WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux); | 
|---|
| 3393 | WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy); | 
|---|
| 3394 | WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx); | 
|---|
| 3395 | WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy); | 
|---|
| 3396 | } | 
|---|
| 3397 | else { | 
|---|
| 3398 | WinGetMaxPosition(hwndChild, &swp); | 
|---|
| 3399 | WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 3400 | SWP_MOVE | SWP_SIZE | SWP_SHOW); | 
|---|
| 3401 | WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux); | 
|---|
| 3402 | WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy); | 
|---|
| 3403 | WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx); | 
|---|
| 3404 | WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy); | 
|---|
| 3405 | } | 
|---|
| 3406 | } | 
|---|
| 3407 | } | 
|---|
| 3408 | WinEndEnumWindows(henum); | 
|---|
| 3409 | } | 
|---|
| 3410 | if (!fFreeTree) { | 
|---|
| 3411 |  | 
|---|
| 3412 | RECTL Rectl; | 
|---|
| 3413 | SWP swp; | 
|---|
| 3414 |  | 
|---|
| 3415 | WinQueryWindowRect(hwndClient, &Rectl); | 
|---|
| 3416 | AdjustSizeOfClient(NULL, &Rectl); | 
|---|
| 3417 | WinQueryWindowPos(hwndTree, &swp); | 
|---|
| 3418 | if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 3419 | if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom) | 
|---|
| 3420 | swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y; | 
|---|
| 3421 | if (swp.x != 0) | 
|---|
| 3422 | swp.x = 0; | 
|---|
| 3423 | if (swp.y < 0) | 
|---|
| 3424 | swp.y = 0; | 
|---|
| 3425 | if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft) | 
|---|
| 3426 | swp.cx = Rectl.xRight - Rectl.xLeft; | 
|---|
| 3427 | WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 3428 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE); | 
|---|
| 3429 | } | 
|---|
| 3430 | } | 
|---|
| 3431 | } | 
|---|
| 3432 |  | 
|---|
| 3433 | static VOID MinResChildren(HWND hwndClient, ULONG cmd) | 
|---|
| 3434 | { | 
|---|
| 3435 | HENUM henum; | 
|---|
| 3436 | HWND hwndChild; | 
|---|
| 3437 |  | 
|---|
| 3438 | { | 
|---|
| 3439 | SWP swp; | 
|---|
| 3440 |  | 
|---|
| 3441 | WinQueryWindowPos(hwndClient, &swp); | 
|---|
| 3442 | if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 3443 | return; | 
|---|
| 3444 | } | 
|---|
| 3445 | henum = WinBeginEnumWindows(hwndClient); | 
|---|
| 3446 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) { | 
|---|
| 3447 | if (!WinQueryWindowUShort(hwndChild, QWS_ID)) | 
|---|
| 3448 | continue; | 
|---|
| 3449 | WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0, cmd); | 
|---|
| 3450 | } | 
|---|
| 3451 | } | 
|---|
| 3452 |  | 
|---|
| 3453 | //=== ChildFrameButtonProc: subclass handler for WALKBUTTON and QUICKBUTTON windows === | 
|---|
| 3454 |  | 
|---|
| 3455 | static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd, | 
|---|
| 3456 | ULONG msg, | 
|---|
| 3457 | MPARAM mp1, MPARAM mp2) | 
|---|
| 3458 | { | 
|---|
| 3459 | USHORT id; | 
|---|
| 3460 | static BOOL emphasized = FALSE; | 
|---|
| 3461 |  | 
|---|
| 3462 | switch (msg) { | 
|---|
| 3463 | case WM_BUTTON1CLICK: | 
|---|
| 3464 | case WM_CHORD: | 
|---|
| 3465 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 3466 | break; | 
|---|
| 3467 |  | 
|---|
| 3468 | case WM_MOUSEMOVE: | 
|---|
| 3469 | if (fOtherHelp) { | 
|---|
| 3470 | if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) | 
|---|
| 3471 | && !WinQueryCapture(HWND_DESKTOP)) { | 
|---|
| 3472 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 3473 | switch (id) { | 
|---|
| 3474 | case IDM_OPENWALK: | 
|---|
| 3475 | MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP)); | 
|---|
| 3476 | break; | 
|---|
| 3477 | case IDM_USERLIST: | 
|---|
| 3478 | MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP)); | 
|---|
| 3479 | break; | 
|---|
| 3480 | } | 
|---|
| 3481 | } | 
|---|
| 3482 | } | 
|---|
| 3483 | break; | 
|---|
| 3484 |  | 
|---|
| 3485 | case WM_BUTTON3CLICK: | 
|---|
| 3486 | case WM_BUTTON2CLICK: | 
|---|
| 3487 | { | 
|---|
| 3488 | USHORT cmd = 0; | 
|---|
| 3489 |  | 
|---|
| 3490 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 3491 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 3492 | switch (id) { | 
|---|
| 3493 | case IDM_OPENWALK: | 
|---|
| 3494 | switch (msg) { | 
|---|
| 3495 | case WM_BUTTON2CLICK: | 
|---|
| 3496 | if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) == | 
|---|
| 3497 | (KC_ALT | KC_SHIFT | KC_CTRL)) | 
|---|
| 3498 | cmd = IDM_GREP; | 
|---|
| 3499 | else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL)) | 
|---|
| 3500 | CascadeChildren(hwndMain); | 
|---|
| 3501 |  | 
|---|
| 3502 | #ifdef NEVER | 
|---|
| 3503 | else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT)) | 
|---|
| 3504 | cmd = IDM_SYSINFO; | 
|---|
| 3505 | #endif | 
|---|
| 3506 |  | 
|---|
| 3507 | else if (shiftstate & KC_SHIFT) | 
|---|
| 3508 | cmd = IDM_WINDOWDLG; | 
|---|
| 3509 | else if (shiftstate & KC_CTRL) | 
|---|
| 3510 | cmd = IDM_SEEALL; | 
|---|
| 3511 | else if (shiftstate & KC_ALT) | 
|---|
| 3512 | TileChildren(hwndMain, TRUE); | 
|---|
| 3513 | else | 
|---|
| 3514 | cmd = IDM_WALKDIR; | 
|---|
| 3515 | break; | 
|---|
| 3516 | case WM_BUTTON3CLICK: | 
|---|
| 3517 | TileChildren(hwndMain, TRUE); | 
|---|
| 3518 | break; | 
|---|
| 3519 | } | 
|---|
| 3520 | break; | 
|---|
| 3521 | case IDM_USERLIST: | 
|---|
| 3522 | switch (msg) { | 
|---|
| 3523 | case WM_BUTTON2CLICK: | 
|---|
| 3524 | if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) == | 
|---|
| 3525 | (KC_ALT | KC_SHIFT | KC_CTRL)) | 
|---|
| 3526 | cmd = IDM_COLORPALETTE; | 
|---|
| 3527 | else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL)) | 
|---|
| 3528 | cmd = IDM_HIDEMENU; | 
|---|
| 3529 | else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT)) | 
|---|
| 3530 | cmd = IDM_NOTEBOOK; | 
|---|
| 3531 | else if (shiftstate & KC_SHIFT) | 
|---|
| 3532 | cmd = IDM_TOOLTITLES; | 
|---|
| 3533 | else if (shiftstate & KC_CTRL) | 
|---|
| 3534 | cmd = IDM_TEXTTOOLS; | 
|---|
| 3535 | else if (shiftstate & KC_ALT) | 
|---|
| 3536 | cmd = IDM_FONTPALETTE; | 
|---|
| 3537 | else | 
|---|
| 3538 | cmd = IDM_TOOLBAR; | 
|---|
| 3539 | break; | 
|---|
| 3540 | case WM_BUTTON3CLICK: | 
|---|
| 3541 | cmd = IDM_DRIVEBAR; | 
|---|
| 3542 | break; | 
|---|
| 3543 | } | 
|---|
| 3544 | break; | 
|---|
| 3545 | }                                 // switch id | 
|---|
| 3546 |  | 
|---|
| 3547 | if (cmd) { | 
|---|
| 3548 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT), | 
|---|
| 3549 | WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID); | 
|---|
| 3550 | } | 
|---|
| 3551 | } | 
|---|
| 3552 | break; | 
|---|
| 3553 |  | 
|---|
| 3554 | case DM_DRAGOVER: | 
|---|
| 3555 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 3556 | if (id == IDM_OPENWALK) { | 
|---|
| 3557 | if (!emphasized) { | 
|---|
| 3558 | emphasized = TRUE; | 
|---|
| 3559 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 3560 | } | 
|---|
| 3561 | if (AcceptOneDrop(hwnd, mp1, mp2)) | 
|---|
| 3562 | return MRFROM2SHORT(DOR_DROP, DO_MOVE); | 
|---|
| 3563 | } | 
|---|
| 3564 | return MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| 3565 |  | 
|---|
| 3566 | case DM_DRAGLEAVE: | 
|---|
| 3567 | if (emphasized) { | 
|---|
| 3568 | emphasized = FALSE; | 
|---|
| 3569 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 3570 | } | 
|---|
| 3571 | break; | 
|---|
| 3572 |  | 
|---|
| 3573 | case DM_DROPHELP: | 
|---|
| 3574 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_OPENDROPHELP)); | 
|---|
| 3575 | return 0; | 
|---|
| 3576 |  | 
|---|
| 3577 | case DM_DROP: | 
|---|
| 3578 | { | 
|---|
| 3579 | char szFrom[CCHMAXPATH + 2]; | 
|---|
| 3580 |  | 
|---|
| 3581 | if (emphasized) { | 
|---|
| 3582 | emphasized = FALSE; | 
|---|
| 3583 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 3584 | } | 
|---|
| 3585 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) { | 
|---|
| 3586 | if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) { | 
|---|
| 3587 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom); | 
|---|
| 3588 | } | 
|---|
| 3589 | } | 
|---|
| 3590 | } | 
|---|
| 3591 | return 0; | 
|---|
| 3592 |  | 
|---|
| 3593 | case WM_CLOSE: | 
|---|
| 3594 | WinDestroyWindow(hwnd); | 
|---|
| 3595 | return 0; | 
|---|
| 3596 | } | 
|---|
| 3597 | return PFNWPButton(hwnd, msg, mp1, mp2); | 
|---|
| 3598 | } | 
|---|
| 3599 |  | 
|---|
| 3600 | static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 3601 | MPARAM mp2) | 
|---|
| 3602 | { | 
|---|
| 3603 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 3604 | static ULONG aheight = 0L; | 
|---|
| 3605 |  | 
|---|
| 3606 | switch (msg) { | 
|---|
| 3607 | case WM_ADJUSTWINDOWPOS: | 
|---|
| 3608 | { | 
|---|
| 3609 | SWP *pswp; | 
|---|
| 3610 |  | 
|---|
| 3611 | pswp = (SWP *) mp1; | 
|---|
| 3612 | if (fDataMin && !fAmClosing) { | 
|---|
| 3613 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) { | 
|---|
| 3614 |  | 
|---|
| 3615 | SWP swp; | 
|---|
| 3616 |  | 
|---|
| 3617 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 3618 | PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID); | 
|---|
| 3619 | HideNote(); | 
|---|
| 3620 | } | 
|---|
| 3621 | else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) { | 
|---|
| 3622 | if (DataHwnd) | 
|---|
| 3623 | PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 3624 | } | 
|---|
| 3625 | } | 
|---|
| 3626 | if (!fAmClosing) { | 
|---|
| 3627 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) | 
|---|
| 3628 | HideNote(); | 
|---|
| 3629 | } | 
|---|
| 3630 | } | 
|---|
| 3631 | break; | 
|---|
| 3632 |  | 
|---|
| 3633 | case UM_FOCUSME: | 
|---|
| 3634 | CreateDataBar(HWND_DESKTOP, (ULONG) mp1); | 
|---|
| 3635 | return 0; | 
|---|
| 3636 |  | 
|---|
| 3637 | case WM_BUTTON1UP: | 
|---|
| 3638 | case WM_BUTTON2UP: | 
|---|
| 3639 | case WM_BUTTON3UP: | 
|---|
| 3640 | case WM_MOUSEMOVE: | 
|---|
| 3641 | case WM_CHORD: | 
|---|
| 3642 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 3643 | break; | 
|---|
| 3644 |  | 
|---|
| 3645 | case WM_CHAR: | 
|---|
| 3646 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 3647 | break; | 
|---|
| 3648 |  | 
|---|
| 3649 | case WM_CONTROL: | 
|---|
| 3650 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1, | 
|---|
| 3651 | mp2); | 
|---|
| 3652 |  | 
|---|
| 3653 | case WM_COMMAND: | 
|---|
| 3654 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2); | 
|---|
| 3655 |  | 
|---|
| 3656 | case WM_CALCFRAMERECT: | 
|---|
| 3657 | { | 
|---|
| 3658 | MRESULT mr; | 
|---|
| 3659 | PRECTL prectl; | 
|---|
| 3660 | LONG sheight = 20, bheight = 20; | 
|---|
| 3661 |  | 
|---|
| 3662 | mr = oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 3663 |  | 
|---|
| 3664 | /* | 
|---|
| 3665 | * Calculate the position of the client rectangle. | 
|---|
| 3666 | * Otherwise, we'll see a lot of redraw when we move the | 
|---|
| 3667 | * client during WM_FORMATFRAME. | 
|---|
| 3668 | */ | 
|---|
| 3669 |  | 
|---|
| 3670 | if (mr && mp2) { | 
|---|
| 3671 | prectl = (PRECTL) mp1; | 
|---|
| 3672 | if (prectl->yBottom != prectl->yTop) { | 
|---|
| 3673 | { | 
|---|
| 3674 | HPS hps; | 
|---|
| 3675 | POINTL aptl[TXTBOX_COUNT]; | 
|---|
| 3676 |  | 
|---|
| 3677 | hps = WinGetPS(hwndStatus); | 
|---|
| 3678 | if (hps) { | 
|---|
| 3679 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 3680 | bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 3681 | WinReleasePS(hps); | 
|---|
| 3682 | } | 
|---|
| 3683 | } | 
|---|
| 3684 | prectl->yBottom += (sheight + 4); | 
|---|
| 3685 | prectl->yTop -= (sheight + 4); | 
|---|
| 3686 | if (fMoreButtons) { | 
|---|
| 3687 |  | 
|---|
| 3688 | HPS hps; | 
|---|
| 3689 | POINTL aptl[TXTBOX_COUNT]; | 
|---|
| 3690 |  | 
|---|
| 3691 | hps = WinGetPS(hwndName); | 
|---|
| 3692 | if (hps) { | 
|---|
| 3693 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 3694 | bheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 3695 | WinReleasePS(hps); | 
|---|
| 3696 | } | 
|---|
| 3697 | prectl->yBottom += (bheight + 4); | 
|---|
| 3698 | prectl->yTop -= (bheight + 4); | 
|---|
| 3699 | } | 
|---|
| 3700 | if (fToolbar) { | 
|---|
| 3701 | if (!fTextTools) | 
|---|
| 3702 | prectl->yTop -= ((fToolTitles) ? 50 : 40); | 
|---|
| 3703 | else | 
|---|
| 3704 | prectl->yTop -= 32; | 
|---|
| 3705 | } | 
|---|
| 3706 | if (fDrivebar) { | 
|---|
| 3707 | ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), | 
|---|
| 3708 | ((prectl->xRight - | 
|---|
| 3709 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 3710 | SV_CYSIZEBORDER) * 2)) - 4)); | 
|---|
| 3711 | prectl->yTop -= (16 * (DriveLines * 18)); | 
|---|
| 3712 | } | 
|---|
| 3713 | if (fUserComboBox) { | 
|---|
| 3714 | if (!aheight) { | 
|---|
| 3715 |  | 
|---|
| 3716 | SWP swpTemp; | 
|---|
| 3717 |  | 
|---|
| 3718 | WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 3719 | &swpTemp); | 
|---|
| 3720 | aheight = swpTemp.cy; | 
|---|
| 3721 | } | 
|---|
| 3722 | prectl->yTop -= (aheight + 6L); | 
|---|
| 3723 | } | 
|---|
| 3724 | if (fAutoView) { | 
|---|
| 3725 | AutoviewHeight = min(AutoviewHeight, | 
|---|
| 3726 | (prectl->yTop - prectl->yBottom) - 116); | 
|---|
| 3727 | AutoviewHeight = max(AutoviewHeight, 36); | 
|---|
| 3728 | prectl->yBottom += (AutoviewHeight + 6); | 
|---|
| 3729 | } | 
|---|
| 3730 | } | 
|---|
| 3731 | } | 
|---|
| 3732 | return mr; | 
|---|
| 3733 | } | 
|---|
| 3734 |  | 
|---|
| 3735 | case WM_FORMATFRAME: | 
|---|
| 3736 | { | 
|---|
| 3737 | SHORT sCount, soldCount; | 
|---|
| 3738 | PSWP pswp, pswpClient, pswpNew; | 
|---|
| 3739 | SWP swpClient; | 
|---|
| 3740 | LONG theight = 48L, dheight = 20L, width, sheight = 20, bheight = 20; | 
|---|
| 3741 |  | 
|---|
| 3742 | sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 3743 | soldCount = sCount; | 
|---|
| 3744 |  | 
|---|
| 3745 | /* | 
|---|
| 3746 | * Reformat the frame to "squeeze" the client | 
|---|
| 3747 | * and make room for status window sibling beneath | 
|---|
| 3748 | * and toolbar above (if toolbar's on) and userlists | 
|---|
| 3749 | * (if userlists are on). | 
|---|
| 3750 | */ | 
|---|
| 3751 |  | 
|---|
| 3752 | pswp = (PSWP) mp1; | 
|---|
| 3753 | { | 
|---|
| 3754 | SHORT x; | 
|---|
| 3755 |  | 
|---|
| 3756 | for (x = 0; x < soldCount; x++) { | 
|---|
| 3757 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) { | 
|---|
| 3758 | pswpClient = pswp; | 
|---|
| 3759 | break; | 
|---|
| 3760 | } | 
|---|
| 3761 | pswp++; | 
|---|
| 3762 | } | 
|---|
| 3763 | } | 
|---|
| 3764 |  | 
|---|
| 3765 | { | 
|---|
| 3766 | HPS hps; | 
|---|
| 3767 | POINTL aptl[TXTBOX_COUNT]; | 
|---|
| 3768 |  | 
|---|
| 3769 | hps = WinGetPS(hwndStatus); | 
|---|
| 3770 | if (hps) { | 
|---|
| 3771 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 3772 | bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 3773 | WinReleasePS(hps); | 
|---|
| 3774 | } | 
|---|
| 3775 | if (fMoreButtons) { | 
|---|
| 3776 | hps = WinGetPS(hwndName); | 
|---|
| 3777 | if (hps) { | 
|---|
| 3778 | GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl); | 
|---|
| 3779 | bheight = aptl[TXTBOX_TOPLEFT].y + 6; | 
|---|
| 3780 | WinReleasePS(hps); | 
|---|
| 3781 | } | 
|---|
| 3782 | } | 
|---|
| 3783 | } | 
|---|
| 3784 | pswpNew = (PSWP) mp1 + soldCount; | 
|---|
| 3785 | *pswpNew = *pswpClient; | 
|---|
| 3786 | swpClient = *pswpClient; | 
|---|
| 3787 | pswpNew->hwnd = hwndStatus; | 
|---|
| 3788 | pswpNew->hwndInsertBehind = HWND_BOTTOM; | 
|---|
| 3789 | pswpNew->x = swpClient.x + 3; | 
|---|
| 3790 | pswpNew->y = swpClient.y + 2; | 
|---|
| 3791 | if (!fSplitStatus) | 
|---|
| 3792 | width = swpClient.cx - (16 + (sheight * 2) + 4); | 
|---|
| 3793 | else | 
|---|
| 3794 | width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2; | 
|---|
| 3795 | width = max(width, 10); | 
|---|
| 3796 | if (fSplitStatus) | 
|---|
| 3797 | pswpNew->cx = width - 6; | 
|---|
| 3798 | else | 
|---|
| 3799 | pswpNew->cx = width - 8; | 
|---|
| 3800 | pswpNew->cy = sheight; | 
|---|
| 3801 | pswpClient->y = pswpNew->y + pswpNew->cy + 3; | 
|---|
| 3802 | pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3; | 
|---|
| 3803 | sCount++; | 
|---|
| 3804 |  | 
|---|
| 3805 | if (fSplitStatus) { | 
|---|
| 3806 | pswpNew = (PSWP) mp1 + (soldCount + 1); | 
|---|
| 3807 | *pswpNew = *pswpClient; | 
|---|
| 3808 | pswpNew->hwnd = hwndStatus2; | 
|---|
| 3809 | pswpNew->hwndInsertBehind = HWND_BOTTOM; | 
|---|
| 3810 | pswpNew->x = width + 8; | 
|---|
| 3811 | pswpNew->y = swpClient.y + 2; | 
|---|
| 3812 | pswpNew->cx = width - 6; | 
|---|
| 3813 | pswpNew->cy = sheight; | 
|---|
| 3814 | sCount++; | 
|---|
| 3815 | } | 
|---|
| 3816 | else { | 
|---|
| 3817 | WinShowWindow(hwndStatus2, FALSE); | 
|---|
| 3818 | WinSetWindowText(hwndStatus2, NullStr); | 
|---|
| 3819 | } | 
|---|
| 3820 |  | 
|---|
| 3821 | if (fToolbar) { | 
|---|
| 3822 | if (fTextTools) | 
|---|
| 3823 | theight = 32L; | 
|---|
| 3824 | else if (!fToolTitles) | 
|---|
| 3825 | theight = 40L; | 
|---|
| 3826 | pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE)); | 
|---|
| 3827 | *pswpNew = *pswpClient; | 
|---|
| 3828 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS); | 
|---|
| 3829 | pswpNew->hwndInsertBehind = HWND_BOTTOM; | 
|---|
| 3830 | pswpNew->x = swpClient.x + 2; | 
|---|
| 3831 | pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2); | 
|---|
| 3832 | pswpNew->cx = swpClient.cx - 4; | 
|---|
| 3833 | pswpNew->cy = theight - 4; | 
|---|
| 3834 | pswpClient->cy -= theight; | 
|---|
| 3835 | sCount++; | 
|---|
| 3836 | } | 
|---|
| 3837 | else | 
|---|
| 3838 | WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE); | 
|---|
| 3839 |  | 
|---|
| 3840 | if (fDrivebar) { | 
|---|
| 3841 | ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4); | 
|---|
| 3842 | pswpNew = (PSWP) mp1 + (soldCount + 1 + | 
|---|
| 3843 | (fSplitStatus != FALSE) + | 
|---|
| 3844 | (fToolbar != FALSE)); | 
|---|
| 3845 | *pswpNew = *pswpClient; | 
|---|
| 3846 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES); | 
|---|
| 3847 | pswpNew->hwndInsertBehind = HWND_BOTTOM; | 
|---|
| 3848 | pswpNew->x = swpClient.x + 2; | 
|---|
| 3849 | dheight += ((dheight - 2) * DriveLines); | 
|---|
| 3850 | pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2); | 
|---|
| 3851 | if (fToolbar) | 
|---|
| 3852 | pswpNew->y -= theight; | 
|---|
| 3853 | pswpNew->cx = swpClient.cx - 4; | 
|---|
| 3854 | pswpNew->cy = dheight - 4; | 
|---|
| 3855 | pswpClient->cy -= dheight; | 
|---|
| 3856 | sCount++; | 
|---|
| 3857 | } | 
|---|
| 3858 | else | 
|---|
| 3859 | WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE); | 
|---|
| 3860 |  | 
|---|
| 3861 | if (fAutoView) { | 
|---|
| 3862 | pswpNew = (PSWP) mp1 + (soldCount + 1 + | 
|---|
| 3863 | (fToolbar != FALSE) + | 
|---|
| 3864 | (fDrivebar != FALSE) + | 
|---|
| 3865 | (fSplitStatus != FALSE)); | 
|---|
| 3866 | *pswpNew = *pswpClient; | 
|---|
| 3867 | pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview; | 
|---|
| 3868 | pswpNew->x = pswpClient->x + 3; | 
|---|
| 3869 | pswpNew->y = pswpClient->y + 3; | 
|---|
| 3870 | if (fMoreButtons) | 
|---|
| 3871 | pswpNew->y += (bheight + 4); | 
|---|
| 3872 | pswpNew->cx = pswpClient->cx - 6; | 
|---|
| 3873 | AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116); | 
|---|
| 3874 | AutoviewHeight = max(AutoviewHeight, 36); | 
|---|
| 3875 | pswpNew->cy = AutoviewHeight; | 
|---|
| 3876 | pswpClient->y += (AutoviewHeight + 6); | 
|---|
| 3877 | pswpClient->cy -= (AutoviewHeight + 6); | 
|---|
| 3878 | sCount++; | 
|---|
| 3879 | WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE); | 
|---|
| 3880 | } | 
|---|
| 3881 | else { | 
|---|
| 3882 | WinShowWindow(hwndAutoview, FALSE); | 
|---|
| 3883 | WinShowWindow(hwndAutoMLE, FALSE); | 
|---|
| 3884 | } | 
|---|
| 3885 |  | 
|---|
| 3886 | pswpNew = (PSWP) mp1 + (soldCount + 1 + | 
|---|
| 3887 | (fToolbar != FALSE) + | 
|---|
| 3888 | (fDrivebar != FALSE) + | 
|---|
| 3889 | (fSplitStatus != FALSE) + (fAutoView != FALSE)); | 
|---|
| 3890 | *pswpNew = *pswpClient; | 
|---|
| 3891 | pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK); | 
|---|
| 3892 | pswpNew->x = swpClient.cx - ((sheight * 2) + 4); | 
|---|
| 3893 | pswpNew->y = swpClient.y; | 
|---|
| 3894 | pswpNew->cx = sheight + 4; | 
|---|
| 3895 | pswpNew->cy = sheight + 4; | 
|---|
| 3896 | sCount++; | 
|---|
| 3897 | pswpNew = (PSWP) mp1 + (soldCount + 2 + | 
|---|
| 3898 | (fToolbar != FALSE) + | 
|---|
| 3899 | (fDrivebar != FALSE) + | 
|---|
| 3900 | (fSplitStatus != FALSE) + (fAutoView != FALSE)); | 
|---|
| 3901 | *pswpNew = *pswpClient; | 
|---|
| 3902 | pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST); | 
|---|
| 3903 | pswpNew->x = swpClient.cx - (sheight + 2); | 
|---|
| 3904 | pswpNew->y = swpClient.y; | 
|---|
| 3905 | pswpNew->cx = sheight + 4; | 
|---|
| 3906 | pswpNew->cy = sheight + 4; | 
|---|
| 3907 | sCount++; | 
|---|
| 3908 | pswpNew = (PSWP) mp1 + (soldCount + 3 + | 
|---|
| 3909 | (fToolbar != FALSE) + | 
|---|
| 3910 | (fDrivebar != FALSE) + | 
|---|
| 3911 | (fSplitStatus != FALSE) + (fAutoView != FALSE)); | 
|---|
| 3912 | *pswpNew = *pswpClient; | 
|---|
| 3913 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED); | 
|---|
| 3914 | pswpNew->x = swpClient.cx - ((sheight * 2) + 16); | 
|---|
| 3915 | pswpNew->y = swpClient.y; | 
|---|
| 3916 | pswpNew->cx = 12; | 
|---|
| 3917 | pswpNew->cy = 12; | 
|---|
| 3918 | sCount++; | 
|---|
| 3919 | pswpNew = (PSWP) mp1 + (soldCount + 4 + | 
|---|
| 3920 | (fToolbar != FALSE) + | 
|---|
| 3921 | (fDrivebar != FALSE) + | 
|---|
| 3922 | (fSplitStatus != FALSE) + (fAutoView != FALSE)); | 
|---|
| 3923 | *pswpNew = *pswpClient; | 
|---|
| 3924 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR); | 
|---|
| 3925 | pswpNew->x = swpClient.cx - ((sheight * 2) + 16); | 
|---|
| 3926 | pswpNew->y = swpClient.y + 12; | 
|---|
| 3927 | pswpNew->cx = 12; | 
|---|
| 3928 | pswpNew->cy = sheight - 8; | 
|---|
| 3929 | sCount++; | 
|---|
| 3930 | if (fUserComboBox) { | 
|---|
| 3931 | if (!aheight) { | 
|---|
| 3932 |  | 
|---|
| 3933 | SWP swpTemp; | 
|---|
| 3934 |  | 
|---|
| 3935 | WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 3936 | &swpTemp); | 
|---|
| 3937 | aheight = swpTemp.cy; | 
|---|
| 3938 | } | 
|---|
| 3939 | pswpNew = (PSWP) mp1 + (soldCount + 5 + | 
|---|
| 3940 | (fToolbar != FALSE) + | 
|---|
| 3941 | (fSplitStatus != FALSE) + | 
|---|
| 3942 | (fDrivebar != FALSE) + (fAutoView != FALSE)); | 
|---|
| 3943 | *pswpNew = *pswpClient; | 
|---|
| 3944 | pswpNew->hwnd = hwndDrivelist; | 
|---|
| 3945 | pswpNew->x = swpClient.x; | 
|---|
| 3946 | pswpNew->cx = 48; | 
|---|
| 3947 | pswpClient->cy -= (aheight + 6L); | 
|---|
| 3948 | pswpNew->y = pswpClient->y; | 
|---|
| 3949 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 3950 | sCount++; | 
|---|
| 3951 | pswpNew = (PSWP) mp1 + (soldCount + 6 + | 
|---|
| 3952 | (fToolbar != FALSE) + | 
|---|
| 3953 | (fDrivebar != FALSE) + | 
|---|
| 3954 | (fSplitStatus != FALSE) + | 
|---|
| 3955 | (fAutoView != FALSE)); | 
|---|
| 3956 | *pswpNew = *pswpClient; | 
|---|
| 3957 | pswpNew->hwnd = hwndStatelist; | 
|---|
| 3958 | pswpNew->x = swpClient.x + 48; | 
|---|
| 3959 | pswpNew->cx = (swpClient.cx - 48) / 7; | 
|---|
| 3960 | pswpNew->y = pswpClient->y; | 
|---|
| 3961 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 3962 | sCount++; | 
|---|
| 3963 | pswpNew = (PSWP) mp1 + (soldCount + 7 + | 
|---|
| 3964 | (fToolbar != FALSE) + | 
|---|
| 3965 | (fDrivebar != FALSE) + | 
|---|
| 3966 | (fSplitStatus != FALSE) + | 
|---|
| 3967 | (fAutoView != FALSE)); | 
|---|
| 3968 | *pswpNew = *pswpClient; | 
|---|
| 3969 | pswpNew->hwnd = hwndCmdlist; | 
|---|
| 3970 | pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7); | 
|---|
| 3971 | pswpNew->cx = (swpClient.cx - 48) / 5 + | 
|---|
| 3972 | ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7); | 
|---|
| 3973 | pswpNew->y = pswpClient->y; | 
|---|
| 3974 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 3975 | sCount++; | 
|---|
| 3976 | pswpNew = (PSWP) mp1 + (soldCount + 8 + | 
|---|
| 3977 | (fToolbar != FALSE) + | 
|---|
| 3978 | (fDrivebar != FALSE) + | 
|---|
| 3979 | (fSplitStatus != FALSE) + | 
|---|
| 3980 | (fAutoView != FALSE)); | 
|---|
| 3981 | *pswpNew = *pswpClient; | 
|---|
| 3982 | pswpNew->hwnd = hwndUserlist; | 
|---|
| 3983 | pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2); | 
|---|
| 3984 | pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) - | 
|---|
| 3985 | ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0); | 
|---|
| 3986 | pswpNew->y = pswpClient->y; | 
|---|
| 3987 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 3988 | sCount++; | 
|---|
| 3989 | if (fToolbar) { | 
|---|
| 3990 | pswpNew = (PSWP) mp1 + (soldCount + 9 + | 
|---|
| 3991 | (fToolbar != FALSE) + | 
|---|
| 3992 | (fDrivebar != FALSE) + | 
|---|
| 3993 | (fSplitStatus != FALSE) + | 
|---|
| 3994 | (fAutoView != FALSE)); | 
|---|
| 3995 | *pswpNew = *pswpClient; | 
|---|
| 3996 | pswpNew->hwnd = hwndButtonlist; | 
|---|
| 3997 | pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4; | 
|---|
| 3998 | pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x; | 
|---|
| 3999 | pswpNew->y = pswpClient->y; | 
|---|
| 4000 | pswpNew->cy = pswpClient->cy + (aheight + 5L); | 
|---|
| 4001 | sCount++; | 
|---|
| 4002 | } | 
|---|
| 4003 | else | 
|---|
| 4004 | WinShowWindow(hwndButtonlist, FALSE); | 
|---|
| 4005 | } | 
|---|
| 4006 | else { | 
|---|
| 4007 | WinShowWindow(hwndUserlist, FALSE); | 
|---|
| 4008 | WinShowWindow(hwndDrivelist, FALSE); | 
|---|
| 4009 | WinShowWindow(hwndStatelist, FALSE); | 
|---|
| 4010 | WinShowWindow(hwndButtonlist, FALSE); | 
|---|
| 4011 | WinShowWindow(hwndCmdlist, FALSE); | 
|---|
| 4012 | } | 
|---|
| 4013 | { | 
|---|
| 4014 | PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0; | 
|---|
| 4015 | SHORT x; | 
|---|
| 4016 |  | 
|---|
| 4017 | pswpNew = (PSWP) mp1 + (soldCount + 5 + | 
|---|
| 4018 | (fToolbar != FALSE) + | 
|---|
| 4019 | (fDrivebar != FALSE) + | 
|---|
| 4020 | (fSplitStatus != FALSE) + | 
|---|
| 4021 | (fAutoView != FALSE) + | 
|---|
| 4022 | ((fUserComboBox != FALSE) * 4) + | 
|---|
| 4023 | (fUserComboBox != FALSE && | 
|---|
| 4024 | fToolbar != FALSE)); | 
|---|
| 4025 | pswp = (PSWP) mp1; | 
|---|
| 4026 | for (x = 0; x < soldCount; x++) { | 
|---|
| 4027 | if (!pswpTitlebar && | 
|---|
| 4028 | WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR) | 
|---|
| 4029 | pswpTitlebar = pswp; | 
|---|
| 4030 | else if (!pswpMinbutton && | 
|---|
| 4031 | WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX) | 
|---|
| 4032 | pswpMinbutton = pswp; | 
|---|
| 4033 | if (pswpTitlebar && pswpMinbutton) | 
|---|
| 4034 | break; | 
|---|
| 4035 | pswp++; | 
|---|
| 4036 | } | 
|---|
| 4037 | if (pswpMinbutton && pswpTitlebar) { | 
|---|
| 4038 | *pswpNew = *pswpMinbutton; | 
|---|
| 4039 | pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE); | 
|---|
| 4040 | pswpNew->cy = pswpMinbutton->cy + 3; | 
|---|
| 4041 | pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3); | 
|---|
| 4042 | pswpTitlebar->cx -= (pswpNew->cx - 1); | 
|---|
| 4043 | pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx); | 
|---|
| 4044 | pswpNew->y = pswpMinbutton->y - 1; | 
|---|
| 4045 | sCount++; | 
|---|
| 4046 | } | 
|---|
| 4047 | else | 
|---|
| 4048 | WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE); | 
|---|
| 4049 | } | 
|---|
| 4050 |  | 
|---|
| 4051 | if (fMoreButtons) { | 
|---|
| 4052 |  | 
|---|
| 4053 | LONG lastx; | 
|---|
| 4054 |  | 
|---|
| 4055 | pswpNew = (PSWP) mp1 + (soldCount + 6 + | 
|---|
| 4056 | (fToolbar != FALSE) + | 
|---|
| 4057 | (fDrivebar != FALSE) + | 
|---|
| 4058 | (fSplitStatus != FALSE) + | 
|---|
| 4059 | (fAutoView != FALSE) + | 
|---|
| 4060 | ((fUserComboBox != FALSE) * 4) + | 
|---|
| 4061 | (fUserComboBox != FALSE && | 
|---|
| 4062 | fToolbar != FALSE)); | 
|---|
| 4063 | *pswpNew = *pswpClient; | 
|---|
| 4064 | pswpNew->hwnd = hwndName; | 
|---|
| 4065 | pswpNew->x = swpClient.x + 3; | 
|---|
| 4066 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 4067 | pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3; | 
|---|
| 4068 | lastx = pswpNew->x + pswpNew->cx; | 
|---|
| 4069 | pswpNew->cy = bheight; | 
|---|
| 4070 | pswpClient->y += (bheight + 4); | 
|---|
| 4071 | pswpClient->cy -= (bheight + 4); | 
|---|
| 4072 | sCount++; | 
|---|
| 4073 | pswpNew = (PSWP) mp1 + (soldCount + 7 + | 
|---|
| 4074 | (fToolbar != FALSE) + | 
|---|
| 4075 | (fDrivebar != FALSE) + | 
|---|
| 4076 | (fSplitStatus != FALSE) + | 
|---|
| 4077 | (fAutoView != FALSE) + | 
|---|
| 4078 | ((fUserComboBox != FALSE) * 4) + | 
|---|
| 4079 | (fUserComboBox != FALSE && | 
|---|
| 4080 | fToolbar != FALSE)); | 
|---|
| 4081 | *pswpNew = *pswpClient; | 
|---|
| 4082 | pswpNew->hwnd = hwndDate; | 
|---|
| 4083 | pswpNew->x = lastx + 3; | 
|---|
| 4084 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 4085 | pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3; | 
|---|
| 4086 | lastx = pswpNew->x + pswpNew->cx; | 
|---|
| 4087 | pswpNew->cy = bheight; | 
|---|
| 4088 | sCount++; | 
|---|
| 4089 | pswpNew = (PSWP) mp1 + (soldCount + 8 + | 
|---|
| 4090 | (fToolbar != FALSE) + | 
|---|
| 4091 | (fDrivebar != FALSE) + | 
|---|
| 4092 | (fSplitStatus != FALSE) + | 
|---|
| 4093 | (fAutoView != FALSE) + | 
|---|
| 4094 | ((fUserComboBox != FALSE) * 4) + | 
|---|
| 4095 | (fUserComboBox != FALSE && | 
|---|
| 4096 | fToolbar != FALSE)); | 
|---|
| 4097 | *pswpNew = *pswpClient; | 
|---|
| 4098 | pswpNew->hwnd = hwndAttr; | 
|---|
| 4099 | pswpNew->x = lastx + 3; | 
|---|
| 4100 | pswpNew->y = swpClient.y + (sheight + 6); | 
|---|
| 4101 | pswpNew->cx = (swpClient.cx - pswpNew->x) - 1; | 
|---|
| 4102 | pswpNew->cy = bheight; | 
|---|
| 4103 | sCount++; | 
|---|
| 4104 | } | 
|---|
| 4105 | else { | 
|---|
| 4106 | WinShowWindow(hwndAttr, FALSE); | 
|---|
| 4107 | WinShowWindow(hwndName, FALSE); | 
|---|
| 4108 | WinShowWindow(hwndDate, FALSE); | 
|---|
| 4109 | } | 
|---|
| 4110 | return MRFROMSHORT(sCount); | 
|---|
| 4111 | } | 
|---|
| 4112 |  | 
|---|
| 4113 | case WM_QUERYFRAMECTLCOUNT: | 
|---|
| 4114 | { | 
|---|
| 4115 | SHORT sCount; | 
|---|
| 4116 |  | 
|---|
| 4117 | sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 4118 |  | 
|---|
| 4119 | sCount += 6; | 
|---|
| 4120 | if (fSplitStatus) | 
|---|
| 4121 | sCount++; | 
|---|
| 4122 | if (fToolbar) | 
|---|
| 4123 | sCount++; | 
|---|
| 4124 | if (fUserComboBox) { | 
|---|
| 4125 | sCount += 4; | 
|---|
| 4126 | if (fToolbar) | 
|---|
| 4127 | sCount++; | 
|---|
| 4128 | } | 
|---|
| 4129 | if (fDrivebar) | 
|---|
| 4130 | sCount++; | 
|---|
| 4131 | if (fAutoView) | 
|---|
| 4132 | sCount++; | 
|---|
| 4133 | if (fMoreButtons) | 
|---|
| 4134 | sCount += 3; | 
|---|
| 4135 | return MRFROMSHORT(sCount); | 
|---|
| 4136 | } | 
|---|
| 4137 |  | 
|---|
| 4138 | case WM_CLOSE: | 
|---|
| 4139 | WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2); | 
|---|
| 4140 | return 0; | 
|---|
| 4141 | } | 
|---|
| 4142 | return oldproc(hwnd, msg, mp1, mp2); | 
|---|
| 4143 | } | 
|---|
| 4144 |  | 
|---|
| 4145 | MRESULT EXPENTRY MainWMCommand(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 4146 | { | 
|---|
| 4147 | SetShiftState(); | 
|---|
| 4148 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 4149 |  | 
|---|
| 4150 | case IDM_CONTEXTMENU: | 
|---|
| 4151 | { | 
|---|
| 4152 | HWND hwnd = WinQueryFocus(HWND_DESKTOP); | 
|---|
| 4153 | // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd); | 
|---|
| 4154 | if (hwnd != NULLHANDLE) { | 
|---|
| 4155 | HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT); | 
|---|
| 4156 | USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID); | 
|---|
| 4157 | switch (id) { | 
|---|
| 4158 | case MAIN_SETUPLIST: | 
|---|
| 4159 | case MAIN_USERLIST: | 
|---|
| 4160 | case MAIN_CMDLIST: | 
|---|
| 4161 | // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU"); | 
|---|
| 4162 | WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0); | 
|---|
| 4163 | } | 
|---|
| 4164 | } | 
|---|
| 4165 | } | 
|---|
| 4166 | break; | 
|---|
| 4167 |  | 
|---|
| 4168 | case IDM_SETTARGET: | 
|---|
| 4169 | SetTargetDir(hwnd, FALSE); | 
|---|
| 4170 | break; | 
|---|
| 4171 |  | 
|---|
| 4172 | case IDM_TOAUTOMLE: | 
|---|
| 4173 | if (fComments && fAutoView) | 
|---|
| 4174 | WinSetFocus(HWND_DESKTOP, hwndAutoMLE); | 
|---|
| 4175 | break; | 
|---|
| 4176 |  | 
|---|
| 4177 | case IDM_HIDENOTEWND: | 
|---|
| 4178 | HideNote(); | 
|---|
| 4179 | break; | 
|---|
| 4180 | case IDM_SHOWNOTEWND: | 
|---|
| 4181 | ShowNote(); | 
|---|
| 4182 | break; | 
|---|
| 4183 |  | 
|---|
| 4184 | case IDM_COMPARE: | 
|---|
| 4185 | { | 
|---|
| 4186 | WALK2 wa; | 
|---|
| 4187 | PCNRITEM pci; | 
|---|
| 4188 |  | 
|---|
| 4189 | memset(&wa, 0, sizeof(wa)); | 
|---|
| 4190 | wa.size = sizeof(wa); | 
|---|
| 4191 | pci = | 
|---|
| 4192 | (PCNRITEM) | 
|---|
| 4193 | WinSendMsg(WinWindowFromID | 
|---|
| 4194 | (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR), | 
|---|
| 4195 | CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST), | 
|---|
| 4196 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 4197 | if (pci && (INT) pci != -1) { | 
|---|
| 4198 | strcpy(wa.szCurrentPath1, pci->pszFileName); | 
|---|
| 4199 | MakeValidDir(wa.szCurrentPath1); | 
|---|
| 4200 | } | 
|---|
| 4201 | else | 
|---|
| 4202 | save_dir2(wa.szCurrentPath1); | 
|---|
| 4203 | TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2); | 
|---|
| 4204 | if (!*wa.szCurrentPath2) | 
|---|
| 4205 | strcpy(wa.szCurrentPath2, wa.szCurrentPath1); | 
|---|
| 4206 | MakeValidDir(wa.szCurrentPath2); | 
|---|
| 4207 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 4208 | hwnd, | 
|---|
| 4209 | WalkTwoCmpDlgProc, | 
|---|
| 4210 | FM3ModHandle, | 
|---|
| 4211 | WALK2_FRAME, | 
|---|
| 4212 | MPFROMP(&wa)) && | 
|---|
| 4213 | !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) { | 
|---|
| 4214 | if (!*dircompare) { | 
|---|
| 4215 |  | 
|---|
| 4216 | COMPARE *cmp; | 
|---|
| 4217 |  | 
|---|
| 4218 | cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__); | 
|---|
| 4219 | if (cmp) { | 
|---|
| 4220 | cmp->size = sizeof(COMPARE); | 
|---|
| 4221 | strcpy(cmp->leftdir, wa.szCurrentPath1); | 
|---|
| 4222 | strcpy(cmp->rightdir, wa.szCurrentPath2); | 
|---|
| 4223 | cmp->hwndParent = hwnd; | 
|---|
| 4224 | cmp->dcd.hwndParent = hwnd; | 
|---|
| 4225 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 4226 | HWND_DESKTOP, | 
|---|
| 4227 | CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp)); | 
|---|
| 4228 | } | 
|---|
| 4229 | } | 
|---|
| 4230 | else { | 
|---|
| 4231 |  | 
|---|
| 4232 | CHAR szPath1[CCHMAXPATH]; | 
|---|
| 4233 | CHAR szPath2[CCHMAXPATH]; | 
|---|
| 4234 | runemf2(SEPARATE, | 
|---|
| 4235 | HWND_DESKTOP, NULL, NULL, | 
|---|
| 4236 | "%s %s %s", | 
|---|
| 4237 | dircompare, | 
|---|
| 4238 | BldQuotedFileName(szPath1, wa.szCurrentPath1), | 
|---|
| 4239 | BldQuotedFileName(szPath2, wa.szCurrentPath2)); | 
|---|
| 4240 | // CHAR d1[] = "\""; | 
|---|
| 4241 | // CHAR d2[] = "\""; | 
|---|
| 4242 | // if (!needs_quoting(wa.szCurrentPath1)) | 
|---|
| 4243 | //   *d1 = 0; | 
|---|
| 4244 | // if (!needs_quoting(wa.szCurrentPath2)) | 
|---|
| 4245 | //   *d2 = 0; | 
|---|
| 4246 | // runemf2(SEPARATE, | 
|---|
| 4247 | //      HWND_DESKTOP, NULL, NULL, | 
|---|
| 4248 | //      "%s %s%s%s %s%s%s", | 
|---|
| 4249 | //      dircompare, | 
|---|
| 4250 | //      d1, wa.szCurrentPath1, d1, d2, wa.szCurrentPath2, d2); | 
|---|
| 4251 | } | 
|---|
| 4252 | } | 
|---|
| 4253 | } | 
|---|
| 4254 | break; | 
|---|
| 4255 |  | 
|---|
| 4256 | case IDM_EXIT: | 
|---|
| 4257 | case IDM_KILLME: | 
|---|
| 4258 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 4259 | break; | 
|---|
| 4260 |  | 
|---|
| 4261 | case IDM_CLI: | 
|---|
| 4262 | if (fSplitStatus && | 
|---|
| 4263 | hwndStatus2 && | 
|---|
| 4264 | !WinIsWindow(WinQueryAnchorBlock(hwnd), | 
|---|
| 4265 | WinWindowFromID(hwndStatus2, COMMAND_LINE))) | 
|---|
| 4266 | PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID); | 
|---|
| 4267 | break; | 
|---|
| 4268 |  | 
|---|
| 4269 | case IDM_ADDTOUSERLIST: | 
|---|
| 4270 | case IDM_DELETEFROMUSERLIST: | 
|---|
| 4271 | { | 
|---|
| 4272 | CHAR temp[CCHMAXPATH], path[CCHMAXPATH]; | 
|---|
| 4273 |  | 
|---|
| 4274 | *temp = 0; | 
|---|
| 4275 | WinQueryWindowText(hwndUserlist, CCHMAXPATH, temp); | 
|---|
| 4276 | bstrip(temp); | 
|---|
| 4277 | if (*temp && | 
|---|
| 4278 | !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) { | 
|---|
| 4279 | if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) { | 
|---|
| 4280 | add_udir(TRUE, path); | 
|---|
| 4281 | if (fUdirsChanged) | 
|---|
| 4282 | save_udirs(); | 
|---|
| 4283 | WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); | 
|---|
| 4284 | } | 
|---|
| 4285 | else { | 
|---|
| 4286 | if (!remove_udir(path)) | 
|---|
| 4287 | Runtime_Error(pszSrcFile, __LINE__, "remove_udir"); | 
|---|
| 4288 | else { | 
|---|
| 4289 | if (fUdirsChanged) | 
|---|
| 4290 | save_udirs(); | 
|---|
| 4291 | WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); | 
|---|
| 4292 | } | 
|---|
| 4293 | } | 
|---|
| 4294 | } | 
|---|
| 4295 | } | 
|---|
| 4296 | break; | 
|---|
| 4297 |  | 
|---|
| 4298 | case IDM_SAVEDIRCNRSTATE: | 
|---|
| 4299 | case IDM_DELETEDIRCNRSTATE: | 
|---|
| 4300 | { | 
|---|
| 4301 | CHAR szStateName[STATE_NAME_MAX_BYTES + 1]; | 
|---|
| 4302 |  | 
|---|
| 4303 | *szStateName = 0; | 
|---|
| 4304 | WinQueryWindowText(hwndStatelist, STATE_NAME_MAX_BYTES, szStateName); | 
|---|
| 4305 | bstrip(szStateName); | 
|---|
| 4306 | // Ignore request if blank or attempting to using illegal name | 
|---|
| 4307 | if (*szStateName && stricmp(szStateName, GetPString(IDS_STATETEXT))) { | 
|---|
| 4308 | if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) { | 
|---|
| 4309 | // Save | 
|---|
| 4310 | INT nSaved = SaveDirCnrState(hwnd, szStateName); | 
|---|
| 4311 | if (nSaved > 0) { | 
|---|
| 4312 | INT ret = add_setup(szStateName); | 
|---|
| 4313 | if (ret == 0) { | 
|---|
| 4314 | WinSendMsg(hwndStatelist, LM_INSERTITEM, | 
|---|
| 4315 | MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName)); | 
|---|
| 4316 | save_setups(); | 
|---|
| 4317 | } | 
|---|
| 4318 | else if (ret != 1) { | 
|---|
| 4319 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, | 
|---|
| 4320 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 4321 | "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed | 
|---|
| 4322 | WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT)); | 
|---|
| 4323 | } | 
|---|
| 4324 | } | 
|---|
| 4325 | else { | 
|---|
| 4326 | saymsg(MB_ENTER | MB_ICONASTERISK, | 
|---|
| 4327 | hwnd, | 
|---|
| 4328 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 4329 | nSaved == 0 ? | 
|---|
| 4330 | "Nothing to save" : | 
|---|
| 4331 | "State data save failed"); | 
|---|
| 4332 | WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT)); | 
|---|
| 4333 | } | 
|---|
| 4334 | } | 
|---|
| 4335 | else { | 
|---|
| 4336 | // Delete | 
|---|
| 4337 | ULONG numsaves = 0, size, x; | 
|---|
| 4338 | CHAR s[STATE_NAME_MAX_BYTES + 80]; | 
|---|
| 4339 |  | 
|---|
| 4340 | INT ret = remove_setup(szStateName); | 
|---|
| 4341 | if (ret == 1) | 
|---|
| 4342 | save_setups(); | 
|---|
| 4343 | sprintf(s, "%s.NumDirsLastTime", szStateName); | 
|---|
| 4344 | size = sizeof(ULONG); | 
|---|
| 4345 | if (!PrfQueryProfileData(fmprof, | 
|---|
| 4346 | FM3Str, | 
|---|
| 4347 | s, | 
|---|
| 4348 | (PVOID)&numsaves, | 
|---|
| 4349 | &size)) { | 
|---|
| 4350 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, | 
|---|
| 4351 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 4352 | GetPString(IDS_DOESNTEXISTTEXT), szStateName); | 
|---|
| 4353 | } | 
|---|
| 4354 | else if (!size) | 
|---|
| 4355 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); | 
|---|
| 4356 | else { | 
|---|
| 4357 | PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L); | 
|---|
| 4358 | for (x = 0; x < numsaves; x++) { | 
|---|
| 4359 | sprintf(s, "%s.DirCnrPos.%lu", szStateName, x); | 
|---|
| 4360 | PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); | 
|---|
| 4361 | sprintf(s, "%s.DirCnrDir.%lu", szStateName, x); | 
|---|
| 4362 | PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); | 
|---|
| 4363 | sprintf(s, "%s.DirCnrSort.%lu", szStateName, x); | 
|---|
| 4364 | PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); | 
|---|
| 4365 | sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x); | 
|---|
| 4366 | PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); | 
|---|
| 4367 | sprintf(s, "%s.DirCnrView.%lu", szStateName, x); | 
|---|
| 4368 | PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); | 
|---|
| 4369 | } | 
|---|
| 4370 | sprintf(s, "%s.LastTreePos", szStateName); | 
|---|
| 4371 | PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); | 
|---|
| 4372 | sprintf(s, "%s.MySizeLastTime", szStateName); | 
|---|
| 4373 | PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0); | 
|---|
| 4374 | } | 
|---|
| 4375 | PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID); | 
|---|
| 4376 | } | 
|---|
| 4377 | } | 
|---|
| 4378 | } | 
|---|
| 4379 | break; | 
|---|
| 4380 |  | 
|---|
| 4381 | case IDM_IDEALSIZE: | 
|---|
| 4382 | { | 
|---|
| 4383 | SWP swp, swpD; | 
|---|
| 4384 | ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L; | 
|---|
| 4385 | ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER); | 
|---|
| 4386 |  | 
|---|
| 4387 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); | 
|---|
| 4388 | if (swp.fl & SWP_MAXIMIZE) { | 
|---|
| 4389 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND, | 
|---|
| 4390 | MPFROM2SHORT(SC_RESTORE, 0), MPVOID); | 
|---|
| 4391 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); | 
|---|
| 4392 | } | 
|---|
| 4393 | WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD); | 
|---|
| 4394 | swpD.x += bsz; | 
|---|
| 4395 | swpD.cx -= (bsz * 2); | 
|---|
| 4396 | swpD.y += icz; | 
|---|
| 4397 | swpD.cy -= (icz + bsz); | 
|---|
| 4398 | if (swp.x == swpD.x && swp.y == swpD.y && | 
|---|
| 4399 | swp.cx == swpD.cx && swp.cy == swpD.cy && | 
|---|
| 4400 | // fixme to be #defined someday | 
|---|
| 4401 | WinQueryWindowUShort(hwnd, QWL_USER + 10) && | 
|---|
| 4402 | WinQueryWindowUShort(hwnd, QWL_USER + 14)) { | 
|---|
| 4403 | swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8); | 
|---|
| 4404 | swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10); | 
|---|
| 4405 | swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12); | 
|---|
| 4406 | swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14); | 
|---|
| 4407 | } | 
|---|
| 4408 | else { | 
|---|
| 4409 | WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x); | 
|---|
| 4410 | WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx); | 
|---|
| 4411 | WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y); | 
|---|
| 4412 | WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy); | 
|---|
| 4413 | } | 
|---|
| 4414 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, | 
|---|
| 4415 | swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE); | 
|---|
| 4416 | } | 
|---|
| 4417 | break; | 
|---|
| 4418 |  | 
|---|
| 4419 | case IDM_BLINK: | 
|---|
| 4420 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0, | 
|---|
| 4421 | SWP_MINIMIZE); | 
|---|
| 4422 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0, | 
|---|
| 4423 | SWP_RESTORE | SWP_ZORDER); | 
|---|
| 4424 | break; | 
|---|
| 4425 |  | 
|---|
| 4426 | case DID_CANCEL: | 
|---|
| 4427 | { | 
|---|
| 4428 | HWND hwndTop = TopWindow(hwndMain, (HWND) 0); | 
|---|
| 4429 |  | 
|---|
| 4430 | if (hwndTop) | 
|---|
| 4431 | WinSetFocus(HWND_DESKTOP, hwndTop); | 
|---|
| 4432 | } | 
|---|
| 4433 | break; | 
|---|
| 4434 |  | 
|---|
| 4435 | case IDM_NOTEBOOK: | 
|---|
| 4436 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 4437 | hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPVOID); | 
|---|
| 4438 | break; | 
|---|
| 4439 |  | 
|---|
| 4440 | case IDM_VIEWHELPS: | 
|---|
| 4441 | case IDM_VIEWINFS: | 
|---|
| 4442 | WinDlgBox(HWND_DESKTOP, | 
|---|
| 4443 | HWND_DESKTOP, | 
|---|
| 4444 | ViewInfProc, | 
|---|
| 4445 | FM3ModHandle, | 
|---|
| 4446 | VINF_FRAME, | 
|---|
| 4447 | ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ? | 
|---|
| 4448 | MPFROMP(NullStr) : MPVOID)); | 
|---|
| 4449 | break; | 
|---|
| 4450 |  | 
|---|
| 4451 | case IDM_OPENWALK: | 
|---|
| 4452 | { | 
|---|
| 4453 | char newpath[CCHMAXPATH]; | 
|---|
| 4454 |  | 
|---|
| 4455 | *newpath = 0; | 
|---|
| 4456 | TopWindowName(hwnd, (HWND) 0, newpath); | 
|---|
| 4457 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 4458 | hwnd, | 
|---|
| 4459 | WalkAllDlgProc, | 
|---|
| 4460 | FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath) | 
|---|
| 4461 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath); | 
|---|
| 4462 | } | 
|---|
| 4463 | break; | 
|---|
| 4464 |  | 
|---|
| 4465 | case IDM_WINDOWDLG: | 
|---|
| 4466 | WindowList(hwnd); | 
|---|
| 4467 | break; | 
|---|
| 4468 |  | 
|---|
| 4469 | case IDM_HELPMOUSE: | 
|---|
| 4470 | case IDM_HELPCONTEXT: | 
|---|
| 4471 | case IDM_HELPHINTS: | 
|---|
| 4472 | case IDM_HELPPIX: | 
|---|
| 4473 | case IDM_HELPTUTOR: | 
|---|
| 4474 | case IDM_HELPUSERLIST: | 
|---|
| 4475 | case IDM_HELP: | 
|---|
| 4476 | case IDM_HELPCONTENTS: | 
|---|
| 4477 | case IDM_HELPKEYS: | 
|---|
| 4478 | case IDM_HELPGENERAL: | 
|---|
| 4479 | if (hwndHelp) { | 
|---|
| 4480 | if (SHORT1FROMMP(mp2) == CMDSRC_MENU) { | 
|---|
| 4481 |  | 
|---|
| 4482 | RECTL rcl; | 
|---|
| 4483 | ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L; | 
|---|
| 4484 |  | 
|---|
| 4485 | WinQueryWindowRect(HWND_DESKTOP, &rcl); | 
|---|
| 4486 | rcl.yBottom += icz; | 
|---|
| 4487 | rcl.yTop -= icz; | 
|---|
| 4488 | rcl.xLeft += icz; | 
|---|
| 4489 | rcl.xRight -= icz; | 
|---|
| 4490 | WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID); | 
|---|
| 4491 | } | 
|---|
| 4492 | else { | 
|---|
| 4493 |  | 
|---|
| 4494 | RECTL rcl; | 
|---|
| 4495 |  | 
|---|
| 4496 | WinQueryWindowRect(HWND_DESKTOP, &rcl); | 
|---|
| 4497 | rcl.yBottom += 8; | 
|---|
| 4498 | rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7); | 
|---|
| 4499 | rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7); | 
|---|
| 4500 | rcl.xRight -= 8; | 
|---|
| 4501 | WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID); | 
|---|
| 4502 | } | 
|---|
| 4503 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 4504 | case IDM_HELPCONTEXT: | 
|---|
| 4505 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 4506 | MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4507 | break; | 
|---|
| 4508 |  | 
|---|
| 4509 | case IDM_HELPMOUSE: | 
|---|
| 4510 | if (hwndHelp) | 
|---|
| 4511 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 4512 | MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4513 | break; | 
|---|
| 4514 |  | 
|---|
| 4515 | case IDM_HELPPIX: | 
|---|
| 4516 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 4517 | MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4518 | break; | 
|---|
| 4519 |  | 
|---|
| 4520 | case IDM_HELPTUTOR: | 
|---|
| 4521 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 4522 | MPFROM2SHORT(HELP_TUTORIAL, 0), | 
|---|
| 4523 | MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4524 | break; | 
|---|
| 4525 |  | 
|---|
| 4526 | case IDM_HELPHINTS: | 
|---|
| 4527 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 4528 | MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4529 | break; | 
|---|
| 4530 |  | 
|---|
| 4531 | case IDM_HELPGENERAL: | 
|---|
| 4532 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 4533 | MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4534 | break; | 
|---|
| 4535 | case IDM_HELPKEYS: | 
|---|
| 4536 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 4537 | MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4538 | break; | 
|---|
| 4539 |  | 
|---|
| 4540 | case IDM_HELP: | 
|---|
| 4541 | case IDM_HELPCONTENTS: | 
|---|
| 4542 | WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID); | 
|---|
| 4543 | break; | 
|---|
| 4544 |  | 
|---|
| 4545 | case IDM_HELPUSERLIST: | 
|---|
| 4546 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 4547 | MPFROM2SHORT(HELP_USERLISTS, 0), | 
|---|
| 4548 | MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 4549 | break; | 
|---|
| 4550 | } | 
|---|
| 4551 | } | 
|---|
| 4552 | break; | 
|---|
| 4553 |  | 
|---|
| 4554 | case IDM_EDITANYARCHIVER: | 
|---|
| 4555 | EditArchiverDefinition(hwnd); | 
|---|
| 4556 | break; | 
|---|
| 4557 |  | 
|---|
| 4558 | case IDM_ABOUT: | 
|---|
| 4559 | WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle, | 
|---|
| 4560 | ABT_FRAME, MPVOID); | 
|---|
| 4561 | break; | 
|---|
| 4562 |  | 
|---|
| 4563 | case IDM_FONTPALETTE: | 
|---|
| 4564 | OpenObject("<WP_FNTPAL>", Default, hwnd); | 
|---|
| 4565 | break; | 
|---|
| 4566 |  | 
|---|
| 4567 | case IDM_HICOLORPALETTE: | 
|---|
| 4568 | case IDM_COLORPALETTE: | 
|---|
| 4569 | { | 
|---|
| 4570 | CHAR *palette = "<WP_CLRPAL>"; | 
|---|
| 4571 | ULONG version[2]; | 
|---|
| 4572 |  | 
|---|
| 4573 | if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, | 
|---|
| 4574 | (PVOID) & version, (ULONG) sizeof(version))) { | 
|---|
| 4575 | if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) { | 
|---|
| 4576 | if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE) | 
|---|
| 4577 | palette = "<WP_HIRESCLRPAL>"; | 
|---|
| 4578 | else | 
|---|
| 4579 | palette = "<WP_LORESCLRPAL>"; | 
|---|
| 4580 | } | 
|---|
| 4581 | } | 
|---|
| 4582 | OpenObject(palette, Default, hwnd); | 
|---|
| 4583 | } | 
|---|
| 4584 | break; | 
|---|
| 4585 |  | 
|---|
| 4586 | case IDM_SYSTEMSETUP: | 
|---|
| 4587 | OpenObject("<WP_CONFIG>", Default, hwnd); | 
|---|
| 4588 | break; | 
|---|
| 4589 |  | 
|---|
| 4590 | case IDM_SCHEMEPALETTE: | 
|---|
| 4591 | { | 
|---|
| 4592 | HOBJECT hWPSObject; | 
|---|
| 4593 |  | 
|---|
| 4594 | hWPSObject = WinQueryObject("<WP_SCHPAL>"); | 
|---|
| 4595 | if (hWPSObject != NULLHANDLE) | 
|---|
| 4596 | WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter," | 
|---|
| 4597 | "Spring:PM_Spring,Summer:PM_Summer," | 
|---|
| 4598 | "System:PM_System,Windows:PM_Windows;" | 
|---|
| 4599 | "OPEN=DEFAULT"); | 
|---|
| 4600 | } | 
|---|
| 4601 | break; | 
|---|
| 4602 |  | 
|---|
| 4603 | case IDM_SYSTEMCLOCK: | 
|---|
| 4604 | OpenObject("<WP_CLOCK>", Default, hwnd); | 
|---|
| 4605 | break; | 
|---|
| 4606 |  | 
|---|
| 4607 | #ifdef NEVER | 
|---|
| 4608 | case IDM_SYSINFO: | 
|---|
| 4609 | WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle, | 
|---|
| 4610 | SYS_FRAME, NULL); | 
|---|
| 4611 | break; | 
|---|
| 4612 | #endif | 
|---|
| 4613 |  | 
|---|
| 4614 | case IDM_INSTANT: | 
|---|
| 4615 | { | 
|---|
| 4616 | CHAR path[CCHMAXPATH]; | 
|---|
| 4617 | PCNRITEM pci = (PCNRITEM) 0; | 
|---|
| 4618 |  | 
|---|
| 4619 | if (hwndTree) | 
|---|
| 4620 | pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS, | 
|---|
| 4621 | MPFROMLONG(CMA_FIRST), | 
|---|
| 4622 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 4623 | if (pci && (INT) pci != -1) { | 
|---|
| 4624 | strcpy(path, pci->pszFileName); | 
|---|
| 4625 | MakeValidDir(path); | 
|---|
| 4626 | } | 
|---|
| 4627 | else | 
|---|
| 4628 | save_dir2(path); | 
|---|
| 4629 | WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle, | 
|---|
| 4630 | BAT_FRAME, MPFROMP(path)); | 
|---|
| 4631 | } | 
|---|
| 4632 | break; | 
|---|
| 4633 |  | 
|---|
| 4634 | case IDM_WINFULLSCREEN: | 
|---|
| 4635 | case IDM_DOSCOMMANDLINE: | 
|---|
| 4636 | case IDM_COMMANDLINE: | 
|---|
| 4637 | { | 
|---|
| 4638 | CHAR *env = GetCmdSpec(FALSE), path[CCHMAXPATH]; | 
|---|
| 4639 | INT type = SEPARATE | WINDOWED; | 
|---|
| 4640 |  | 
|---|
| 4641 | *path = 0; | 
|---|
| 4642 | TopWindowName(hwnd, (HWND) 0, path); | 
|---|
| 4643 | if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE) | 
|---|
| 4644 | env = GetCmdSpec(TRUE); | 
|---|
| 4645 | else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) { | 
|---|
| 4646 | env = "WINOS2.COM"; | 
|---|
| 4647 | type = SEPARATE | FULLSCREEN; | 
|---|
| 4648 | } | 
|---|
| 4649 | runemf2(type, hwnd, path, NULL, "%s", env); | 
|---|
| 4650 | } | 
|---|
| 4651 | break; | 
|---|
| 4652 |  | 
|---|
| 4653 | case IDM_KILLPROC: | 
|---|
| 4654 | WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle, | 
|---|
| 4655 | KILL_FRAME, NULL); | 
|---|
| 4656 | break; | 
|---|
| 4657 |  | 
|---|
| 4658 | case IDM_AUTOVIEWCOMMENTS: | 
|---|
| 4659 | case IDM_AUTOVIEWFILE: | 
|---|
| 4660 | if (SHORT1FROMMP(mp1) == IDM_AUTOVIEWFILE) | 
|---|
| 4661 | fComments = FALSE; | 
|---|
| 4662 | else | 
|---|
| 4663 | fComments = TRUE; | 
|---|
| 4664 | PrfWriteProfileData(fmprof, FM3Str, "Comments", &fComments, sizeof(BOOL)); | 
|---|
| 4665 | WinSetWindowText((fComments) ? hwndAutoview : hwndAutoMLE, NullStr); | 
|---|
| 4666 | goto AutoChange; | 
|---|
| 4667 |  | 
|---|
| 4668 | case IDM_AUTOVIEW: | 
|---|
| 4669 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), | 
|---|
| 4670 | &fAutoView, TRUE, "AutoView"); | 
|---|
| 4671 | AutoChange: | 
|---|
| 4672 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, | 
|---|
| 4673 | MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 4674 | if (fAutoView) { | 
|---|
| 4675 |  | 
|---|
| 4676 | CHAR s[CCHMAXPATH]; | 
|---|
| 4677 | HWND hwndDir; | 
|---|
| 4678 | PCNRITEM pci; | 
|---|
| 4679 |  | 
|---|
| 4680 | hwndDir = TopWindowName(hwnd, (HWND) 0, s); | 
|---|
| 4681 | if (hwndDir) { | 
|---|
| 4682 | hwndDir = WinWindowFromID(hwndDir, FID_CLIENT); | 
|---|
| 4683 | if (hwndDir) { | 
|---|
| 4684 | hwndDir = WinWindowFromID(hwndDir, DIR_CNR); | 
|---|
| 4685 | if (hwndDir) { | 
|---|
| 4686 | pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS, | 
|---|
| 4687 | MPFROMLONG(CMA_FIRST), | 
|---|
| 4688 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 4689 | if (pci && (INT) pci != -1 && | 
|---|
| 4690 | (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW))) | 
|---|
| 4691 | WinSendMsg(hwnd, | 
|---|
| 4692 | UM_LOADFILE, | 
|---|
| 4693 | MPFROMP(pci->pszFileName), | 
|---|
| 4694 | (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ? | 
|---|
| 4695 | MPVOID : MPFROMLONG(1)); | 
|---|
| 4696 | } | 
|---|
| 4697 | } | 
|---|
| 4698 | } | 
|---|
| 4699 | } | 
|---|
| 4700 | break; | 
|---|
| 4701 |  | 
|---|
| 4702 | case IDM_TEXTTOOLS: | 
|---|
| 4703 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), | 
|---|
| 4704 | &fTextTools, TRUE, "TextTools"); | 
|---|
| 4705 | BuildTools(hwndToolback, TRUE); | 
|---|
| 4706 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, | 
|---|
| 4707 | MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 4708 | break; | 
|---|
| 4709 |  | 
|---|
| 4710 | case IDM_TOOLTITLES: | 
|---|
| 4711 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), | 
|---|
| 4712 | &fToolTitles, TRUE, "ToolTitles"); | 
|---|
| 4713 | BuildTools(hwndToolback, TRUE); | 
|---|
| 4714 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, | 
|---|
| 4715 | MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 4716 | break; | 
|---|
| 4717 |  | 
|---|
| 4718 | case IDM_HIDEMENU: | 
|---|
| 4719 | { | 
|---|
| 4720 | HWND hwndMenu; | 
|---|
| 4721 |  | 
|---|
| 4722 | hwndMenu = WinQueryWindowULong(hwnd, QWL_USER); | 
|---|
| 4723 | MenuInvisible = (MenuInvisible) ? FALSE : TRUE; | 
|---|
| 4724 | if (MenuInvisible) { | 
|---|
| 4725 | WinSetParent(hwndMenu, HWND_OBJECT, FALSE); | 
|---|
| 4726 | WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4727 | FID_SYSMENU), IDM_HIDEMENU, | 
|---|
| 4728 | GetPString(IDS_UNHIDEMENUTEXT)); | 
|---|
| 4729 | } | 
|---|
| 4730 | else { | 
|---|
| 4731 | WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE); | 
|---|
| 4732 | WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4733 | FID_SYSMENU), IDM_HIDEMENU, | 
|---|
| 4734 | GetPString(IDS_HIDEMENUTEXT)); | 
|---|
| 4735 | } | 
|---|
| 4736 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME, | 
|---|
| 4737 | MPFROMLONG(FCF_MENU), MPVOID); | 
|---|
| 4738 | PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible", | 
|---|
| 4739 | &MenuInvisible, sizeof(BOOL)); | 
|---|
| 4740 | } | 
|---|
| 4741 | break; | 
|---|
| 4742 |  | 
|---|
| 4743 | case IDM_SEEALL: | 
|---|
| 4744 | case IDM_GREP: | 
|---|
| 4745 | case IDM_COLLECTOR: | 
|---|
| 4746 | { | 
|---|
| 4747 | HWND hwndC; | 
|---|
| 4748 | SWP swp; | 
|---|
| 4749 | BOOL already = FALSE; | 
|---|
| 4750 |  | 
|---|
| 4751 | if (Collector) | 
|---|
| 4752 | already = TRUE; | 
|---|
| 4753 | if (!already && !fAutoTile && !fExternalCollector) | 
|---|
| 4754 | GetNextWindowPos(hwnd, &swp, NULL, NULL); | 
|---|
| 4755 | hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4); | 
|---|
| 4756 | if (hwndC) { | 
|---|
| 4757 | if (!already && !fAutoTile && !fExternalCollector) | 
|---|
| 4758 | WinSetWindowPos(hwndC, HWND_TOP, | 
|---|
| 4759 | swp.x, swp.y, swp.cx, swp.cy, | 
|---|
| 4760 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER); | 
|---|
| 4761 | else if (fAutoTile && !already) | 
|---|
| 4762 | TileChildren(hwnd, TRUE); | 
|---|
| 4763 | WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | | 
|---|
| 4764 | SWP_ACTIVATE); | 
|---|
| 4765 | if (SHORT1FROMMP(mp1) == IDM_GREP) | 
|---|
| 4766 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND, | 
|---|
| 4767 | MPFROM2SHORT(IDM_GREP, 0), MPVOID); | 
|---|
| 4768 | if (SHORT1FROMMP(mp1) == IDM_SEEALL) | 
|---|
| 4769 | PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND, | 
|---|
| 4770 | MPFROM2SHORT(IDM_SEEALL, 0), MPVOID); | 
|---|
| 4771 | } | 
|---|
| 4772 | } | 
|---|
| 4773 | break; | 
|---|
| 4774 |  | 
|---|
| 4775 | case IDM_TOOLLEFT: | 
|---|
| 4776 | case IDM_TOOLRIGHT: | 
|---|
| 4777 | { | 
|---|
| 4778 | TOOL *tool; | 
|---|
| 4779 |  | 
|---|
| 4780 | if (!toolhead || !toolhead->next) { | 
|---|
| 4781 | firsttool = (toolhead) ? toolhead->id : 0; | 
|---|
| 4782 | break; | 
|---|
| 4783 | } | 
|---|
| 4784 | tool = find_tool(firsttool); | 
|---|
| 4785 | if (!tool) | 
|---|
| 4786 | tool = toolhead; | 
|---|
| 4787 | if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) { | 
|---|
| 4788 | tool = prev_tool(tool, TRUE); | 
|---|
| 4789 | firsttool = tool->id; | 
|---|
| 4790 | } | 
|---|
| 4791 | else { | 
|---|
| 4792 | tool = next_tool(tool, TRUE); | 
|---|
| 4793 | firsttool = tool->id; | 
|---|
| 4794 | } | 
|---|
| 4795 | ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4796 | MAIN_TOOLS)); | 
|---|
| 4797 | } | 
|---|
| 4798 | break; | 
|---|
| 4799 |  | 
|---|
| 4800 | case IDM_CREATETOOL: | 
|---|
| 4801 | BuildTools(hwndToolback, TRUE); | 
|---|
| 4802 | break; | 
|---|
| 4803 |  | 
|---|
| 4804 | case IDM_TOOLBAR: | 
|---|
| 4805 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 4806 | IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar"); | 
|---|
| 4807 | BuildTools(hwndToolback, TRUE); | 
|---|
| 4808 | WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4809 | MAIN_TOOLS), fToolbar); | 
|---|
| 4810 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4811 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 4812 | if (fDrivebar) | 
|---|
| 4813 | WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4814 | MAIN_DRIVES), NULL, TRUE); | 
|---|
| 4815 | break; | 
|---|
| 4816 |  | 
|---|
| 4817 | case IDM_DRIVEBAR: | 
|---|
| 4818 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 4819 | IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar"); | 
|---|
| 4820 | WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4821 | MAIN_DRIVES), fDrivebar); | 
|---|
| 4822 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4823 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 4824 | PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID); | 
|---|
| 4825 | break; | 
|---|
| 4826 |  | 
|---|
| 4827 | case IDM_USERLIST: | 
|---|
| 4828 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 4829 | SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox"); | 
|---|
| 4830 | WinShowWindow(hwndUserlist, fUserComboBox); | 
|---|
| 4831 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4832 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 4833 | PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); | 
|---|
| 4834 | PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID); | 
|---|
| 4835 | PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID); | 
|---|
| 4836 | PostMsg(hwnd, UM_FILLBUTTONLIST, MPVOID, MPVOID); | 
|---|
| 4837 | break; | 
|---|
| 4838 |  | 
|---|
| 4839 | case IDM_MOREBUTTONS: | 
|---|
| 4840 | WinSetWindowText(hwndName, NullStr); | 
|---|
| 4841 | WinSetWindowText(hwndDate, NullStr); | 
|---|
| 4842 | WinSetWindowText(hwndAttr, NullStr); | 
|---|
| 4843 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 4844 | SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons"); | 
|---|
| 4845 | if (fMoreButtons) { | 
|---|
| 4846 |  | 
|---|
| 4847 | HWND hwndTemp; | 
|---|
| 4848 |  | 
|---|
| 4849 | hwndTemp = TopWindow(hwnd, (HWND) 0); | 
|---|
| 4850 |  | 
|---|
| 4851 | if (hwndTemp) { | 
|---|
| 4852 | WinSetFocus(HWND_DESKTOP, hwnd); | 
|---|
| 4853 | WinSetFocus(HWND_DESKTOP, hwndTemp); | 
|---|
| 4854 | } | 
|---|
| 4855 | } | 
|---|
| 4856 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 4857 | WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID); | 
|---|
| 4858 | break; | 
|---|
| 4859 |  | 
|---|
| 4860 | case IDM_FREETREE: | 
|---|
| 4861 | if (fFreeTree) { | 
|---|
| 4862 |  | 
|---|
| 4863 | SWP swp, swpT; | 
|---|
| 4864 |  | 
|---|
| 4865 | WinQueryWindowPos(hwndTree, &swpT); | 
|---|
| 4866 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 4867 | WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0, | 
|---|
| 4868 | SWP_MOVE); | 
|---|
| 4869 | } | 
|---|
| 4870 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1), | 
|---|
| 4871 | &fFreeTree, TRUE, "FreeTree"); | 
|---|
| 4872 | if (fAutoTile) | 
|---|
| 4873 | TileChildren(hwnd, TRUE); | 
|---|
| 4874 | break; | 
|---|
| 4875 |  | 
|---|
| 4876 | case IDM_AUTOTILE: | 
|---|
| 4877 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 4878 | SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile"); | 
|---|
| 4879 | if (fAutoTile) | 
|---|
| 4880 | TileChildren(hwnd, TRUE); | 
|---|
| 4881 | break; | 
|---|
| 4882 |  | 
|---|
| 4883 | case IDM_TILEBACKWARDS: | 
|---|
| 4884 | SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 4885 | SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards"); | 
|---|
| 4886 | if (fAutoTile) | 
|---|
| 4887 | TileChildren(hwnd, TRUE); | 
|---|
| 4888 | break; | 
|---|
| 4889 |  | 
|---|
| 4890 | case IDM_NEXTWINDOW: | 
|---|
| 4891 | case IDM_PREVWINDOW: | 
|---|
| 4892 | NextChild(hwnd, (SHORT1FROMMP(mp1) == IDM_PREVWINDOW)); | 
|---|
| 4893 | break; | 
|---|
| 4894 |  | 
|---|
| 4895 | case IDM_CASCADE: | 
|---|
| 4896 | CascadeChildren(hwnd); | 
|---|
| 4897 | break; | 
|---|
| 4898 |  | 
|---|
| 4899 | case IDM_TILE: | 
|---|
| 4900 | TileChildren(hwnd, TRUE); | 
|---|
| 4901 | break; | 
|---|
| 4902 |  | 
|---|
| 4903 | case IDM_RESTORE: | 
|---|
| 4904 | MinResChildren(hwnd, SWP_RESTORE); | 
|---|
| 4905 | break; | 
|---|
| 4906 |  | 
|---|
| 4907 | case IDM_MINIMIZE: | 
|---|
| 4908 | MinResChildren(hwnd, SWP_MINIMIZE); | 
|---|
| 4909 | break; | 
|---|
| 4910 |  | 
|---|
| 4911 | case IDM_ARRANGEICONS: | 
|---|
| 4912 | ArrangeIcons(hwnd); | 
|---|
| 4913 | break; | 
|---|
| 4914 |  | 
|---|
| 4915 | case IDM_INIVIEWER: | 
|---|
| 4916 | StartIniEditor(hwnd, NULL, 4); | 
|---|
| 4917 | break; | 
|---|
| 4918 |  | 
|---|
| 4919 | case IDM_EDITASSOC: | 
|---|
| 4920 | EditAssociations(hwnd); | 
|---|
| 4921 | break; | 
|---|
| 4922 |  | 
|---|
| 4923 | case IDM_EDITCOMMANDS: | 
|---|
| 4924 | EditCommands(hwnd); | 
|---|
| 4925 | PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID); | 
|---|
| 4926 | break; | 
|---|
| 4927 |  | 
|---|
| 4928 | default: | 
|---|
| 4929 | if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER), | 
|---|
| 4930 | SHORT1FROMMP(mp1))) { | 
|---|
| 4931 | if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART && | 
|---|
| 4932 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) { | 
|---|
| 4933 |  | 
|---|
| 4934 | INT x; | 
|---|
| 4935 | HWND hwndCnr; | 
|---|
| 4936 |  | 
|---|
| 4937 | if (!cmdloaded) | 
|---|
| 4938 | load_commands(); | 
|---|
| 4939 | hwndCnr = TopWindow(hwnd, (HWND) 0); | 
|---|
| 4940 | hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT), | 
|---|
| 4941 | UM_CONTAINERHWND, MPVOID, MPVOID); | 
|---|
| 4942 | if (!hwndCnr) { | 
|---|
| 4943 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT); | 
|---|
| 4944 | break; | 
|---|
| 4945 | } | 
|---|
| 4946 | x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART; | 
|---|
| 4947 | if (x >= 0) { | 
|---|
| 4948 | x++; | 
|---|
| 4949 | RunCommand(hwndCnr, x); | 
|---|
| 4950 | if (fUnHilite) { | 
|---|
| 4951 |  | 
|---|
| 4952 | PCNRITEM pci; | 
|---|
| 4953 | DIRCNRDATA *dcd = NULL; | 
|---|
| 4954 |  | 
|---|
| 4955 | // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR? | 
|---|
| 4956 | if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR) | 
|---|
| 4957 | dcd = INSTDATA(hwndCnr); | 
|---|
| 4958 | pci = (PCNRITEM) WinSendMsg(hwndCnr, | 
|---|
| 4959 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 4960 | MPFROMLONG(CMA_FIRST), | 
|---|
| 4961 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 4962 | if (pci && (INT) pci != -1 && | 
|---|
| 4963 | (pci->rc.flRecordAttr & CRA_SELECTED)) | 
|---|
| 4964 | { | 
|---|
| 4965 | UnHilite(hwnd, | 
|---|
| 4966 | TRUE, | 
|---|
| 4967 | dcd ? &dcd->lastselection : NULL, | 
|---|
| 4968 | dcd ? dcd ->ulItemsToUnHilite : 0); | 
|---|
| 4969 | } | 
|---|
| 4970 | } | 
|---|
| 4971 | } | 
|---|
| 4972 | } | 
|---|
| 4973 | else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART && | 
|---|
| 4974 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) { | 
|---|
| 4975 | if (!qtloaded) | 
|---|
| 4976 | load_quicktools(); | 
|---|
| 4977 | if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) { | 
|---|
| 4978 | if (fToolsChanged) | 
|---|
| 4979 | save_tools(NULL); | 
|---|
| 4980 | if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART])) | 
|---|
| 4981 | load_tools(NULL); | 
|---|
| 4982 | else { | 
|---|
| 4983 | strcpy(lasttoolbox, | 
|---|
| 4984 | quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]); | 
|---|
| 4985 | PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox); | 
|---|
| 4986 | } | 
|---|
| 4987 | BuildTools(hwndToolback, TRUE); | 
|---|
| 4988 | } | 
|---|
| 4989 | } | 
|---|
| 4990 | else { | 
|---|
| 4991 |  | 
|---|
| 4992 | HWND hwndActive; | 
|---|
| 4993 |  | 
|---|
| 4994 | hwndActive = TopWindow(hwnd, (HWND) 0); | 
|---|
| 4995 | if (hwndActive) | 
|---|
| 4996 | PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), | 
|---|
| 4997 | WM_COMMAND, mp1, mp2); | 
|---|
| 4998 | } | 
|---|
| 4999 | } | 
|---|
| 5000 | break;                              // default | 
|---|
| 5001 | } // switch mp1 | 
|---|
| 5002 | return 0; | 
|---|
| 5003 | } | 
|---|
| 5004 |  | 
|---|
| 5005 | static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1, | 
|---|
| 5006 | MPARAM mp2) | 
|---|
| 5007 | { | 
|---|
| 5008 | TID tid; | 
|---|
| 5009 | SWP swp; | 
|---|
| 5010 | PFNWP oldproc; | 
|---|
| 5011 | HWND hwndTmp; | 
|---|
| 5012 | HWND hwndFrame; | 
|---|
| 5013 | HWND hwndSysMenu, hwndSysSubMenu, hwndMenu; | 
|---|
| 5014 | USHORT idSysMenu; | 
|---|
| 5015 | MENUITEM mi, mit; | 
|---|
| 5016 | ULONG size; | 
|---|
| 5017 | BOOL temp = FALSE; | 
|---|
| 5018 |  | 
|---|
| 5019 | switch (msg) { | 
|---|
| 5020 | case WM_CREATE: | 
|---|
| 5021 | WinQueryWindowProcess(hwnd, &mypid, &tid); | 
|---|
| 5022 | hwndMain = hwnd; | 
|---|
| 5023 | WinSetWindowUShort(hwnd, QWL_USER + 8, 0); | 
|---|
| 5024 | WinSetWindowUShort(hwnd, QWL_USER + 10, 0); | 
|---|
| 5025 | WinSetWindowUShort(hwnd, QWL_USER + 12, 0); | 
|---|
| 5026 | WinSetWindowUShort(hwnd, QWL_USER + 16, 0); | 
|---|
| 5027 | if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) { | 
|---|
| 5028 | Runtime_Error(pszSrcFile, __LINE__, | 
|---|
| 5029 | GetPString(IDS_COULDNTSTARTTHREADTEXT)); | 
|---|
| 5030 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 5031 | return 0; | 
|---|
| 5032 | } | 
|---|
| 5033 | else | 
|---|
| 5034 | DosSleep(32);//05 Aug 07 GKY 64 | 
|---|
| 5035 |  | 
|---|
| 5036 | hwndFrame = WinQueryWindow(hwnd, QW_PARENT); | 
|---|
| 5037 |  | 
|---|
| 5038 | /* | 
|---|
| 5039 | * create frame children (not client children, frame children) | 
|---|
| 5040 | */ | 
|---|
| 5041 | DosSleep(1); | 
|---|
| 5042 | WinQueryWindowPos(hwndFrame, &swp); | 
|---|
| 5043 | oldproc = WinSubclassWindow(hwndFrame, MainFrameWndProc); | 
|---|
| 5044 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc); | 
|---|
| 5045 | CommonCreateMainChildren(hwnd, &swp); | 
|---|
| 5046 |  | 
|---|
| 5047 | if (!WinCreateWindow(hwndFrame, | 
|---|
| 5048 | WC_BUTTON, | 
|---|
| 5049 | "I", | 
|---|
| 5050 | WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS, | 
|---|
| 5051 | ((swp.cx - | 
|---|
| 5052 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5053 | SV_CXMINMAXBUTTON)) - | 
|---|
| 5054 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5055 | SV_CXMINMAXBUTTON) / 2) - | 
|---|
| 5056 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5057 | SV_CXSIZEBORDER), | 
|---|
| 5058 | (swp.cy - WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5059 | SV_CYMINMAXBUTTON)) - | 
|---|
| 5060 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5061 | SV_CYSIZEBORDER), | 
|---|
| 5062 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5063 | SV_CXMINMAXBUTTON) / 2, | 
|---|
| 5064 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5065 | SV_CYMINMAXBUTTON), | 
|---|
| 5066 | hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) { | 
|---|
| 5067 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 5068 | } | 
|---|
| 5069 | else { | 
|---|
| 5070 | WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE), | 
|---|
| 5071 | IdealButtonProc); | 
|---|
| 5072 | SetPresParams(WinWindowFromID(hwndFrame, | 
|---|
| 5073 | IDM_IDEALSIZE), | 
|---|
| 5074 | NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT)); | 
|---|
| 5075 | } | 
|---|
| 5076 |  | 
|---|
| 5077 | hwndTmp = WinCreateWindow(hwndFrame, | 
|---|
| 5078 | WC_BUTTON, | 
|---|
| 5079 | "#1019", | 
|---|
| 5080 | WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | | 
|---|
| 5081 | BS_BITMAP, | 
|---|
| 5082 | swp.cx - 46, | 
|---|
| 5083 | swp.y + 2, | 
|---|
| 5084 | 24, | 
|---|
| 5085 | 22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL); | 
|---|
| 5086 | if (!hwndTmp) | 
|---|
| 5087 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 5088 |  | 
|---|
| 5089 | hwndTmp = WinCreateWindow(hwndFrame, | 
|---|
| 5090 | WC_BUTTON, | 
|---|
| 5091 | "#3062", | 
|---|
| 5092 | WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS | | 
|---|
| 5093 | BS_BITMAP, | 
|---|
| 5094 | swp.cx - 22, | 
|---|
| 5095 | swp.y + 2, | 
|---|
| 5096 | 24, | 
|---|
| 5097 | 22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL); | 
|---|
| 5098 | if (!hwndTmp) | 
|---|
| 5099 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 5100 |  | 
|---|
| 5101 | hwndUserlist = WinCreateWindow(hwndFrame, | 
|---|
| 5102 | WC_COMBOBOX, | 
|---|
| 5103 | (PSZ) NULL, | 
|---|
| 5104 | WS_VISIBLE | CBS_DROPDOWN | | 
|---|
| 5105 | LS_HORZSCROLL, | 
|---|
| 5106 | (swp.x + | 
|---|
| 5107 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5108 | SV_CXSIZEBORDER) + 48L), | 
|---|
| 5109 | (swp.cy - | 
|---|
| 5110 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5111 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5112 | ((swp.cx - | 
|---|
| 5113 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5114 | SV_CXSIZEBORDER) * | 
|---|
| 5115 | 2)) - 64L), 60L, hwndFrame, HWND_TOP, | 
|---|
| 5116 | MAIN_USERLIST, NULL, NULL); | 
|---|
| 5117 | if (!hwndUserlist) | 
|---|
| 5118 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 5119 | hwndCmdlist = WinCreateWindow(hwndFrame, | 
|---|
| 5120 | WC_COMBOBOX, | 
|---|
| 5121 | (PSZ) NULL, | 
|---|
| 5122 | WS_VISIBLE | CBS_DROPDOWN | | 
|---|
| 5123 | LS_HORZSCROLL, | 
|---|
| 5124 | (swp.x + | 
|---|
| 5125 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5126 | SV_CXSIZEBORDER) + 48L), | 
|---|
| 5127 | (swp.cy - | 
|---|
| 5128 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5129 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5130 | ((swp.cx - | 
|---|
| 5131 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5132 | SV_CXSIZEBORDER) * 2)) - | 
|---|
| 5133 | 64L), 60L, hwndFrame, HWND_TOP, | 
|---|
| 5134 | MAIN_CMDLIST, NULL, NULL); | 
|---|
| 5135 | if (!hwndCmdlist) | 
|---|
| 5136 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 5137 | WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT)); | 
|---|
| 5138 | hwndStatelist = WinCreateWindow(hwndFrame, | 
|---|
| 5139 | WC_COMBOBOX, | 
|---|
| 5140 | (PSZ) NULL, | 
|---|
| 5141 | WS_VISIBLE | CBS_DROPDOWN | | 
|---|
| 5142 | LS_HORZSCROLL, | 
|---|
| 5143 | (swp.x + | 
|---|
| 5144 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5145 | SV_CXSIZEBORDER) + 48L), | 
|---|
| 5146 | (swp.cy - | 
|---|
| 5147 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5148 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5149 | ((swp.cx - | 
|---|
| 5150 | (WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5151 | SV_CXSIZEBORDER) * | 
|---|
| 5152 | 2)) - 64L), 60L, hwndFrame, HWND_TOP, | 
|---|
| 5153 | MAIN_SETUPLIST, NULL, NULL); | 
|---|
| 5154 | if (!hwndStatelist) | 
|---|
| 5155 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 5156 |  | 
|---|
| 5157 | hwndDrivelist = WinCreateWindow(hwndFrame, | 
|---|
| 5158 | WC_COMBOBOX, | 
|---|
| 5159 | (PSZ) NULL, | 
|---|
| 5160 | WS_VISIBLE | CBS_DROPDOWN, | 
|---|
| 5161 | (swp.x + | 
|---|
| 5162 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5163 | SV_CXSIZEBORDER)), | 
|---|
| 5164 | (swp.cy - | 
|---|
| 5165 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5166 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5167 | 48L, | 
|---|
| 5168 | 60L, | 
|---|
| 5169 | hwndFrame, | 
|---|
| 5170 | HWND_TOP, MAIN_DRIVELIST, NULL, NULL); | 
|---|
| 5171 | if (!hwndDrivelist) | 
|---|
| 5172 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 5173 | SetPresParams(hwndDrivelist, | 
|---|
| 5174 | NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT)); | 
|---|
| 5175 | hwndButtonlist = WinCreateWindow(hwndFrame, | 
|---|
| 5176 | WC_COMBOBOX, | 
|---|
| 5177 | (PSZ) NULL, | 
|---|
| 5178 | WS_VISIBLE | CBS_DROPDOWN | | 
|---|
| 5179 | LS_HORZSCROLL, | 
|---|
| 5180 | (swp.cx - | 
|---|
| 5181 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5182 | SV_CXSIZEBORDER)) - | 
|---|
| 5183 | 164L, | 
|---|
| 5184 | (swp.cy - | 
|---|
| 5185 | WinQuerySysValue(HWND_DESKTOP, | 
|---|
| 5186 | SV_CYSIZEBORDER)) - 60, | 
|---|
| 5187 | 164L, 60L, hwndFrame, HWND_TOP, | 
|---|
| 5188 | MAIN_BUTTONLIST, NULL, NULL); | 
|---|
| 5189 | if (!hwndButtonlist) | 
|---|
| 5190 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW); | 
|---|
| 5191 | WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT), | 
|---|
| 5192 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID); | 
|---|
| 5193 | WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT), | 
|---|
| 5194 | EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID); | 
|---|
| 5195 | WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 5196 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 5197 | WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT), | 
|---|
| 5198 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 5199 | WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT), | 
|---|
| 5200 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 5201 |  | 
|---|
| 5202 | oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT), | 
|---|
| 5203 | DropDownListProc); | 
|---|
| 5204 | WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT), | 
|---|
| 5205 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5206 | oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT), | 
|---|
| 5207 | DropDownListProc); | 
|---|
| 5208 | WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT), | 
|---|
| 5209 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5210 | oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT), | 
|---|
| 5211 | DropDownListProc); | 
|---|
| 5212 | WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT), | 
|---|
| 5213 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5214 | oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT), | 
|---|
| 5215 | DropDownListProc); | 
|---|
| 5216 | WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT), | 
|---|
| 5217 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5218 | oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 5219 | DropDownListProc); | 
|---|
| 5220 | WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT), | 
|---|
| 5221 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5222 | oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc); | 
|---|
| 5223 | WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5224 | oldproc = WinSubclassWindow(hwndCmdlist, DropDownListProc); | 
|---|
| 5225 | WinSetWindowPtr(hwndCmdlist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5226 | oldproc = WinSubclassWindow(hwndStatelist, DropDownListProc); | 
|---|
| 5227 | WinSetWindowPtr(hwndStatelist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5228 | oldproc = WinSubclassWindow(hwndDrivelist, DropDownListProc); | 
|---|
| 5229 | WinSetWindowPtr(hwndDrivelist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5230 | oldproc = WinSubclassWindow(hwndButtonlist, DropDownListProc); | 
|---|
| 5231 | WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc); | 
|---|
| 5232 | oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST), | 
|---|
| 5233 | ChildFrameButtonProc); | 
|---|
| 5234 | WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST), | 
|---|
| 5235 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5236 | oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK), | 
|---|
| 5237 | ChildFrameButtonProc); | 
|---|
| 5238 | WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK), | 
|---|
| 5239 | QWL_USER, (PVOID) oldproc); | 
|---|
| 5240 | hwndMenu = WinWindowFromID(hwndFrame, FID_MENU); | 
|---|
| 5241 | WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID); | 
|---|
| 5242 | SetToggleChecks(hwndMenu); | 
|---|
| 5243 | SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR); | 
|---|
| 5244 | SetConditionalCascade(hwndMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW); | 
|---|
| 5245 | SetConditionalCascade(hwndMenu, IDM_TILEMENU, IDM_TILE); | 
|---|
| 5246 | WinSetWindowULong(hwnd, QWL_USER, hwndMenu); | 
|---|
| 5247 | memset(&mi, 0, sizeof(mi)); | 
|---|
| 5248 | memset(&mit, 0, sizeof(mit)); | 
|---|
| 5249 | hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU); | 
|---|
| 5250 | idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu, | 
|---|
| 5251 | MM_ITEMIDFROMPOSITION, | 
|---|
| 5252 | MPVOID, MPVOID)); | 
|---|
| 5253 | WinSendMsg(hwndSysMenu, | 
|---|
| 5254 | MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit)); | 
|---|
| 5255 | hwndSysSubMenu = mit.hwndSubMenu; | 
|---|
| 5256 | mi.iPosition = MIT_END; | 
|---|
| 5257 | mi.afStyle = MIS_SEPARATOR; | 
|---|
| 5258 | mi.id = (USHORT) - 1; | 
|---|
| 5259 | WinSendMsg(hwndSysSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(NULL)); | 
|---|
| 5260 | mi.afStyle = MIS_TEXT; | 
|---|
| 5261 | mi.id = IDM_IDEALSIZE; | 
|---|
| 5262 | WinSendMsg(hwndSysSubMenu, | 
|---|
| 5263 | MM_INSERTITEM, | 
|---|
| 5264 | MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT))); | 
|---|
| 5265 | mi.afStyle = MIS_TEXT; | 
|---|
| 5266 | mi.id = IDM_HIDEMENU; | 
|---|
| 5267 | WinSendMsg(hwndSysSubMenu, | 
|---|
| 5268 | MM_INSERTITEM, | 
|---|
| 5269 | MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT))); | 
|---|
| 5270 | SetSysMenu(hwndSysMenu); | 
|---|
| 5271 |  | 
|---|
| 5272 | size = sizeof(BOOL); | 
|---|
| 5273 | if (PrfQueryProfileData(fmprof, | 
|---|
| 5274 | FM3Str, | 
|---|
| 5275 | "MenuInvisible", &temp, &size) && size && temp) | 
|---|
| 5276 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID); | 
|---|
| 5277 | size = sizeof(BOOL); | 
|---|
| 5278 | if (PrfQueryProfileData(fmprof, | 
|---|
| 5279 | FM3Str, "FreeTree", &temp, &size) && size && temp) | 
|---|
| 5280 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID); | 
|---|
| 5281 | size = sizeof(BOOL); | 
|---|
| 5282 | if (PrfQueryProfileData(fmprof, | 
|---|
| 5283 | FM3Str, | 
|---|
| 5284 | "AutoTile", &temp, &size) && size && !temp) | 
|---|
| 5285 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID); | 
|---|
| 5286 | size = sizeof(BOOL); | 
|---|
| 5287 | if (PrfQueryProfileData(fmprof, | 
|---|
| 5288 | FM3Str, "Toolbar", &temp, &size) && size && !temp) | 
|---|
| 5289 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID); | 
|---|
| 5290 |  | 
|---|
| 5291 | WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "FM/2"); | 
|---|
| 5292 | FixSwitchList(hwndFrame, NULL); | 
|---|
| 5293 | break;                              // WM_CREATE | 
|---|
| 5294 |  | 
|---|
| 5295 | case UM_SETUP: | 
|---|
| 5296 | /* | 
|---|
| 5297 | * start up some initial children | 
|---|
| 5298 | */ | 
|---|
| 5299 | load_tools(NULL); | 
|---|
| 5300 | BuildTools(hwndToolback, TRUE); | 
|---|
| 5301 | WinShowWindow(WinQueryWindow(hwnd, QW_PARENT), TRUE); | 
|---|
| 5302 | PostMsg(MainObjectHwnd, UM_SETUP2, mp1, mp2); | 
|---|
| 5303 | return 0; | 
|---|
| 5304 |  | 
|---|
| 5305 | case UM_SETUP2: | 
|---|
| 5306 | { | 
|---|
| 5307 | SWP swp; | 
|---|
| 5308 | ULONG size = sizeof(SWP); | 
|---|
| 5309 |  | 
|---|
| 5310 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 5311 | hwndTree = StartTreeCnr(hwnd, 0); | 
|---|
| 5312 | if (!hwndTree) | 
|---|
| 5313 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 5314 | else { | 
|---|
| 5315 | if (!fSaveState || | 
|---|
| 5316 | !PrfQueryProfileData(fmprof, | 
|---|
| 5317 | FM3Str, | 
|---|
| 5318 | "LastTreePos", | 
|---|
| 5319 | &swp, &size) || size != sizeof(SWP)) { | 
|---|
| 5320 |  | 
|---|
| 5321 | INT ratio, height = 0; | 
|---|
| 5322 |  | 
|---|
| 5323 | if (!fNoTreeGap) | 
|---|
| 5324 | height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2; | 
|---|
| 5325 | size = sizeof(ratio); | 
|---|
| 5326 | if (!PrfQueryProfileData(fmprof, | 
|---|
| 5327 | FM3Str, | 
|---|
| 5328 | "TreeWindowRatio", | 
|---|
| 5329 | (PVOID) & ratio, | 
|---|
| 5330 | &size) || size < sizeof(ratio)) | 
|---|
| 5331 | ratio = 400; | 
|---|
| 5332 | WinSetWindowPos(hwndTree, | 
|---|
| 5333 | HWND_TOP, | 
|---|
| 5334 | 0, | 
|---|
| 5335 | height, | 
|---|
| 5336 | (swp.cx * 100) / ratio, | 
|---|
| 5337 | swp.cy - height, | 
|---|
| 5338 | SWP_SHOW | SWP_SIZE | SWP_MOVE | | 
|---|
| 5339 | SWP_ACTIVATE | SWP_ZORDER); | 
|---|
| 5340 | } | 
|---|
| 5341 | else | 
|---|
| 5342 | WinSetWindowPos(hwndTree, | 
|---|
| 5343 | HWND_TOP, | 
|---|
| 5344 | swp.x, | 
|---|
| 5345 | swp.y, | 
|---|
| 5346 | swp.cx, | 
|---|
| 5347 | swp.cy, | 
|---|
| 5348 | swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | | 
|---|
| 5349 | SWP_ZORDER | SWP_ACTIVATE); | 
|---|
| 5350 | } | 
|---|
| 5351 | ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5352 | MAIN_TOOLS)); | 
|---|
| 5353 | } | 
|---|
| 5354 | PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2); | 
|---|
| 5355 | return 0; | 
|---|
| 5356 |  | 
|---|
| 5357 | case UM_SETUP3: | 
|---|
| 5358 | /* start remaining child windows */ | 
|---|
| 5359 | if (!fNoSaveState && fSaveState) | 
|---|
| 5360 | PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPVOID); | 
|---|
| 5361 | PostMsg(MainObjectHwnd, UM_SETUP4, mp1, mp2); | 
|---|
| 5362 | return 0; | 
|---|
| 5363 |  | 
|---|
| 5364 | case UM_SETUP4: | 
|---|
| 5365 | { | 
|---|
| 5366 | INT argc = (INT) mp1, x; | 
|---|
| 5367 | CHAR **argv = (CHAR **) mp2; | 
|---|
| 5368 |  | 
|---|
| 5369 | for (x = 1; x < argc; x++) { | 
|---|
| 5370 | if (*argv[x] == '/' || *argv[x] == ';') | 
|---|
| 5371 | continue; | 
|---|
| 5372 | if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE)) | 
|---|
| 5373 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]); | 
|---|
| 5374 | } | 
|---|
| 5375 | } | 
|---|
| 5376 | PostMsg(MainObjectHwnd, UM_SETUP5, MPVOID, MPVOID); | 
|---|
| 5377 | return 0; | 
|---|
| 5378 |  | 
|---|
| 5379 | case UM_SETUP5: | 
|---|
| 5380 | if (fAutoTile) | 
|---|
| 5381 | TileChildren(hwnd, TRUE); | 
|---|
| 5382 | PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID); | 
|---|
| 5383 | PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID); | 
|---|
| 5384 | PostMsg(hwnd, UM_FILLCMDLIST, MPVOID, MPVOID); | 
|---|
| 5385 | PostMsg(hwnd, UM_FILLBUTTONLIST, MPVOID, MPVOID); | 
|---|
| 5386 | { | 
|---|
| 5387 | HWND hwndActive; | 
|---|
| 5388 |  | 
|---|
| 5389 | hwndActive = TopWindow(hwnd, hwndTree); | 
|---|
| 5390 | if (hwndActive) | 
|---|
| 5391 | WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); | 
|---|
| 5392 | } | 
|---|
| 5393 | if (fStartMinimized || fReminimize) | 
|---|
| 5394 | PostMsg(hwndTree, UM_MINIMIZE, MPVOID, MPVOID); | 
|---|
| 5395 | else if (fStartMaximized) | 
|---|
| 5396 | PostMsg(hwndTree, UM_MAXIMIZE, MPVOID, MPVOID); | 
|---|
| 5397 | fRunning = TRUE; | 
|---|
| 5398 | return 0; | 
|---|
| 5399 | } | 
|---|
| 5400 |  | 
|---|
| 5401 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 5402 | } | 
|---|
| 5403 |  | 
|---|
| 5404 | MRESULT EXPENTRY MainWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 5405 | { | 
|---|
| 5406 | switch (msg) { | 
|---|
| 5407 | case WM_CREATE: | 
|---|
| 5408 | case UM_SETUP: | 
|---|
| 5409 | case UM_SETUP2: | 
|---|
| 5410 | case UM_SETUP3: | 
|---|
| 5411 | case UM_SETUP4: | 
|---|
| 5412 | case UM_SETUP5: | 
|---|
| 5413 | return MainWMOnce(hwnd, msg, mp1, mp2); | 
|---|
| 5414 |  | 
|---|
| 5415 | case WM_CONTROLPOINTER: | 
|---|
| 5416 | if (!fNoFinger && | 
|---|
| 5417 | (SHORT1FROMMP(mp1) == IDM_OPENWALK || | 
|---|
| 5418 | SHORT1FROMMP(mp1) == IDM_USERLIST)) | 
|---|
| 5419 | return MRFROMLONG(hptrFinger); | 
|---|
| 5420 | break; | 
|---|
| 5421 |  | 
|---|
| 5422 | case UM_LOADFILE: | 
|---|
| 5423 | case UM_THREADUSE: | 
|---|
| 5424 | case UM_BUILDDRIVEBAR: | 
|---|
| 5425 | return CommonMainWndProc(hwnd, msg, mp1, mp2); | 
|---|
| 5426 |  | 
|---|
| 5427 | case WM_BUTTON1UP: | 
|---|
| 5428 | case WM_BUTTON2UP: | 
|---|
| 5429 | case WM_BUTTON3UP: | 
|---|
| 5430 | case WM_MOUSEMOVE: | 
|---|
| 5431 | shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL)); | 
|---|
| 5432 | break; | 
|---|
| 5433 |  | 
|---|
| 5434 | case WM_CHAR: | 
|---|
| 5435 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL)); | 
|---|
| 5436 | break; | 
|---|
| 5437 |  | 
|---|
| 5438 | case WM_MENUEND: | 
|---|
| 5439 | if ((HWND) mp2 == MainPopupMenu) { | 
|---|
| 5440 | WinDestroyWindow(MainPopupMenu); | 
|---|
| 5441 | MainPopupMenu = (HWND) 0; | 
|---|
| 5442 | } | 
|---|
| 5443 | break; | 
|---|
| 5444 |  | 
|---|
| 5445 | case UM_CONTEXTMENU: | 
|---|
| 5446 | case WM_CONTEXTMENU: | 
|---|
| 5447 | if (CheckMenu(&MainPopupMenu, MAIN_POPUP)) { | 
|---|
| 5448 | SetToggleChecks(MainPopupMenu); | 
|---|
| 5449 | PopupMenu(hwnd, hwnd, MainPopupMenu); | 
|---|
| 5450 | } | 
|---|
| 5451 | if (msg == UM_CONTEXTMENU) | 
|---|
| 5452 | return 0; | 
|---|
| 5453 | return MRFROMSHORT(TRUE); | 
|---|
| 5454 |  | 
|---|
| 5455 | case UM_SETUSERLISTNAME: | 
|---|
| 5456 | if (mp1) { | 
|---|
| 5457 | if (fUserComboBox) | 
|---|
| 5458 | WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT), | 
|---|
| 5459 | (CHAR *) mp1); | 
|---|
| 5460 | if (add_udir(FALSE, (CHAR *) mp1)) { | 
|---|
| 5461 | if (fUserComboBox && fAutoAddDirs) { | 
|---|
| 5462 | WinSendMsg(hwndUserlist, LM_INSERTITEM, | 
|---|
| 5463 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
| 5464 | MPFROMP((CHAR *) mp1)); | 
|---|
| 5465 | } | 
|---|
| 5466 | } | 
|---|
| 5467 | } | 
|---|
| 5468 | return 0; | 
|---|
| 5469 |  | 
|---|
| 5470 | case UM_ARRANGEICONS: | 
|---|
| 5471 | ArrangeIcons(hwnd); | 
|---|
| 5472 | return 0; | 
|---|
| 5473 |  | 
|---|
| 5474 | case WM_CHORD: | 
|---|
| 5475 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID); | 
|---|
| 5476 | break; | 
|---|
| 5477 |  | 
|---|
| 5478 | case WM_SETFOCUS: | 
|---|
| 5479 | if (mp2) | 
|---|
| 5480 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID); | 
|---|
| 5481 | break; | 
|---|
| 5482 |  | 
|---|
| 5483 | case UM_FOCUSME: | 
|---|
| 5484 | WinSetFocus(hwndTree, TRUE); | 
|---|
| 5485 | return 0; | 
|---|
| 5486 |  | 
|---|
| 5487 | case UM_RESCAN: | 
|---|
| 5488 | TileChildren(hwnd, TRUE); | 
|---|
| 5489 | return 0; | 
|---|
| 5490 |  | 
|---|
| 5491 | case WM_SAVEAPPLICATION: | 
|---|
| 5492 | { | 
|---|
| 5493 | SWP swp; | 
|---|
| 5494 |  | 
|---|
| 5495 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp); | 
|---|
| 5496 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 5497 | WinStoreWindowPos(FM2Str, | 
|---|
| 5498 | "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 5499 | if (!fNoSaveState && fSaveState) | 
|---|
| 5500 | SaveDirCnrState(hwnd, NULL); | 
|---|
| 5501 | } | 
|---|
| 5502 | } | 
|---|
| 5503 | break; | 
|---|
| 5504 |  | 
|---|
| 5505 | case MM_PORTHOLEINIT: | 
|---|
| 5506 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 5507 | case 0: | 
|---|
| 5508 | case 1: | 
|---|
| 5509 | { | 
|---|
| 5510 | HWND hwndCurrent; | 
|---|
| 5511 | ULONG wmsg; | 
|---|
| 5512 |  | 
|---|
| 5513 | wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU; | 
|---|
| 5514 | hwndCurrent = TopWindow(hwnd, (HWND) 0); | 
|---|
| 5515 | PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent, | 
|---|
| 5516 | FID_CLIENT), wmsg, | 
|---|
| 5517 | MPVOID, MPVOID), mp1, mp2); | 
|---|
| 5518 | } | 
|---|
| 5519 | break; | 
|---|
| 5520 | } | 
|---|
| 5521 | break; | 
|---|
| 5522 |  | 
|---|
| 5523 | case WM_INITMENU: | 
|---|
| 5524 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 5525 | case IDM_CONFIGMENU: | 
|---|
| 5526 | SetToggleChecks((HWND) WinQueryWindowULong(hwnd, QWL_USER)); | 
|---|
| 5527 | break; | 
|---|
| 5528 |  | 
|---|
| 5529 | case IDM_WINDOWSMENU: | 
|---|
| 5530 | /* | 
|---|
| 5531 | * add child windows of client | 
|---|
| 5532 | * and switchlist entries to end of pulldown menu | 
|---|
| 5533 | */ | 
|---|
| 5534 | { | 
|---|
| 5535 | HWND hwndMenu, hwndSubMenu; | 
|---|
| 5536 | MENUITEM mi; | 
|---|
| 5537 |  | 
|---|
| 5538 | hwndMenu = WinQueryWindowULong(hwnd, QWL_USER); | 
|---|
| 5539 | memset(&mi, 0, sizeof(mi)); | 
|---|
| 5540 | mi.iPosition = MIT_END; | 
|---|
| 5541 | mi.afStyle = MIS_TEXT; | 
|---|
| 5542 | if (!WinSendMsg(hwndMenu, MM_QUERYITEM, | 
|---|
| 5543 | MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi))) | 
|---|
| 5544 | break; | 
|---|
| 5545 | hwndSubMenu = mi.hwndSubMenu; | 
|---|
| 5546 | SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 5547 | } | 
|---|
| 5548 | break; | 
|---|
| 5549 |  | 
|---|
| 5550 | default: | 
|---|
| 5551 | { | 
|---|
| 5552 | HWND hwndCurrent; | 
|---|
| 5553 |  | 
|---|
| 5554 | hwndCurrent = TopWindow(hwnd, (HWND) 0); | 
|---|
| 5555 | if (hwndCurrent) | 
|---|
| 5556 | WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2); | 
|---|
| 5557 | } | 
|---|
| 5558 | break; | 
|---|
| 5559 | } | 
|---|
| 5560 | break; | 
|---|
| 5561 |  | 
|---|
| 5562 | case UM_ADDTOMENU: | 
|---|
| 5563 | AddToMenu((CHAR *) mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5564 | FID_MENU)); | 
|---|
| 5565 | return 0; | 
|---|
| 5566 |  | 
|---|
| 5567 | case UM_FILLCMDLIST: | 
|---|
| 5568 | WinSendMsg(hwndCmdlist, LM_DELETEALL, MPVOID, MPVOID); | 
|---|
| 5569 | if (!cmdloaded) | 
|---|
| 5570 | load_commands(); | 
|---|
| 5571 | if (cmdhead) { | 
|---|
| 5572 |  | 
|---|
| 5573 | LINKCMDS *info; | 
|---|
| 5574 |  | 
|---|
| 5575 | info = cmdhead; | 
|---|
| 5576 | while (info) { | 
|---|
| 5577 | WinSendMsg(hwndCmdlist, LM_INSERTITEM, | 
|---|
| 5578 | MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title)); | 
|---|
| 5579 | info = info->next; | 
|---|
| 5580 | } | 
|---|
| 5581 | } | 
|---|
| 5582 | return 0; | 
|---|
| 5583 |  | 
|---|
| 5584 | case UM_FILLSETUPLIST: | 
|---|
| 5585 | fill_setups_list(); | 
|---|
| 5586 | return 0; | 
|---|
| 5587 |  | 
|---|
| 5588 | case UM_FILLBUTTONLIST: | 
|---|
| 5589 | WinSendMsg(hwndButtonlist, LM_DELETEALL, MPVOID, MPVOID); | 
|---|
| 5590 | if (fUserComboBox) { | 
|---|
| 5591 |  | 
|---|
| 5592 | BOOL foundit = FALSE, thisone; | 
|---|
| 5593 | ULONG ulSearchCount; | 
|---|
| 5594 | SHORT sSelect; | 
|---|
| 5595 | FILEFINDBUF3 findbuf; | 
|---|
| 5596 | HDIR hDir; | 
|---|
| 5597 | CHAR *p; | 
|---|
| 5598 |  | 
|---|
| 5599 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 5600 | hDir = HDIR_CREATE; | 
|---|
| 5601 | ulSearchCount = 1; | 
|---|
| 5602 | if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED, | 
|---|
| 5603 | &findbuf, sizeof(FILEFINDBUF3), | 
|---|
| 5604 | &ulSearchCount, FIL_STANDARD)) { | 
|---|
| 5605 | do { | 
|---|
| 5606 | priority_bumped(); | 
|---|
| 5607 | if (!foundit) { | 
|---|
| 5608 | thisone = FALSE; | 
|---|
| 5609 | p = strrchr(lasttoolbox, '\\'); | 
|---|
| 5610 | if (!p) | 
|---|
| 5611 | p = lasttoolbox; | 
|---|
| 5612 | else | 
|---|
| 5613 | p++; | 
|---|
| 5614 | if (!stricmp(findbuf.achName, p)) | 
|---|
| 5615 | thisone = TRUE; | 
|---|
| 5616 | } | 
|---|
| 5617 | p = strrchr(findbuf.achName, '.'); | 
|---|
| 5618 | if (p) | 
|---|
| 5619 | *p = 0; | 
|---|
| 5620 | sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM, | 
|---|
| 5621 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
| 5622 | MPFROMP(findbuf.achName)); | 
|---|
| 5623 | if (!foundit && thisone && sSelect >= 0) { | 
|---|
| 5624 | WinSendMsg(hwndButtonlist, LM_SELECTITEM, | 
|---|
| 5625 | MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE)); | 
|---|
| 5626 | foundit = TRUE; | 
|---|
| 5627 | } | 
|---|
| 5628 | } | 
|---|
| 5629 | while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), | 
|---|
| 5630 | &ulSearchCount)); | 
|---|
| 5631 | DosFindClose(hDir); | 
|---|
| 5632 | priority_bumped(); | 
|---|
| 5633 | } | 
|---|
| 5634 | WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT)); | 
|---|
| 5635 | } | 
|---|
| 5636 | return 0; | 
|---|
| 5637 |  | 
|---|
| 5638 | case UM_FILLUSERLIST: | 
|---|
| 5639 | WinSendMsg(hwndUserlist, LM_DELETEALL, MPVOID, MPVOID); | 
|---|
| 5640 | if (fUserComboBox) { | 
|---|
| 5641 | ULONG ulDriveNum; | 
|---|
| 5642 | ULONG ulDriveMap; | 
|---|
| 5643 | ULONG ulSearchCount; | 
|---|
| 5644 | FILEFINDBUF3 findbuf; | 
|---|
| 5645 | HDIR hDir; | 
|---|
| 5646 | APIRET rc; | 
|---|
| 5647 | LINKDIRS *info; | 
|---|
| 5648 | LINKDIRS *temp; | 
|---|
| 5649 |  | 
|---|
| 5650 | if (!loadedudirs) | 
|---|
| 5651 | load_udirs(); | 
|---|
| 5652 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 5653 | DosQCurDisk(&ulDriveNum, &ulDriveMap); | 
|---|
| 5654 | info = udirhead; | 
|---|
| 5655 | while (info) { | 
|---|
| 5656 | if (IsFullName(info->path) && | 
|---|
| 5657 | !(driveflags[toupper(*info->path) - 'A'] & | 
|---|
| 5658 | (DRIVE_IGNORE | DRIVE_INVALID))) { | 
|---|
| 5659 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 5660 | hDir = HDIR_CREATE; | 
|---|
| 5661 | ulSearchCount = 1; | 
|---|
| 5662 | if (!IsRoot(info->path)) | 
|---|
| 5663 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY | | 
|---|
| 5664 | MUST_HAVE_DIRECTORY | FILE_READONLY | | 
|---|
| 5665 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, | 
|---|
| 5666 | &findbuf, sizeof(FILEFINDBUF3), | 
|---|
| 5667 | &ulSearchCount, FIL_STANDARD); | 
|---|
| 5668 | else { | 
|---|
| 5669 | rc = 0; | 
|---|
| 5670 | findbuf.attrFile = FILE_DIRECTORY; | 
|---|
| 5671 | } | 
|---|
| 5672 | priority_bumped(); | 
|---|
| 5673 | if (!rc) { | 
|---|
| 5674 | if (!IsRoot(info->path)) | 
|---|
| 5675 | DosFindClose(hDir); | 
|---|
| 5676 | if (findbuf.attrFile & FILE_DIRECTORY) | 
|---|
| 5677 | WinSendMsg(hwndUserlist, LM_INSERTITEM, | 
|---|
| 5678 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
| 5679 | MPFROMP(info->path)); | 
|---|
| 5680 | else { | 
|---|
| 5681 | temp = info->next; | 
|---|
| 5682 | remove_udir(info->path); | 
|---|
| 5683 | info = temp; | 
|---|
| 5684 | continue; | 
|---|
| 5685 | } | 
|---|
| 5686 | } | 
|---|
| 5687 | else if (!(ulDriveMap & (1L << (toupper(*info->path) - 'A')))) { | 
|---|
| 5688 | temp = info->next; | 
|---|
| 5689 | remove_udir(info->path); | 
|---|
| 5690 | info = temp; | 
|---|
| 5691 | continue; | 
|---|
| 5692 | } | 
|---|
| 5693 | } | 
|---|
| 5694 | info = info->next; | 
|---|
| 5695 | } | 
|---|
| 5696 | info = ldirhead; | 
|---|
| 5697 | while (info) { | 
|---|
| 5698 | if (IsFullName(info->path) && | 
|---|
| 5699 | !(driveflags[toupper(*info->path) - 'A'] & | 
|---|
| 5700 | (DRIVE_IGNORE | DRIVE_INVALID))) { | 
|---|
| 5701 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 5702 | hDir = HDIR_CREATE; | 
|---|
| 5703 | ulSearchCount = 1; | 
|---|
| 5704 | if (!IsRoot(info->path)) | 
|---|
| 5705 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY | | 
|---|
| 5706 | MUST_HAVE_DIRECTORY | FILE_READONLY | | 
|---|
| 5707 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, | 
|---|
| 5708 | &findbuf, sizeof(FILEFINDBUF3), | 
|---|
| 5709 | &ulSearchCount, FIL_STANDARD); | 
|---|
| 5710 | else { | 
|---|
| 5711 | rc = 0; | 
|---|
| 5712 | findbuf.attrFile = FILE_DIRECTORY; | 
|---|
| 5713 | } | 
|---|
| 5714 | priority_bumped(); | 
|---|
| 5715 | if (!rc) { | 
|---|
| 5716 | if (!IsRoot(info->path)) | 
|---|
| 5717 | DosFindClose(hDir); | 
|---|
| 5718 | if (findbuf.attrFile & FILE_DIRECTORY) | 
|---|
| 5719 | WinSendMsg(hwndUserlist, LM_INSERTITEM, | 
|---|
| 5720 | MPFROM2SHORT(LIT_SORTASCENDING, 0), | 
|---|
| 5721 | MPFROMP(info->path)); | 
|---|
| 5722 | else { | 
|---|
| 5723 | temp = info->next; | 
|---|
| 5724 | remove_udir(info->path); | 
|---|
| 5725 | info = temp; | 
|---|
| 5726 | continue; | 
|---|
| 5727 | } | 
|---|
| 5728 | } | 
|---|
| 5729 | else if (!(ulDriveMap & (1L << (toupper(*info->path) - 'A')))) { | 
|---|
| 5730 | temp = info->next; | 
|---|
| 5731 | remove_udir(info->path); | 
|---|
| 5732 | info = temp; | 
|---|
| 5733 | continue; | 
|---|
| 5734 | } | 
|---|
| 5735 | } | 
|---|
| 5736 | info = info->next; | 
|---|
| 5737 | } | 
|---|
| 5738 | WinSendMsg(hwndUserlist, LM_INSERTITEM, | 
|---|
| 5739 | MPFROM2SHORT(0, 0), | 
|---|
| 5740 | MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT))); | 
|---|
| 5741 | WinSetWindowText(hwndUserlist, GetPString(IDS_COMMONDIRTEXT)); | 
|---|
| 5742 | } | 
|---|
| 5743 | return 0; | 
|---|
| 5744 |  | 
|---|
| 5745 | case UM_SIZE: | 
|---|
| 5746 | if (fAutoTile) | 
|---|
| 5747 | TileChildren(hwnd, FALSE); | 
|---|
| 5748 | else | 
|---|
| 5749 | MoveChildrenAwayFromTree(hwnd); | 
|---|
| 5750 | return 0; | 
|---|
| 5751 |  | 
|---|
| 5752 | case WM_SIZE: | 
|---|
| 5753 | ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), | 
|---|
| 5754 | SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); | 
|---|
| 5755 | break; | 
|---|
| 5756 |  | 
|---|
| 5757 | case WM_ERASEBACKGROUND: | 
|---|
| 5758 | WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0); | 
|---|
| 5759 | return 0; | 
|---|
| 5760 |  | 
|---|
| 5761 | case WM_PAINT: | 
|---|
| 5762 | { | 
|---|
| 5763 | HPS hps; | 
|---|
| 5764 | RECTL rcl; | 
|---|
| 5765 |  | 
|---|
| 5766 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL); | 
|---|
| 5767 | if (hps) { | 
|---|
| 5768 | WinQueryWindowRect(hwnd, &rcl); | 
|---|
| 5769 | WinFillRect(hps, &rcl, CLR_PALEGRAY); | 
|---|
| 5770 | WinEndPaint(hps); | 
|---|
| 5771 | } | 
|---|
| 5772 | } | 
|---|
| 5773 | break; | 
|---|
| 5774 |  | 
|---|
| 5775 | case UM_CONTROL: | 
|---|
| 5776 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 5777 | case MAIN_CMDLIST: | 
|---|
| 5778 | case MAIN_SETUPLIST: | 
|---|
| 5779 | case MAIN_DRIVELIST: | 
|---|
| 5780 | case MAIN_USERLIST: | 
|---|
| 5781 | case MAIN_BUTTONLIST: | 
|---|
| 5782 | switch (SHORT2FROMMP(mp1)) { | 
|---|
| 5783 | case CBN_ENTER: | 
|---|
| 5784 | { | 
|---|
| 5785 | HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5786 | SHORT1FROMMP(mp1)); | 
|---|
| 5787 | CHAR path[CCHMAXPATH]; | 
|---|
| 5788 | ULONG ul; | 
|---|
| 5789 |  | 
|---|
| 5790 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 5791 | case MAIN_USERLIST: | 
|---|
| 5792 | ul = CCHMAXPATH; | 
|---|
| 5793 | break; | 
|---|
| 5794 | case MAIN_SETUPLIST: | 
|---|
| 5795 | ul = STATE_NAME_MAX_BYTES; | 
|---|
| 5796 | break; | 
|---|
| 5797 | default: | 
|---|
| 5798 | ul = 13;                    // fixme to not be hardcoded | 
|---|
| 5799 | } | 
|---|
| 5800 |  | 
|---|
| 5801 | SetShiftState(); | 
|---|
| 5802 | WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path); | 
|---|
| 5803 | bstrip(path); | 
|---|
| 5804 | if (*path) { | 
|---|
| 5805 | if (SHORT1FROMMP(mp1) == MAIN_USERLIST) { | 
|---|
| 5806 | if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) { | 
|---|
| 5807 | if (!LastDir || | 
|---|
| 5808 | !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT), | 
|---|
| 5809 | UM_CONTAINERDIR, MPFROMP(path), MPVOID)) | 
|---|
| 5810 | save_dir2(path); | 
|---|
| 5811 | if (!PMMkDir(hwnd, path, TRUE)) { | 
|---|
| 5812 | WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT)); | 
|---|
| 5813 | break; | 
|---|
| 5814 | } | 
|---|
| 5815 | } | 
|---|
| 5816 | if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) { | 
|---|
| 5817 |  | 
|---|
| 5818 | HWND hwndDir; | 
|---|
| 5819 |  | 
|---|
| 5820 | if ((fUserListSwitches && | 
|---|
| 5821 | !(shiftstate & KC_SHIFT)) || | 
|---|
| 5822 | (!fUserListSwitches && (shiftstate & KC_SHIFT))) { | 
|---|
| 5823 | hwndDir = FindDirCnr(hwnd); | 
|---|
| 5824 | if (hwndDir) { | 
|---|
| 5825 | WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID); | 
|---|
| 5826 | break; | 
|---|
| 5827 | } | 
|---|
| 5828 | } | 
|---|
| 5829 | OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path); | 
|---|
| 5830 | } | 
|---|
| 5831 | } | 
|---|
| 5832 | else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) { | 
|---|
| 5833 | ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree, | 
|---|
| 5834 | FID_CLIENT), | 
|---|
| 5835 | TREE_CNR), path, FALSE, TRUE); | 
|---|
| 5836 | WinSetFocus(HWND_DESKTOP, hwndTree); | 
|---|
| 5837 | } | 
|---|
| 5838 | else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) { | 
|---|
| 5839 | strcat(path, ".TLS"); | 
|---|
| 5840 | load_tools(path); | 
|---|
| 5841 | PrfWriteProfileString(fmprof, | 
|---|
| 5842 | FM3Str, "LastToolBox", lasttoolbox); | 
|---|
| 5843 | BuildTools(hwndToolback, TRUE); | 
|---|
| 5844 | WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT)); | 
|---|
| 5845 | } | 
|---|
| 5846 | else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) { | 
|---|
| 5847 |  | 
|---|
| 5848 | CHAR szKey[80]; | 
|---|
| 5849 | ULONG size, numsaves = 0; | 
|---|
| 5850 |  | 
|---|
| 5851 | SetShiftState(); | 
|---|
| 5852 | size = sizeof(ULONG); | 
|---|
| 5853 | sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name | 
|---|
| 5854 | if (!PrfQueryProfileData(fmprof, | 
|---|
| 5855 | FM3Str, | 
|---|
| 5856 | szKey, | 
|---|
| 5857 | (PVOID)&numsaves, | 
|---|
| 5858 | &size)) | 
|---|
| 5859 | { | 
|---|
| 5860 | if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) { | 
|---|
| 5861 | saymsg(MB_ENTER | MB_ICONASTERISK, hwnd, | 
|---|
| 5862 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 5863 | GetPString(IDS_DOESNTEXISTTEXT), path); | 
|---|
| 5864 | } | 
|---|
| 5865 | else { | 
|---|
| 5866 | Win_Error2(hwnd, hwnd, __FILE__, __LINE__, | 
|---|
| 5867 | IDS_PRFQUERYPROFILEDATA); | 
|---|
| 5868 | } | 
|---|
| 5869 | } | 
|---|
| 5870 | else if (!numsaves) | 
|---|
| 5871 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); | 
|---|
| 5872 | else { | 
|---|
| 5873 | if ((shiftstate & KC_SHIFT) == 0) | 
|---|
| 5874 | PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2L)); | 
|---|
| 5875 | { | 
|---|
| 5876 | char *temp; | 
|---|
| 5877 |  | 
|---|
| 5878 | temp = xstrdup(path, pszSrcFile, __LINE__); | 
|---|
| 5879 | if (!temp) { | 
|---|
| 5880 | if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) | 
|---|
| 5881 | PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, | 
|---|
| 5882 | MPFROMLONG(1)); | 
|---|
| 5883 | } | 
|---|
| 5884 | else { | 
|---|
| 5885 | if (!PostMsg | 
|---|
| 5886 | (MainObjectHwnd, UM_RESTORE, MPFROMP(temp), MPVOID)) | 
|---|
| 5887 | free(temp); | 
|---|
| 5888 | } | 
|---|
| 5889 | } | 
|---|
| 5890 | } | 
|---|
| 5891 | // fixme to hold restored state name for a while | 
|---|
| 5892 | // WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));    // 15 Apr 07 SHL | 
|---|
| 5893 | } | 
|---|
| 5894 | else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) { | 
|---|
| 5895 |  | 
|---|
| 5896 | SHORT sSelect; | 
|---|
| 5897 |  | 
|---|
| 5898 | sSelect = (SHORT) WinSendMsg(hwndCmdlist, | 
|---|
| 5899 | LM_QUERYSELECTION, | 
|---|
| 5900 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
| 5901 | if (sSelect >= 0) | 
|---|
| 5902 | WinPostMsg(hwnd, | 
|---|
| 5903 | WM_COMMAND, | 
|---|
| 5904 | MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0), | 
|---|
| 5905 | MPVOID); | 
|---|
| 5906 | WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT)); | 
|---|
| 5907 | } | 
|---|
| 5908 | } | 
|---|
| 5909 | } | 
|---|
| 5910 | break; | 
|---|
| 5911 |  | 
|---|
| 5912 | default: | 
|---|
| 5913 | break; | 
|---|
| 5914 | } | 
|---|
| 5915 | break; | 
|---|
| 5916 |  | 
|---|
| 5917 | default: | 
|---|
| 5918 | break; | 
|---|
| 5919 | } | 
|---|
| 5920 | return 0; | 
|---|
| 5921 |  | 
|---|
| 5922 | case WM_HELP: | 
|---|
| 5923 | WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID); | 
|---|
| 5924 | break; | 
|---|
| 5925 |  | 
|---|
| 5926 | case UM_COMMAND: | 
|---|
| 5927 | case WM_COMMAND: | 
|---|
| 5928 |  | 
|---|
| 5929 | return MainWMCommand(hwnd, msg, mp1, mp2); | 
|---|
| 5930 |  | 
|---|
| 5931 | case WM_CLOSE: | 
|---|
| 5932 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5933 | WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID); | 
|---|
| 5934 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID); | 
|---|
| 5935 | fAmClosing = TRUE; | 
|---|
| 5936 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 5937 | WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID); | 
|---|
| 5938 | if (CloseChildren(hwnd)) { | 
|---|
| 5939 | fAmClosing = FALSE; | 
|---|
| 5940 | if (fAutoTile) | 
|---|
| 5941 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID); | 
|---|
| 5942 | return 0; | 
|---|
| 5943 | } | 
|---|
| 5944 | if (hwndTree) { | 
|---|
| 5945 | if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID)) | 
|---|
| 5946 | WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 5947 | } | 
|---|
| 5948 | DosSleep(1); | 
|---|
| 5949 | return 0;                           // Hold off WM_QUIT | 
|---|
| 5950 |  | 
|---|
| 5951 | case UM_CLOSE: | 
|---|
| 5952 | HideNote(); | 
|---|
| 5953 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 5954 | return 0; | 
|---|
| 5955 |  | 
|---|
| 5956 | case UM_RESTORE: | 
|---|
| 5957 | { | 
|---|
| 5958 | char *temp; | 
|---|
| 5959 |  | 
|---|
| 5960 | temp = xstrdup(GetPString(IDS_FM2TEMPTEXT), pszSrcFile, __LINE__); | 
|---|
| 5961 | if (temp) { | 
|---|
| 5962 | if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(temp), MPVOID)) | 
|---|
| 5963 | free(temp); | 
|---|
| 5964 | } | 
|---|
| 5965 | } | 
|---|
| 5966 | return 0; | 
|---|
| 5967 |  | 
|---|
| 5968 | case UM_SETDIR: | 
|---|
| 5969 | /* mp1 == name of directory to open */ | 
|---|
| 5970 | if (mp1) | 
|---|
| 5971 | return MRFROMLONG(OpenDirCnr((HWND) 0, | 
|---|
| 5972 | hwndMain, | 
|---|
| 5973 | hwndTree, (BOOL) mp2, (char *)mp1)); | 
|---|
| 5974 | return 0; | 
|---|
| 5975 |  | 
|---|
| 5976 | case WM_DESTROY: | 
|---|
| 5977 | hwndMain = (HWND) 0; | 
|---|
| 5978 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID)) | 
|---|
| 5979 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID); | 
|---|
| 5980 | break; | 
|---|
| 5981 | } | 
|---|
| 5982 |  | 
|---|
| 5983 | return WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 5984 | } | 
|---|
| 5985 |  | 
|---|
| 5986 | #pragma alloc_text(MISC8,SetToggleChecks,FindDirCnrByName,TopWindow) | 
|---|
| 5987 | #pragma alloc_text(MISC8,TopWindowName,CountDirCnrs) | 
|---|
| 5988 | #pragma alloc_text(MAINWND,AdjustSizeOfClient,FillClient,ChildButtonProc) | 
|---|
| 5989 | #pragma alloc_text(MAINWND,ToolBackProc,StatusProc) | 
|---|
| 5990 | #pragma alloc_text(MAINWND,MoveChildrenAwayFromTree,ArrangeIcons,NextChild) | 
|---|
| 5991 | #pragma alloc_text(MAINWND,ChildFrameButtonProc) | 
|---|
| 5992 | #pragma alloc_text(MAINWND2,CloseChildren,CountChildren,GetNextWindowPos) | 
|---|
| 5993 | #pragma alloc_text(MAINWND2,CascadeChildren,TileChildren,ResizeChildren) | 
|---|
| 5994 | #pragma alloc_text(MAINWND2,MinResChildren,MainFrameWndProc,MainWndProc) | 
|---|
| 5995 | #pragma alloc_text(MAINWND2,DropDownListProc) | 
|---|
| 5996 | #pragma alloc_text(MAINWND3,RestoreDirCnrState,SaveDirCnrState) | 
|---|
| 5997 | #pragma alloc_text(MAINWND3,CloseDirCnrChildren,TransformSwp) | 
|---|
| 5998 | #pragma alloc_text(MAINWND3,ResizeTools,BuildTools,CommandLineProc) | 
|---|
| 5999 | #pragma alloc_text(MAINWND4,DriveProc,DriveBackProc,BuildDriveBarButtons,ResizeDrives) | 
|---|
| 6000 | #pragma alloc_text(MAINWND4,LEDProc,IdealButtonProc) | 
|---|
| 6001 | #pragma alloc_text(MAINWND5,MainWMOnce) | 
|---|
| 6002 | #pragma alloc_text(MAINWND6,MainWMCommand) | 
|---|
| 6003 | #pragma alloc_text(BUBBLE,MakeBubble,BubbleProc,BubbleHelp) | 
|---|
| 6004 | #pragma alloc_text(MAINOBJ,MainObjectWndProc,MakeMainObjWin) | 
|---|
| 6005 |  | 
|---|