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