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