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