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