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