source: trunk/dll/mainwnd.c@ 1178

Last change on this file since 1178 was 1158, checked in by John Small, 17 years ago

Ticket 187: Draft 1: Functions only

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