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