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