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