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