1 | /***********************************************************************
|
---|
2 |
|
---|
3 | $Id: treecnr.c 689 2007-06-15 06:33:24Z stevenhl $
|
---|
4 |
|
---|
5 | Tree containers
|
---|
6 |
|
---|
7 | Copyright (c) 1993-98 M. Kimes
|
---|
8 | Copyright (c) 2001, 2007 Steven H. Levine
|
---|
9 |
|
---|
10 | 16 Oct 02 SHL Handle large partitions
|
---|
11 | 11 Jun 03 SHL Add JFS and FAT32 support
|
---|
12 | 25 May 05 SHL Rename comnam to szCommonName and fix typo
|
---|
13 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL
|
---|
14 | 26 May 05 SHL More large file formatting updates
|
---|
15 | 05 Jun 05 SHL Use QWL_USER
|
---|
16 | 06 Aug 05 SHL Renames
|
---|
17 | 08 Dec 05 SHL TreeCnrWndProc: disable menu items if drive not ready
|
---|
18 | 17 Jul 06 SHL Use Runtime_Error
|
---|
19 | 15 Aug 06 SHL Rework SetMask args
|
---|
20 | 31 Aug 06 JS Add more partitioning menu items
|
---|
21 | 22 OCT 06 GKY Add NDFS32 support
|
---|
22 | 29 Dec 06 GKY Fixed menu gray out for remote drives (added variable "remote")
|
---|
23 | 29 Dec 06 GKY Enabled edit of drive flags on "not ready" drives
|
---|
24 | 18 Feb 07 GKY More drive type and icon support
|
---|
25 | 08 Mar 07 SHL Ensure drive icon updates after drive flags change
|
---|
26 | 09 Mar 07 GKY Use SelectDriveIcon
|
---|
27 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
28 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
|
---|
29 | 06 Apr 07 GKY Add some error checking in drag/drop
|
---|
30 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
|
---|
31 | 19 Apr 07 SHL Add more drag/drop error checking
|
---|
32 | 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
|
---|
33 | 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
|
---|
34 | 10 Jun 07 GKY Mouse button 3 white space click to fail silently
|
---|
35 |
|
---|
36 | ***********************************************************************/
|
---|
37 |
|
---|
38 | #define INCL_DOS
|
---|
39 | #define INCL_WIN
|
---|
40 | #define INCL_GPI
|
---|
41 | #define INCL_DOSERRORS
|
---|
42 | #define INCL_LONGLONG
|
---|
43 | #include <os2.h>
|
---|
44 |
|
---|
45 | #include <stdarg.h>
|
---|
46 | #include <stdio.h>
|
---|
47 | #include <stdlib.h>
|
---|
48 | #include <string.h>
|
---|
49 | #include <ctype.h>
|
---|
50 | #include <process.h> // _beginthread
|
---|
51 |
|
---|
52 | #include "fm3dll.h"
|
---|
53 | #include "fm3dlg.h"
|
---|
54 | #include "fm3str.h"
|
---|
55 | #include "mle.h"
|
---|
56 |
|
---|
57 | #pragma data_seg(DATA1)
|
---|
58 |
|
---|
59 | static PSZ pszSrcFile = __FILE__;
|
---|
60 |
|
---|
61 | #pragma alloc_text(TREECNR,TreeCnrWndProc,TreeObjWndProc,TreeClientWndProc)
|
---|
62 | #pragma alloc_text(TREECNR,TreeFrameWndProc,TreeTitleWndProc,ShowTreeRec)
|
---|
63 | #pragma alloc_text(TREECNR,TreeStatProc,OpenButtonProc)
|
---|
64 | #pragma alloc_text(STARTUP,StartTreeCnr)
|
---|
65 |
|
---|
66 | APIRET16 APIENTRY16 Dos16MemAvail(PULONG pulAvailMem);
|
---|
67 |
|
---|
68 | typedef struct APPNOTIFY
|
---|
69 | {
|
---|
70 | HAPP happ;
|
---|
71 | CHAR device;
|
---|
72 | struct APPNOTIFY *next;
|
---|
73 | struct APPNOTIFY *prev;
|
---|
74 | }
|
---|
75 | APPNOTIFY;
|
---|
76 |
|
---|
77 | MRESULT EXPENTRY OpenButtonProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
78 | {
|
---|
79 | static BOOL emphasized = FALSE;
|
---|
80 |
|
---|
81 | switch (msg) {
|
---|
82 | case WM_CREATE:
|
---|
83 | {
|
---|
84 | MRESULT rc;
|
---|
85 |
|
---|
86 | rc = PFNWPButton(hwnd, msg, mp1, mp2);
|
---|
87 | WinSetPresParam(hwnd, PP_FONTNAMESIZE,
|
---|
88 | strlen(GetPString(IDS_8TIMESNEWROMANTEXT)) + 1,
|
---|
89 | (PVOID) GetPString(IDS_8TIMESNEWROMANTEXT));
|
---|
90 | return rc;
|
---|
91 | }
|
---|
92 |
|
---|
93 | case WM_MOUSEMOVE:
|
---|
94 | BubbleHelp(hwnd, TRUE, FALSE, TRUE, GetPString(IDS_OPENBUTTONHELP));
|
---|
95 | break;
|
---|
96 |
|
---|
97 | case WM_CONTEXTMENU:
|
---|
98 | PostMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
99 | WM_COMMAND, MPFROM2SHORT(IDM_OPENWALK, 0), MPVOID);
|
---|
100 | return 0;
|
---|
101 |
|
---|
102 | case DM_DRAGOVER:
|
---|
103 | if (!emphasized) {
|
---|
104 | emphasized = TRUE;
|
---|
105 | EmphasizeButton(hwnd, emphasized);
|
---|
106 | }
|
---|
107 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
108 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
109 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
110 |
|
---|
111 | case DM_DRAGLEAVE:
|
---|
112 | if (emphasized) {
|
---|
113 | emphasized = FALSE;
|
---|
114 | EmphasizeButton(hwnd, emphasized);
|
---|
115 | }
|
---|
116 | break;
|
---|
117 |
|
---|
118 | case DM_DROPHELP:
|
---|
119 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_OPENDROPHELP));
|
---|
120 | return 0;
|
---|
121 |
|
---|
122 | case DM_DROP:
|
---|
123 | {
|
---|
124 | char szFrom[CCHMAXPATH + 2];
|
---|
125 |
|
---|
126 | if (emphasized) {
|
---|
127 | emphasized = FALSE;
|
---|
128 | EmphasizeButton(hwnd, emphasized);
|
---|
129 | }
|
---|
130 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
|
---|
131 | MakeValidDir(szFrom);
|
---|
132 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
133 | UM_OPENWINDOWFORME, MPFROMP(szFrom), MPVOID);
|
---|
134 | }
|
---|
135 | }
|
---|
136 | return 0;
|
---|
137 |
|
---|
138 | }
|
---|
139 | return PFNWPButton(hwnd, msg, mp1, mp2);
|
---|
140 | }
|
---|
141 |
|
---|
142 | VOID ShowTreeRec(HWND hwndCnr, CHAR * dirname, BOOL collapsefirst,
|
---|
143 | BOOL maketop)
|
---|
144 | {
|
---|
145 | /* Find a record in tree view, move it so it shows in container and
|
---|
146 | make it the current record */
|
---|
147 |
|
---|
148 | PCNRITEM pci, pciToSelect, pciP;
|
---|
149 | BOOL quickbail = FALSE;
|
---|
150 | CHAR szDir[CCHMAXPATH], *p;
|
---|
151 |
|
---|
152 | /* is it already the current record? */
|
---|
153 | pci = WinSendMsg(hwndCnr,
|
---|
154 | CM_QUERYRECORDEMPHASIS,
|
---|
155 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
---|
156 | if (pci && (INT) pci != -1 && !stricmp(pci->szFileName, dirname)) {
|
---|
157 | quickbail = TRUE;
|
---|
158 | goto MakeTop; /* skip lookup bullsh*t */
|
---|
159 | }
|
---|
160 | WinEnableWindowUpdate(hwndCnr, FALSE);
|
---|
161 | pci = FindCnrRecord(hwndCnr, dirname, NULL, TRUE, FALSE, TRUE);
|
---|
162 | if (!pci || (INT) pci == -1) {
|
---|
163 | *szDir = *dirname;
|
---|
164 | szDir[1] = ':';
|
---|
165 | szDir[2] = '\\';
|
---|
166 | szDir[3] = 0;
|
---|
167 | p = szDir + 3;
|
---|
168 | for (;;) {
|
---|
169 | pciP = FindCnrRecord(hwndCnr, szDir, NULL, TRUE, FALSE, TRUE);
|
---|
170 | if (pciP && (INT) pciP != -1) {
|
---|
171 | if (!stricmp(dirname, pciP->szFileName))
|
---|
172 | break;
|
---|
173 | if (!(pciP->rc.flRecordAttr & CRA_EXPANDED))
|
---|
174 | WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
|
---|
175 | strcpy(szDir, dirname);
|
---|
176 | if (p - szDir >= strlen(szDir))
|
---|
177 | break;
|
---|
178 | p = strchr(p, '\\');
|
---|
179 | if (p) {
|
---|
180 | *p = 0;
|
---|
181 | p++;
|
---|
182 | }
|
---|
183 | else
|
---|
184 | break;
|
---|
185 | }
|
---|
186 | else
|
---|
187 | break;
|
---|
188 | DosSleep(0L);
|
---|
189 | }
|
---|
190 | pci = FindCnrRecord(hwndCnr, dirname, NULL, TRUE, FALSE, TRUE);
|
---|
191 | }
|
---|
192 | if (pci && (INT) pci != -1) {
|
---|
193 | if (!(pci->rc.flRecordAttr & CRA_CURSORED)) {
|
---|
194 | if (collapsefirst) {
|
---|
195 | /* collapse top level of all branches */
|
---|
196 | pciP = WinSendMsg(hwndCnr,
|
---|
197 | CM_QUERYRECORD,
|
---|
198 | MPVOID, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
|
---|
199 | while (pciP && (INT) pciP != -1) {
|
---|
200 | if (toupper(*pciP->szFileName) == toupper(*dirname))
|
---|
201 | /* collapse all levels if branch is our drive */
|
---|
202 | ExpandAll(hwndCnr, FALSE, pciP);
|
---|
203 | else if (pciP->rc.flRecordAttr & CRA_EXPANDED)
|
---|
204 | WinSendMsg(hwndCnr, CM_COLLAPSETREE, MPFROMP(pciP), MPVOID);
|
---|
205 | pciP = WinSendMsg(hwndCnr,
|
---|
206 | CM_QUERYRECORD,
|
---|
207 | MPFROMP(pciP),
|
---|
208 | MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
|
---|
209 | }
|
---|
210 | }
|
---|
211 | /* expand all parent branches */
|
---|
212 | pciToSelect = pci;
|
---|
213 | for (;;) {
|
---|
214 | pciP = WinSendMsg(hwndCnr,
|
---|
215 | CM_QUERYRECORD,
|
---|
216 | MPFROMP(pciToSelect),
|
---|
217 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
|
---|
218 | if (pciP && (INT) pciP != -1) {
|
---|
219 | if (!(pciP->rc.flRecordAttr & CRA_EXPANDED))
|
---|
220 | WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciP), MPVOID);
|
---|
221 | pciToSelect = pciP;
|
---|
222 | }
|
---|
223 | else
|
---|
224 | break;
|
---|
225 | DosSleep(0L);
|
---|
226 | }
|
---|
227 | }
|
---|
228 | /* make record visible */
|
---|
229 | MakeTop:
|
---|
230 | pciToSelect = pci;
|
---|
231 | if (pciToSelect && (INT) pciToSelect != -1) {
|
---|
232 | if (fTopDir || maketop)
|
---|
233 | ShowCnrRecord(hwndCnr, (PMINIRECORDCORE) pciToSelect);
|
---|
234 | if (fSwitchTreeExpand && !(pciToSelect->rc.flRecordAttr & CRA_EXPANDED))
|
---|
235 | WinSendMsg(hwndCnr, CM_EXPANDTREE, MPFROMP(pciToSelect), MPVOID);
|
---|
236 | if (quickbail) {
|
---|
237 | WinEnableWindowUpdate(hwndCnr, TRUE);
|
---|
238 | return;
|
---|
239 | }
|
---|
240 | WinSendMsg(hwndCnr,
|
---|
241 | CM_SETRECORDEMPHASIS,
|
---|
242 | MPFROMP(pciToSelect),
|
---|
243 | MPFROM2SHORT(TRUE, CRA_SELECTED | CRA_CURSORED));
|
---|
244 | }
|
---|
245 | }
|
---|
246 | WinEnableWindowUpdate(hwndCnr, TRUE);
|
---|
247 | }
|
---|
248 |
|
---|
249 | MRESULT EXPENTRY TreeTitleWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
250 | MPARAM mp2)
|
---|
251 | {
|
---|
252 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
253 |
|
---|
254 | switch (msg) {
|
---|
255 | case WM_CONTEXTMENU:
|
---|
256 | return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
|
---|
257 | UM_CONTEXTMENU, mp1, mp2);
|
---|
258 | }
|
---|
259 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
260 | }
|
---|
261 |
|
---|
262 | MRESULT EXPENTRY TreeStatProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
263 | {
|
---|
264 | switch (msg) {
|
---|
265 | case WM_CREATE:
|
---|
266 | return CommonTextProc(hwnd, msg, mp1, mp2);
|
---|
267 |
|
---|
268 | case WM_CONTEXTMENU:
|
---|
269 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), msg, mp1, mp2);
|
---|
270 | return 0;
|
---|
271 |
|
---|
272 | case WM_PAINT:
|
---|
273 | {
|
---|
274 | MRESULT mr = PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
275 |
|
---|
276 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
|
---|
277 | return mr;
|
---|
278 | }
|
---|
279 |
|
---|
280 | case WM_SETFOCUS:
|
---|
281 | if (mp2)
|
---|
282 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
283 | break;
|
---|
284 |
|
---|
285 | case UM_FOCUSME:
|
---|
286 | WinSetFocus(HWND_DESKTOP, WinQueryWindow(hwnd, QW_PARENT));
|
---|
287 | return 0;
|
---|
288 | }
|
---|
289 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
290 | }
|
---|
291 |
|
---|
292 | MRESULT EXPENTRY TreeFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
293 | MPARAM mp2)
|
---|
294 | {
|
---|
295 | switch (msg) {
|
---|
296 | case UM_RESCAN:
|
---|
297 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), msg, mp1, mp2);
|
---|
298 | return 0;
|
---|
299 |
|
---|
300 | case WM_ADJUSTWINDOWPOS:
|
---|
301 | {
|
---|
302 | SWP *pswp;
|
---|
303 |
|
---|
304 | pswp = (SWP *) mp1;
|
---|
305 | if (ParentIsDesktop(hwnd, (HWND) 0)) {
|
---|
306 | if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
|
---|
307 | HideNote();
|
---|
308 | }
|
---|
309 | }
|
---|
310 | break;
|
---|
311 |
|
---|
312 | case WM_TRACKFRAME:
|
---|
313 | if (!fFreeTree && !ParentIsDesktop(hwnd, (HWND) 0)) {
|
---|
314 | switch (SHORT1FROMMP(mp1) & TF_MOVE) {
|
---|
315 | case TF_MOVE:
|
---|
316 | case TF_LEFT:
|
---|
317 | case TF_TOP:
|
---|
318 | case (TF_LEFT | TF_BOTTOM):
|
---|
319 | case (TF_LEFT | TF_TOP):
|
---|
320 | {
|
---|
321 | SWP swp;
|
---|
322 |
|
---|
323 | WinQueryWindowPos(hwnd, &swp);
|
---|
324 | if (!(swp.fl & SWP_ACTIVATE))
|
---|
325 | WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
|
---|
326 | SWP_ZORDER | SWP_ACTIVATE);
|
---|
327 | }
|
---|
328 | return 0;
|
---|
329 | }
|
---|
330 | }
|
---|
331 | break;
|
---|
332 |
|
---|
333 | case WM_CALCFRAMERECT:
|
---|
334 | if (*(ULONG *) realappname != FM3UL) {
|
---|
335 |
|
---|
336 | MRESULT mr;
|
---|
337 | PRECTL prectl;
|
---|
338 |
|
---|
339 | mr = CommonFrameWndProc(TREE_CNR, hwnd, msg, mp1, mp2);
|
---|
340 |
|
---|
341 | /*
|
---|
342 | * Calculate the position of the client rectangle.
|
---|
343 | * Otherwise, we'll see a lot of redraw when we move the
|
---|
344 | * client during WM_FORMATFRAME.
|
---|
345 | */
|
---|
346 |
|
---|
347 | if (mr && mp2) {
|
---|
348 | prectl = (PRECTL) mp1;
|
---|
349 | prectl->yTop -= 22;
|
---|
350 | }
|
---|
351 | return mr;
|
---|
352 | }
|
---|
353 | break;
|
---|
354 |
|
---|
355 | case WM_FORMATFRAME:
|
---|
356 | {
|
---|
357 | SHORT sCount;
|
---|
358 | PSWP pswp, pswpClient, pswpNew;
|
---|
359 |
|
---|
360 | sCount = (SHORT) CommonFrameWndProc(TREE_CNR, hwnd, msg, mp1, mp2);
|
---|
361 |
|
---|
362 | /*
|
---|
363 | * Reformat the frame to "squeeze" the client
|
---|
364 | */
|
---|
365 |
|
---|
366 | pswp = (PSWP) mp1;
|
---|
367 | {
|
---|
368 | SHORT x;
|
---|
369 |
|
---|
370 | for (x = 0; x < sCount; x++) {
|
---|
371 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
|
---|
372 | pswpClient = pswp;
|
---|
373 | break;
|
---|
374 | }
|
---|
375 | pswp++;
|
---|
376 | }
|
---|
377 | }
|
---|
378 | pswpNew = (PSWP) mp1 + sCount;
|
---|
379 | *pswpNew = *pswpClient;
|
---|
380 | pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_STATUS);
|
---|
381 | if (*(ULONG *) realappname == FM3UL) {
|
---|
382 |
|
---|
383 | PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
|
---|
384 | SHORT x;
|
---|
385 |
|
---|
386 | pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWINDOW);
|
---|
387 | pswp = (PSWP) mp1;
|
---|
388 | for (x = 0; x < sCount; x++) {
|
---|
389 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
|
---|
390 | pswpTitlebar = pswp;
|
---|
391 | else if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
|
---|
392 | pswpMinbutton = pswp;
|
---|
393 | if (pswpTitlebar && pswpMinbutton)
|
---|
394 | break;
|
---|
395 | pswp++;
|
---|
396 | }
|
---|
397 | pswpNew->cy = pswpMinbutton->cy + 3;
|
---|
398 | pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
|
---|
399 | pswpTitlebar->cx -= (pswpNew->cx + 1);
|
---|
400 | pswpNew->x = pswpTitlebar->x + pswpTitlebar->cx;
|
---|
401 | pswpNew->y = pswpMinbutton->y - 1;
|
---|
402 | }
|
---|
403 | else {
|
---|
404 | pswpNew->x = pswpClient->x + 3;
|
---|
405 | pswpNew->y = (pswpClient->y + pswpClient->cy) - 20;
|
---|
406 | pswpNew->cx = pswpClient->cx - 6;
|
---|
407 | pswpNew->cy = 18;
|
---|
408 | pswpClient->cy -= 22;
|
---|
409 | }
|
---|
410 | sCount++;
|
---|
411 | return MRFROMSHORT(sCount);
|
---|
412 | }
|
---|
413 |
|
---|
414 | case WM_QUERYFRAMECTLCOUNT:
|
---|
415 | {
|
---|
416 | SHORT sCount;
|
---|
417 |
|
---|
418 | sCount = (SHORT) CommonFrameWndProc(TREE_CNR, hwnd, msg, mp1, mp2);
|
---|
419 | sCount++;
|
---|
420 | return MRFROMSHORT(sCount);
|
---|
421 | }
|
---|
422 | }
|
---|
423 | return CommonFrameWndProc(TREE_CNR, hwnd, msg, mp1, mp2);
|
---|
424 | }
|
---|
425 |
|
---|
426 | MRESULT EXPENTRY TreeClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
427 | MPARAM mp2)
|
---|
428 | {
|
---|
429 |
|
---|
430 | switch (msg) {
|
---|
431 | case UM_CONTAINERHWND:
|
---|
432 | return MRFROMLONG(WinWindowFromID(hwnd, TREE_CNR));
|
---|
433 |
|
---|
434 | case UM_VIEWSMENU:
|
---|
435 | return MRFROMLONG(CheckMenu(&TreeCnrMenu, TREECNR_POPUP));
|
---|
436 |
|
---|
437 | case UM_TIMER:
|
---|
438 | case UM_ACTION:
|
---|
439 | case UM_SHOWME:
|
---|
440 | case UM_OPENWINDOWFORME:
|
---|
441 | case UM_MINIMIZE:
|
---|
442 | case UM_MAXIMIZE:
|
---|
443 | case WM_INITMENU:
|
---|
444 | case UM_INITMENU:
|
---|
445 | case UM_FILTER:
|
---|
446 | case UM_FILESMENU:
|
---|
447 | case UM_UPDATERECORD:
|
---|
448 | case UM_UPDATERECORDLIST:
|
---|
449 | case MM_PORTHOLEINIT:
|
---|
450 | case UM_DRIVECMD:
|
---|
451 | case WM_CLOSE:
|
---|
452 | case WM_CONTROL:
|
---|
453 | case UM_COMMAND:
|
---|
454 | case WM_COMMAND:
|
---|
455 | return WinSendMsg(WinWindowFromID(hwnd, TREE_CNR), msg, mp1, mp2);
|
---|
456 |
|
---|
457 | case WM_PSETFOCUS:
|
---|
458 | case WM_SETFOCUS:
|
---|
459 | if (mp2)
|
---|
460 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
461 | break;
|
---|
462 |
|
---|
463 | case UM_FOCUSME:
|
---|
464 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, TREE_CNR));
|
---|
465 | break;
|
---|
466 |
|
---|
467 | case WM_ERASEBACKGROUND:
|
---|
468 | WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
|
---|
469 | return 0;
|
---|
470 |
|
---|
471 | case WM_PAINT:
|
---|
472 | {
|
---|
473 | HPS hps;
|
---|
474 | RECTL rcl;
|
---|
475 |
|
---|
476 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
|
---|
477 | if (hps) {
|
---|
478 | WinQueryWindowRect(hwnd, &rcl);
|
---|
479 | WinFillRect(hps, &rcl, CLR_PALEGRAY);
|
---|
480 | PaintRecessedWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
481 | MAIN_STATUS), hps, FALSE, FALSE);
|
---|
482 | WinEndPaint(hps);
|
---|
483 | }
|
---|
484 | }
|
---|
485 | break;
|
---|
486 |
|
---|
487 | case WM_SIZE:
|
---|
488 | WinSetWindowPos(WinWindowFromID(hwnd, TREE_CNR),
|
---|
489 | HWND_TOP,
|
---|
490 | 0,
|
---|
491 | 0,
|
---|
492 | SHORT1FROMMP(mp2),
|
---|
493 | SHORT2FROMMP(mp2), SWP_SHOW | SWP_MOVE | SWP_SIZE);
|
---|
494 | if (hwndMain)
|
---|
495 | PostMsg(hwndMain, UM_SIZE, MPVOID, MPVOID);
|
---|
496 | break;
|
---|
497 |
|
---|
498 | case WM_CONTEXTMENU:
|
---|
499 | case UM_CONTEXTMENU:
|
---|
500 | PostMsg(WinWindowFromID(hwnd, TREE_CNR),
|
---|
501 | WM_CONTROL, MPFROM2SHORT(TREE_CNR, CN_CONTEXTMENU), MPVOID);
|
---|
502 | return 0;
|
---|
503 | }
|
---|
504 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
505 | }
|
---|
506 |
|
---|
507 | MRESULT EXPENTRY TreeObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
508 | {
|
---|
509 | DIRCNRDATA *dcd;
|
---|
510 | DIRCNRDATA *dcdsrc;
|
---|
511 |
|
---|
512 | switch (msg) {
|
---|
513 | case WM_CREATE:
|
---|
514 | break;
|
---|
515 |
|
---|
516 | case UM_SHOWME:
|
---|
517 | if (mp1) {
|
---|
518 | dcd = INSTDATA(hwnd);
|
---|
519 | if (dcd) {
|
---|
520 | BOOL tempsusp, tempfollow, temptop;
|
---|
521 |
|
---|
522 | tempsusp = dcd->suspendview;
|
---|
523 | dcd->suspendview = TRUE;
|
---|
524 | tempfollow = fFollowTree;
|
---|
525 | fFollowTree = FALSE;
|
---|
526 | if (mp2) {
|
---|
527 | temptop = fTopDir;
|
---|
528 | fTopDir = TRUE;
|
---|
529 | }
|
---|
530 | ShowTreeRec(dcd->hwndCnr, (CHAR *) mp1, fCollapseFirst, TRUE);
|
---|
531 | dcd->suspendview = tempsusp;
|
---|
532 | fFollowTree = tempfollow;
|
---|
533 | if (mp2)
|
---|
534 | fTopDir = temptop;
|
---|
535 | }
|
---|
536 | free((CHAR *) mp1);
|
---|
537 | }
|
---|
538 | return 0;
|
---|
539 |
|
---|
540 | case DM_PRINTOBJECT:
|
---|
541 | return MRFROMLONG(DRR_TARGET);
|
---|
542 |
|
---|
543 | case DM_DISCARDOBJECT:
|
---|
544 | dcd = INSTDATA(hwnd);
|
---|
545 | if (fFM2Deletes && dcd) {
|
---|
546 |
|
---|
547 | LISTINFO *li;
|
---|
548 | CNRDRAGINFO cni;
|
---|
549 |
|
---|
550 | cni.pRecord = NULL;
|
---|
551 | cni.pDragInfo = (PDRAGINFO) mp1;
|
---|
552 | li = DoFileDrop(dcd->hwndCnr,
|
---|
553 | dcd->directory, FALSE, MPVOID, MPFROMP(&cni));
|
---|
554 | CheckPmDrgLimit(cni.pDragInfo);
|
---|
555 | if (li) {
|
---|
556 | li->type = ((fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE);
|
---|
557 | if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
|
---|
558 | FreeListInfo(li);
|
---|
559 | else
|
---|
560 | return MRFROMLONG(DRR_SOURCE);
|
---|
561 | }
|
---|
562 | }
|
---|
563 | return MRFROMLONG(DRR_TARGET);
|
---|
564 |
|
---|
565 | case UM_EXPAND:
|
---|
566 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
567 | if (!dcd)
|
---|
568 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
569 | else {
|
---|
570 | BOOL tempsusp = dcd->suspendview;
|
---|
571 |
|
---|
572 | dcd->suspendview = TRUE;
|
---|
573 | ExpandAll(dcd->hwndCnr,
|
---|
574 | (SHORT1FROMMP(mp1) == IDM_EXPAND), (PCNRITEM) mp2);
|
---|
575 | dcd->suspendview = tempsusp;
|
---|
576 | PostMsg(dcd->hwndCnr, UM_FILTER, MPVOID, MPVOID);
|
---|
577 | }
|
---|
578 | return 0;
|
---|
579 |
|
---|
580 | case UM_UPDATERECORDLIST:
|
---|
581 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
582 | if (!dcd || !mp1)
|
---|
583 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
584 | else {
|
---|
585 | INT numentries = 0;
|
---|
586 | CHAR **list = (CHAR **) mp1;
|
---|
587 |
|
---|
588 | while (list[numentries])
|
---|
589 | numentries++;
|
---|
590 | if (numentries)
|
---|
591 | UpdateCnrList(dcd->hwndCnr, list, numentries, TRUE, dcd);
|
---|
592 | }
|
---|
593 | return 0;
|
---|
594 |
|
---|
595 | case UM_SETUP:
|
---|
596 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
597 | if (!dcd)
|
---|
598 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
599 | else {
|
---|
600 | dcd->hwndObject = hwnd;
|
---|
601 | if (ParentIsDesktop(hwnd, dcd->hwndParent))
|
---|
602 | DosSleep(250L);
|
---|
603 | }
|
---|
604 | return 0;
|
---|
605 |
|
---|
606 | case UM_RESCAN2:
|
---|
607 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
608 | if (!dcd)
|
---|
609 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
610 | // Bypass if not running integrated (i.e if vtree)
|
---|
611 | else if (hwndStatus &&
|
---|
612 | dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
---|
613 | CHAR s[CCHMAXPATH * 2];
|
---|
614 | PCNRITEM pci = (PCNRITEM) mp1;
|
---|
615 | FSALLOCATE fsa;
|
---|
616 | struct
|
---|
617 | {
|
---|
618 | ULONG serial;
|
---|
619 | CHAR volumelength;
|
---|
620 | CHAR volumelabel[CCHMAXPATH];
|
---|
621 | }
|
---|
622 | volser;
|
---|
623 | CHAR tb[64];
|
---|
624 | CHAR szFree[64];
|
---|
625 | CNRINFO cnri;
|
---|
626 |
|
---|
627 | strcpy(s, GetPString(IDS_TREETEXT));
|
---|
628 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
629 | cnri.cb = sizeof(CNRINFO);
|
---|
630 | WinSendMsg(dcd->hwndCnr,
|
---|
631 | CM_QUERYCNRINFO,
|
---|
632 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
633 | if (cnri.cRecords) {
|
---|
634 | sprintf(s, GetPString(IDS_NUMDRIVESTEXT), cnri.cRecords);
|
---|
635 | if (pci) {
|
---|
636 | if (!(driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
637 | DRIVE_REMOVABLE) ||
|
---|
638 | driveserial[toupper(*pci->szFileName) - 'A'] != -1) {
|
---|
639 | memset(&volser, 0, sizeof(volser));
|
---|
640 | DosError(FERR_DISABLEHARDERR);
|
---|
641 | if (!DosQueryFSInfo(toupper(*pci->szFileName) - '@',
|
---|
642 | FSIL_VOLSER,
|
---|
643 | &volser,
|
---|
644 | (ULONG) sizeof(volser)) &&
|
---|
645 | dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
---|
646 | DosError(FERR_DISABLEHARDERR);
|
---|
647 | if (!DosQueryFSInfo(toupper(*pci->szFileName) - '@',
|
---|
648 | FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
|
---|
649 | CommaFmtULL(tb, sizeof(tb),
|
---|
650 | (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit *
|
---|
651 | fsa.cbSector), 'M');
|
---|
652 | sprintf(szFree, " %s %s", tb, GetPString(IDS_FREETEXT));
|
---|
653 | }
|
---|
654 | else
|
---|
655 | *szFree = 0;
|
---|
656 | driveserial[toupper(*pci->szFileName) - 'A'] = volser.serial;
|
---|
657 | sprintf(&s[strlen(s)],
|
---|
658 | GetPString(IDS_TREESTATUSSTARTTEXT),
|
---|
659 | toupper(*pci->szFileName),
|
---|
660 | volser.volumelabel, volser.serial, szFree);
|
---|
661 | if (!fMoreButtons) {
|
---|
662 | if (*dcd->mask.szMask ||
|
---|
663 | (dcd->mask.attrFile != ALLATTRS ||
|
---|
664 | ((fFilesInTree ||
|
---|
665 | (driveflags[toupper(*pci->szFileName)] &
|
---|
666 | DRIVE_INCLUDEFILES)) ?
|
---|
667 | dcd->mask.antiattr :
|
---|
668 | (dcd->mask.antiattr &&
|
---|
669 | dcd->mask.antiattr != FILE_DIRECTORY)))) {
|
---|
670 | sprintf(&s[strlen(s)],
|
---|
671 | " (%s)",
|
---|
672 | (*dcd->mask.szMask) ?
|
---|
673 | dcd->mask.szMask : GetPString(IDS_ATTRTEXT));
|
---|
674 | }
|
---|
675 | }
|
---|
676 | }
|
---|
677 | }
|
---|
678 | else {
|
---|
679 | /* find root record and strip it */
|
---|
680 | pci = FindParentRecord(dcd->hwndCnr, pci);
|
---|
681 | driveserial[toupper(*pci->szFileName) - 'A'] = -1;
|
---|
682 | UnFlesh(dcd->hwndCnr, pci);
|
---|
683 | }
|
---|
684 | }
|
---|
685 | }
|
---|
686 | if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
|
---|
687 | WinSetWindowText(hwndStatus, s);
|
---|
688 | }
|
---|
689 | return 0;
|
---|
690 |
|
---|
691 | case UM_RESCAN:
|
---|
692 | /*
|
---|
693 | * populate container
|
---|
694 | */
|
---|
695 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
696 | if (!dcd)
|
---|
697 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
698 | else {
|
---|
699 | WinSendMsg(dcd->hwndCnr,
|
---|
700 | CM_REMOVERECORD,
|
---|
701 | MPVOID,
|
---|
702 | MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE));
|
---|
703 | WinSendMsg(dcd->hwndCnr,
|
---|
704 | CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-1));
|
---|
705 | WinSendMsg(dcd->hwndCnr,
|
---|
706 | CM_SCROLLWINDOW,
|
---|
707 | MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(-1));
|
---|
708 | FillTreeCnr(dcd->hwndCnr, dcd->hwndParent);
|
---|
709 | if (fOkayMinimize) {
|
---|
710 | PostMsg(dcd->hwndCnr, UM_MINIMIZE, MPVOID, MPVOID);
|
---|
711 | fOkayMinimize = FALSE;
|
---|
712 | }
|
---|
713 | WinSendMsg(dcd->hwndCnr,
|
---|
714 | CM_INVALIDATERECORD,
|
---|
715 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
716 | PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
717 | }
|
---|
718 | return 0;
|
---|
719 |
|
---|
720 | case UM_COMMAND:
|
---|
721 | if (mp1) {
|
---|
722 |
|
---|
723 | LISTINFO *li = (LISTINFO *) mp1;
|
---|
724 |
|
---|
725 | switch (li->type) {
|
---|
726 | case IDM_DOITYOURSELF:
|
---|
727 | case IDM_APPENDTOCLIP:
|
---|
728 | case IDM_SAVETOCLIP:
|
---|
729 | case IDM_ARCHIVE:
|
---|
730 | case IDM_VIEW:
|
---|
731 | case IDM_EDIT:
|
---|
732 | case IDM_OBJECT:
|
---|
733 | case IDM_SHADOW:
|
---|
734 | case IDM_SHADOW2:
|
---|
735 | case IDM_PRINT:
|
---|
736 | case IDM_ATTRS:
|
---|
737 | case IDM_DELETE:
|
---|
738 | case IDM_PERMDELETE:
|
---|
739 | if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
|
---|
740 | return (MRESULT) TRUE;
|
---|
741 | default:
|
---|
742 | if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
|
---|
743 | return (MRESULT) TRUE;
|
---|
744 | }
|
---|
745 | }
|
---|
746 | return 0;
|
---|
747 |
|
---|
748 | case UM_MASSACTION:
|
---|
749 | if (mp1) {
|
---|
750 |
|
---|
751 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
752 | if (!dcd)
|
---|
753 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
754 | else {
|
---|
755 | WORKER *wk;
|
---|
756 |
|
---|
757 | wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
|
---|
758 | if (!wk)
|
---|
759 | FreeListInfo((LISTINFO *) mp1);
|
---|
760 | else {
|
---|
761 | wk->size = sizeof(WORKER);
|
---|
762 | wk->hwndCnr = dcd->hwndCnr;
|
---|
763 | wk->hwndParent = dcd->hwndParent;
|
---|
764 | wk->hwndFrame = dcd->hwndFrame;
|
---|
765 | wk->hwndClient = dcd->hwndClient;
|
---|
766 | wk->li = (LISTINFO *) mp1;
|
---|
767 | strcpy(wk->directory, dcd->directory);
|
---|
768 | if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
|
---|
769 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
770 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
771 | free(wk);
|
---|
772 | FreeListInfo((LISTINFO *) mp1);
|
---|
773 | }
|
---|
774 | }
|
---|
775 | }
|
---|
776 | }
|
---|
777 | return 0;
|
---|
778 |
|
---|
779 | case UM_ACTION:
|
---|
780 | if (mp1) {
|
---|
781 |
|
---|
782 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
783 | if (!dcd)
|
---|
784 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
785 | else {
|
---|
786 | WORKER *wk;
|
---|
787 |
|
---|
788 | wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
|
---|
789 | if (!wk)
|
---|
790 | FreeListInfo((LISTINFO *) mp1);
|
---|
791 | else {
|
---|
792 | wk->size = sizeof(WORKER);
|
---|
793 | wk->hwndCnr = dcd->hwndCnr;
|
---|
794 | wk->hwndParent = dcd->hwndParent;
|
---|
795 | wk->hwndFrame = dcd->hwndFrame;
|
---|
796 | wk->hwndClient = dcd->hwndClient;
|
---|
797 | wk->li = (LISTINFO *) mp1;
|
---|
798 | strcpy(wk->directory, dcd->directory);
|
---|
799 | if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
|
---|
800 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
801 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
802 | free(wk);
|
---|
803 | FreeListInfo((LISTINFO *) mp1);
|
---|
804 | }
|
---|
805 | }
|
---|
806 | }
|
---|
807 | }
|
---|
808 | return 0;
|
---|
809 |
|
---|
810 | case WM_CLOSE:
|
---|
811 | WinDestroyWindow(hwnd);
|
---|
812 | break;
|
---|
813 |
|
---|
814 | case WM_DESTROY:
|
---|
815 | hwndTree = (HWND) 0;
|
---|
816 | dcd = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
817 | if (dcd) {
|
---|
818 | WinSendMsg(dcd->hwndCnr,
|
---|
819 | UM_CLOSE, MPFROMLONG(dcd->dontclose != FALSE), MPVOID);
|
---|
820 | free(dcd);
|
---|
821 | }
|
---|
822 | DosPostEventSem(CompactSem);
|
---|
823 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
824 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
825 | break;
|
---|
826 | }
|
---|
827 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
828 | }
|
---|
829 |
|
---|
830 | MRESULT EXPENTRY TreeCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
831 | {
|
---|
832 | static APPNOTIFY *apphead = NULL, *apptail = NULL;
|
---|
833 | DIRCNRDATA *dcd = INSTDATA(hwnd);
|
---|
834 | DIRCNRDATA *dcdsrc;
|
---|
835 |
|
---|
836 | switch (msg) {
|
---|
837 | case DM_PRINTOBJECT:
|
---|
838 | return MRFROMLONG(DRR_TARGET);
|
---|
839 |
|
---|
840 | case DM_DISCARDOBJECT:
|
---|
841 | if (dcd)
|
---|
842 | return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
|
---|
843 | else
|
---|
844 | return MRFROMLONG(DRR_TARGET);
|
---|
845 |
|
---|
846 | case WM_CHAR:
|
---|
847 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
848 | if (SHORT1FROMMP(mp1) & KC_KEYUP)
|
---|
849 | return (MRESULT) TRUE;
|
---|
850 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
|
---|
851 | switch (SHORT2FROMMP(mp2)) {
|
---|
852 | case VK_INSERT:
|
---|
853 | if ((shiftstate & KC_CTRL) == KC_CTRL)
|
---|
854 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
|
---|
855 | break;
|
---|
856 | case VK_DELETE:
|
---|
857 | if ((shiftstate & KC_CTRL) == KC_CTRL)
|
---|
858 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
|
---|
859 | else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
|
---|
860 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
|
---|
861 | else
|
---|
862 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
|
---|
863 | break;
|
---|
864 | }
|
---|
865 | }
|
---|
866 | if (shiftstate || fNoSearch)
|
---|
867 | break;
|
---|
868 | if (SHORT1FROMMP(mp1) & KC_CHAR) {
|
---|
869 |
|
---|
870 | ULONG thistime, len;
|
---|
871 | SEARCHSTRING srch;
|
---|
872 | PCNRITEM pci;
|
---|
873 |
|
---|
874 | if (!dcd)
|
---|
875 | break;
|
---|
876 | switch (SHORT1FROMMP(mp2)) {
|
---|
877 | case '\x1b':
|
---|
878 | case '\r':
|
---|
879 | case '\n':
|
---|
880 | dcd->lasttime = 0;
|
---|
881 | *dcd->szCommonName = 0;
|
---|
882 | break;
|
---|
883 | default:
|
---|
884 | thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
|
---|
885 | if (thistime > dcd->lasttime + 1250)
|
---|
886 | *dcd->szCommonName = 0;
|
---|
887 | dcd->lasttime = thistime;
|
---|
888 | if (SHORT1FROMMP(mp2) == ' ' && !*dcd->szCommonName)
|
---|
889 | break;
|
---|
890 | KbdRetry:
|
---|
891 | len = strlen(dcd->szCommonName);
|
---|
892 | if (len >= CCHMAXPATH - 1) {
|
---|
893 | *dcd->szCommonName = 0;
|
---|
894 | len = 0;
|
---|
895 | }
|
---|
896 | dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
|
---|
897 | dcd->szCommonName[len + 1] = 0;
|
---|
898 | memset(&srch, 0, sizeof(SEARCHSTRING));
|
---|
899 | srch.cb = (ULONG) sizeof(SEARCHSTRING);
|
---|
900 | srch.pszSearch = (PSZ) dcd->szCommonName;
|
---|
901 | srch.fsPrefix = TRUE;
|
---|
902 | srch.fsCaseSensitive = FALSE;
|
---|
903 | srch.usView = CV_ICON;
|
---|
904 | pci = WinSendMsg(hwnd,
|
---|
905 | CM_SEARCHSTRING,
|
---|
906 | MPFROMP(&srch), MPFROMLONG(CMA_FIRST));
|
---|
907 | if (pci && (INT) pci != -1) {
|
---|
908 | /* make found item current item */
|
---|
909 | WinSendMsg(hwnd,
|
---|
910 | CM_SETRECORDEMPHASIS,
|
---|
911 | MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
|
---|
912 | /* make sure that record shows in viewport */
|
---|
913 | ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
|
---|
914 | return (MRESULT) TRUE;
|
---|
915 | }
|
---|
916 | else {
|
---|
917 | if (SHORT1FROMMP(mp2) == ' ') {
|
---|
918 | dcd->szCommonName[len] = 0;
|
---|
919 | break;
|
---|
920 | }
|
---|
921 | *dcd->szCommonName = 0;
|
---|
922 | dcd->lasttime = 0;
|
---|
923 | if (len) // retry as first letter if no match
|
---|
924 | goto KbdRetry;
|
---|
925 | }
|
---|
926 | break;
|
---|
927 | }
|
---|
928 | }
|
---|
929 | break;
|
---|
930 |
|
---|
931 | case WM_MOUSEMOVE:
|
---|
932 | case WM_BUTTON1UP:
|
---|
933 | case WM_BUTTON2UP:
|
---|
934 | case WM_BUTTON3UP:
|
---|
935 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
936 | break;
|
---|
937 |
|
---|
938 | case UM_TIMER:
|
---|
939 | if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent) &&
|
---|
940 | hwndStatus2) {
|
---|
941 | FILEFINDBUF3 ffb;
|
---|
942 | ULONG nm = 1L;
|
---|
943 | HDIR hdir = HDIR_CREATE;
|
---|
944 |
|
---|
945 | if (*SwapperDat) {
|
---|
946 | if (!DosFindFirst(SwapperDat,
|
---|
947 | &hdir,
|
---|
948 | FILE_NORMAL | FILE_HIDDEN |
|
---|
949 | FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY,
|
---|
950 | &ffb, sizeof(ffb), &nm, FIL_STANDARD)) {
|
---|
951 | CHAR tb[39], tm[39], tpm[39], s[163];
|
---|
952 | ULONG amem;
|
---|
953 |
|
---|
954 | priority_bumped();
|
---|
955 | DosFindClose(hdir);
|
---|
956 | if (!DosQuerySysInfo(QSV_TOTAVAILMEM,
|
---|
957 | QSV_TOTAVAILMEM,
|
---|
958 | (PVOID) & amem, sizeof(amem))) {
|
---|
959 | CommaFmtULL(tpm, sizeof(tpm), amem, 'M');
|
---|
960 | }
|
---|
961 | else
|
---|
962 | *tpm = 0;
|
---|
963 | if (!Dos16MemAvail(&amem))
|
---|
964 | CommaFmtULL(tm, sizeof(tm), amem, 'M');
|
---|
965 | else
|
---|
966 | *tm = 0;
|
---|
967 | CommaFmtULL(tb, sizeof(tb), ffb.cbFile, 'M');
|
---|
968 | sprintf(s, " %s %s%s%s%s%s",
|
---|
969 | GetPString(IDS_SWAPFILETEXT),
|
---|
970 | tb,
|
---|
971 | *tm ? GetPString(IDS_TREEMEMTEXT) : NullStr,
|
---|
972 | tm, *tpm ? "/" : NullStr, tpm);
|
---|
973 | WinSetWindowText(hwndStatus2, s);
|
---|
974 | }
|
---|
975 | else
|
---|
976 | WinSetWindowText(hwndStatus2, NullStr);
|
---|
977 | }
|
---|
978 | else
|
---|
979 | WinSetWindowText(hwndStatus2, NullStr);
|
---|
980 | }
|
---|
981 | if (msg == UM_TIMER)
|
---|
982 | return 0;
|
---|
983 | break;
|
---|
984 |
|
---|
985 | case WM_PRESPARAMCHANGED:
|
---|
986 | PresParamChanged(hwnd, "TreeCnr", mp1, mp2);
|
---|
987 | break;
|
---|
988 |
|
---|
989 | case UM_FILESMENU:
|
---|
990 | {
|
---|
991 | PCNRITEM pci;
|
---|
992 | HWND menuHwnd = (HWND) 0;
|
---|
993 |
|
---|
994 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
995 | if (pci && (INT) pci != -1) {
|
---|
996 | if (IsRoot(pci->szFileName))
|
---|
997 | menuHwnd = CheckMenu(&TreeMenu, TREE_POPUP);
|
---|
998 | else {
|
---|
999 | menuHwnd = CheckMenu(&DirMenu, DIR_POPUP);
|
---|
1000 | // WinEnableMenuItem(DirMenu,
|
---|
1001 | // IDM_TREE,
|
---|
1002 | // FALSE);
|
---|
1003 | }
|
---|
1004 | if (!(pci->attrFile & FILE_DIRECTORY))
|
---|
1005 | menuHwnd = CheckMenu(&FileMenu, FILE_POPUP);
|
---|
1006 | }
|
---|
1007 | return MRFROMLONG(menuHwnd);
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | case UM_COMPARE:
|
---|
1011 | if (dcd && mp1 && mp2) {
|
---|
1012 |
|
---|
1013 | COMPARE *cmp;
|
---|
1014 | CHAR *leftdir = (CHAR *) mp1, *rightdir = (CHAR *) mp2;
|
---|
1015 |
|
---|
1016 | if (!IsFile(leftdir) && !IsFile(rightdir)) {
|
---|
1017 | cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
|
---|
1018 | if (cmp) {
|
---|
1019 | cmp->size = sizeof(COMPARE);
|
---|
1020 | strcpy(cmp->leftdir, leftdir);
|
---|
1021 | strcpy(cmp->rightdir, rightdir);
|
---|
1022 | cmp->hwndParent = dcd->hwndParent;
|
---|
1023 | cmp->dcd.hwndParent = dcd->hwndParent;
|
---|
1024 | WinDlgBox(HWND_DESKTOP,
|
---|
1025 | HWND_DESKTOP,
|
---|
1026 | CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
|
---|
1027 | }
|
---|
1028 | }
|
---|
1029 | }
|
---|
1030 | return 0;
|
---|
1031 |
|
---|
1032 | case UM_UPDATERECORDLIST:
|
---|
1033 | if (dcd && mp1)
|
---|
1034 | WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
|
---|
1035 | return 0;
|
---|
1036 |
|
---|
1037 | case UM_UPDATERECORD:
|
---|
1038 | if (dcd && mp1) {
|
---|
1039 |
|
---|
1040 | CHAR *filename;
|
---|
1041 |
|
---|
1042 | filename = mp1;
|
---|
1043 | if (filename)
|
---|
1044 | UpdateCnrRecord(hwnd, filename, TRUE, dcd);
|
---|
1045 | }
|
---|
1046 | return 0;
|
---|
1047 |
|
---|
1048 | case WM_SETFOCUS:
|
---|
1049 | if (dcd && hwndStatus && mp2) {
|
---|
1050 | WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1051 | if (hwndMain)
|
---|
1052 | PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
|
---|
1053 | }
|
---|
1054 | break;
|
---|
1055 |
|
---|
1056 | case UM_RESCAN:
|
---|
1057 | if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
|
---|
1058 | /*
|
---|
1059 | * put name of our window on status line
|
---|
1060 | */
|
---|
1061 |
|
---|
1062 | PCNRITEM pci = NULL;
|
---|
1063 | CHAR str[CCHMAXPATH + 6];
|
---|
1064 |
|
---|
1065 | if (fAutoView && hwndMain) {
|
---|
1066 | pci = WinSendMsg(hwnd,
|
---|
1067 | CM_QUERYRECORDEMPHASIS,
|
---|
1068 | MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
|
---|
1069 | if (pci && (INT) pci != -1 && fComments &&
|
---|
1070 | !(driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_SLOW))
|
---|
1071 | WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->szFileName), MPVOID);
|
---|
1072 | else
|
---|
1073 | WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
---|
1074 | }
|
---|
1075 | if (!fAutoView || !hwndMain)
|
---|
1076 | pci = (PCNRITEM) WinSendMsg(hwnd,
|
---|
1077 | CM_QUERYRECORDEMPHASIS,
|
---|
1078 | MPFROMLONG(CMA_FIRST),
|
---|
1079 | MPFROMSHORT(CRA_CURSORED));
|
---|
1080 | if ((INT) pci == -1)
|
---|
1081 | pci = NULL;
|
---|
1082 | if (pci) {
|
---|
1083 | if (*(ULONG *) realappname == FM3UL) {
|
---|
1084 | sprintf(str, "%s %s", GetPString(IDS_DTTEXT), pci->szFileName);
|
---|
1085 | WinSetWindowText(dcd->hwndFrame, str);
|
---|
1086 | WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR),
|
---|
1087 | str);
|
---|
1088 | }
|
---|
1089 | else
|
---|
1090 | WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
|
---|
1091 | MAIN_STATUS), pci->szFileName);
|
---|
1092 | if (fMoreButtons && hwndName) {
|
---|
1093 | WinSetWindowText(hwndName, pci->szFileName);
|
---|
1094 | sprintf(str,
|
---|
1095 | "%04u/%02u/%02u %02u:%02u:%02u",
|
---|
1096 | pci->date.year,
|
---|
1097 | pci->date.month,
|
---|
1098 | pci->date.day,
|
---|
1099 | pci->time.hours, pci->time.minutes, pci->time.seconds);
|
---|
1100 | WinSetWindowText(hwndDate, str);
|
---|
1101 | WinSetWindowText(hwndAttr, pci->pszDispAttr);
|
---|
1102 | }
|
---|
1103 | }
|
---|
1104 | PostMsg(dcd->hwndObject, UM_RESCAN2, MPFROMP(pci), MPVOID);
|
---|
1105 | if (hwndStatus2)
|
---|
1106 | PostMsg(hwnd, UM_TIMER, MPVOID, MPVOID);
|
---|
1107 | }
|
---|
1108 | return 0;
|
---|
1109 |
|
---|
1110 | case UM_SETUP2:
|
---|
1111 | {
|
---|
1112 | PCNRITEM pci = (PCNRITEM) mp1;
|
---|
1113 |
|
---|
1114 | if (pci)
|
---|
1115 | NotifyError(pci->szFileName, (ULONG) mp2);
|
---|
1116 | }
|
---|
1117 | return 0;
|
---|
1118 |
|
---|
1119 | case UM_SETUP:
|
---|
1120 | if (!dcd) {
|
---|
1121 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
1122 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
1123 | return 0;
|
---|
1124 | }
|
---|
1125 | else {
|
---|
1126 | if (!dcd->hwndObject) {
|
---|
1127 | /*
|
---|
1128 | * first time through -- set things up
|
---|
1129 | */
|
---|
1130 |
|
---|
1131 | CNRINFO cnri;
|
---|
1132 |
|
---|
1133 | RestorePresParams(hwnd, "TreeCnr");
|
---|
1134 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
1135 | cnri.cb = sizeof(CNRINFO);
|
---|
1136 | WinSendMsg(hwnd,
|
---|
1137 | CM_QUERYCNRINFO,
|
---|
1138 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
1139 | cnri.cyLineSpacing = 0;
|
---|
1140 | cnri.cxTreeIndent = 12L;
|
---|
1141 | cnri.pSortRecord = (PVOID) SortTreeCnr;
|
---|
1142 | cnri.flWindowAttr &= (~(CV_NAME | CV_DETAIL | CV_TEXT));
|
---|
1143 | cnri.flWindowAttr |= (CV_TREE | CA_TREELINE | CV_ICON | CV_MINI);
|
---|
1144 | {
|
---|
1145 | ULONG size = sizeof(ULONG);
|
---|
1146 |
|
---|
1147 | PrfQueryProfileData(fmprof,
|
---|
1148 | appname,
|
---|
1149 | "TreeflWindowAttr",
|
---|
1150 | (PVOID) & cnri.flWindowAttr, &size);
|
---|
1151 | size = sizeof(MASK);
|
---|
1152 | *dcd->mask.prompt = 0;
|
---|
1153 | if (!*dcd->mask.szMask && !dcd->mask.attrFile) {
|
---|
1154 | if (PrfQueryProfileSize(fmprof,
|
---|
1155 | appname, "TreeFilter", &size) && size) {
|
---|
1156 | PrfQueryProfileData(fmprof,
|
---|
1157 | appname, "TreeFilter", &dcd->mask, &size);
|
---|
1158 | SetMask(NULL, &dcd->mask);
|
---|
1159 | }
|
---|
1160 | else
|
---|
1161 | dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
|
---|
1162 | FILE_ARCHIVED | FILE_DIRECTORY |
|
---|
1163 | FILE_HIDDEN | FILE_SYSTEM);
|
---|
1164 | }
|
---|
1165 | dcd->mask.attrFile |= FILE_DIRECTORY;
|
---|
1166 | }
|
---|
1167 | cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
|
---|
1168 | cnri.flWindowAttr |= CV_FLOW;
|
---|
1169 | dcd->flWindowAttr = cnri.flWindowAttr;
|
---|
1170 | WinSendMsg(hwnd,
|
---|
1171 | CM_SETCNRINFO,
|
---|
1172 | MPFROMP(&cnri),
|
---|
1173 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
|
---|
1174 | CMA_CXTREEINDENT | CMA_PSORTRECORD));
|
---|
1175 | if (_beginthread(MakeObjWin, NULL, 327680, (PVOID) dcd) == -1) {
|
---|
1176 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
1177 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
1178 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
1179 | return 0;
|
---|
1180 | }
|
---|
1181 | else
|
---|
1182 | DosSleep(1L);
|
---|
1183 | }
|
---|
1184 | }
|
---|
1185 | return 0;
|
---|
1186 |
|
---|
1187 | case WM_BUTTON3CLICK:
|
---|
1188 | case WM_CHORD:
|
---|
1189 | {
|
---|
1190 | PCNRITEM pci = NULL;
|
---|
1191 | QUERYRECFROMRECT pqr;
|
---|
1192 | NOTIFYRECORDENTER nr;
|
---|
1193 | BOOL tbool = fDCOpens;
|
---|
1194 | RECTL rectl;
|
---|
1195 | POINTL ptl;
|
---|
1196 |
|
---|
1197 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
1198 | if (msg == WM_CHORD) {
|
---|
1199 | if (!WinQueryPointerPos(HWND_DESKTOP, &ptl))
|
---|
1200 | break;
|
---|
1201 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1L);
|
---|
1202 | }
|
---|
1203 | else {
|
---|
1204 | ptl.x = SHORT1FROMMP(mp1);
|
---|
1205 | ptl.y = SHORT2FROMMP(mp1);
|
---|
1206 | }
|
---|
1207 | memset(&rectl, 0, sizeof(rectl));
|
---|
1208 | memset(&pqr, 0, sizeof(pqr));
|
---|
1209 | pqr.cb = sizeof(pqr);
|
---|
1210 | pqr.rect.xLeft = ptl.x - 1;
|
---|
1211 | pqr.rect.xRight = ptl.x + 1;
|
---|
1212 | pqr.rect.yTop = ptl.y + 1;
|
---|
1213 | pqr.rect.yBottom = ptl.y - 1;
|
---|
1214 | pqr.fsSearch = CMA_PARTIAL;
|
---|
1215 | pci = (PCNRITEM) WinSendMsg(hwnd,
|
---|
1216 | CM_QUERYRECORDFROMRECT,
|
---|
1217 | MPFROMLONG(CMA_FIRST), MPFROMP(&pqr));
|
---|
1218 | if (!pci || (INT) pci == -1)
|
---|
1219 | break; //Probable B3 click on white space Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
1220 | else {
|
---|
1221 | memset(&nr, 0, sizeof(nr));
|
---|
1222 | nr.hwndCnr = hwnd;
|
---|
1223 | nr.pRecord = (PRECORDCORE) pci;
|
---|
1224 | fDCOpens = TRUE;
|
---|
1225 | WinSendMsg(hwnd,
|
---|
1226 | WM_CONTROL,
|
---|
1227 | MPFROM2SHORT(WinQueryWindowUShort(hwnd,
|
---|
1228 | QWS_ID),
|
---|
1229 | CN_ENTER), MPFROMP(&nr));
|
---|
1230 | PostMsg(hwnd, UM_RESTOREDC, MPFROMLONG(tbool), MPVOID);
|
---|
1231 | }
|
---|
1232 | }
|
---|
1233 | break;
|
---|
1234 |
|
---|
1235 | case UM_RESTOREDC:
|
---|
1236 | fDCOpens = (BOOL) mp1;
|
---|
1237 | return 0;
|
---|
1238 |
|
---|
1239 | case WM_CONTROL:
|
---|
1240 | DosError(FERR_DISABLEHARDERR);
|
---|
1241 | if (dcd) {
|
---|
1242 | switch (SHORT2FROMMP(mp1)) {
|
---|
1243 | case CN_BEGINEDIT:
|
---|
1244 | case CN_REALLOCPSZ:
|
---|
1245 | case CN_ENDEDIT:
|
---|
1246 | {
|
---|
1247 | MRESULT mre;
|
---|
1248 |
|
---|
1249 | mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
|
---|
1250 | if (mre != (MRESULT) - 1)
|
---|
1251 | return mre;
|
---|
1252 | }
|
---|
1253 | break;
|
---|
1254 |
|
---|
1255 | case CN_DRAGLEAVE:
|
---|
1256 | if (mp2) {
|
---|
1257 |
|
---|
1258 | PDRAGINFO pDInfo;
|
---|
1259 |
|
---|
1260 | // fixme to know why - seems superfluous
|
---|
1261 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
1262 | DrgAccessDraginfo(pDInfo);
|
---|
1263 | DrgFreeDraginfo(pDInfo);
|
---|
1264 | }
|
---|
1265 | return 0;
|
---|
1266 |
|
---|
1267 | case CN_DRAGAFTER:
|
---|
1268 | case CN_DRAGOVER:
|
---|
1269 | if (mp2) {
|
---|
1270 |
|
---|
1271 | PDRAGITEM pDItem;
|
---|
1272 | PDRAGINFO pDInfo;
|
---|
1273 | PCNRITEM pci;
|
---|
1274 | USHORT uso;
|
---|
1275 |
|
---|
1276 | pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
|
---|
1277 | if (!DrgAccessDraginfo(pDInfo)) {
|
---|
1278 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
|
---|
1279 | "DrgAccessDraginfo");
|
---|
1280 | return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
|
---|
1281 | }
|
---|
1282 | pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
|
---|
1283 | if ((INT) pci == -1)
|
---|
1284 | pci = NULL;
|
---|
1285 | if (pci && (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODROP))) {
|
---|
1286 | DrgFreeDraginfo(pDInfo);
|
---|
1287 | return MRFROM2SHORT(DOR_NODROP, 0);
|
---|
1288 | }
|
---|
1289 | if (!WinIsWindowEnabled(dcd->hwndFrame)) {
|
---|
1290 | DrgFreeDraginfo(pDInfo);
|
---|
1291 | return MRFROM2SHORT(DOR_NODROP, 0);
|
---|
1292 | }
|
---|
1293 | if (pci) {
|
---|
1294 | uso = pDInfo->usOperation;
|
---|
1295 | if (uso == DO_DEFAULT)
|
---|
1296 | uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
|
---|
1297 | if (!(pci->attrFile & FILE_DIRECTORY)) {
|
---|
1298 | if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
|
---|
1299 | DrgFreeDraginfo(pDInfo);
|
---|
1300 | return (MRFROM2SHORT(DOR_NODROP, 0));
|
---|
1301 | }
|
---|
1302 | if (uso != DO_LINK &&
|
---|
1303 | !(driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
1304 | DRIVE_NOTWRITEABLE)) {
|
---|
1305 |
|
---|
1306 | ARC_TYPE *info;
|
---|
1307 |
|
---|
1308 | if (!fQuickArcFind &&
|
---|
1309 | !(driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
1310 | DRIVE_SLOW))
|
---|
1311 | info = find_type(pci->szFileName, NULL);
|
---|
1312 | else
|
---|
1313 | info = quick_find_type(pci->szFileName, NULL);
|
---|
1314 | if (!info || ((uso == DO_MOVE && !info->move) ||
|
---|
1315 | (uso == DO_COPY && !info->create))) {
|
---|
1316 | DrgFreeDraginfo(pDInfo);
|
---|
1317 | return (MRFROM2SHORT(DOR_NODROP, 0));
|
---|
1318 | }
|
---|
1319 | }
|
---|
1320 | }
|
---|
1321 | }
|
---|
1322 | pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
|
---|
1323 | 0); /* Index to DRAGITEM */
|
---|
1324 | if (DrgVerifyRMF(pDItem, /* Check valid rendering */
|
---|
1325 | DRM_OS2FILE, /* mechanisms and data */
|
---|
1326 | NULL) || DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE)) { /* formats */
|
---|
1327 | DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
|
---|
1328 | if (!pci || (INT) pci == -1)
|
---|
1329 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
1330 | if (driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
1331 | DRIVE_NOTWRITEABLE)
|
---|
1332 | return MRFROM2SHORT(DOR_DROP, DO_LINK);
|
---|
1333 | if (toupper(*pci->szFileName) < 'C')
|
---|
1334 | return MRFROM2SHORT(DOR_DROP, DO_COPY);
|
---|
1335 | return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
|
---|
1336 | ((fCopyDefault) ? DO_COPY : DO_MOVE));
|
---|
1337 | }
|
---|
1338 | DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
|
---|
1339 | }
|
---|
1340 | return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
|
---|
1341 |
|
---|
1342 | case CN_INITDRAG:
|
---|
1343 | {
|
---|
1344 | PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
|
---|
1345 | PCNRITEM pci;
|
---|
1346 |
|
---|
1347 | if (!pcd) {
|
---|
1348 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
1349 | break;
|
---|
1350 | }
|
---|
1351 | else {
|
---|
1352 | pci = (PCNRITEM) pcd->pRecord;
|
---|
1353 | if (!pci || (INT) pci == -1) {
|
---|
1354 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
1355 | break;
|
---|
1356 | }
|
---|
1357 | if (pci->flags & (RECFLAGS_ENV | RECFLAGS_NODRAG)) {
|
---|
1358 | Runtime_Error(pszSrcFile, __LINE__, "drag not allowed");
|
---|
1359 | break;
|
---|
1360 | }
|
---|
1361 | if (hwndStatus2) {
|
---|
1362 | WinSetWindowText(hwndStatus2, (IsRoot(pci->szFileName)) ?
|
---|
1363 | GetPString(IDS_DRAGROOTTEXT) :
|
---|
1364 | (pci->attrFile & FILE_DIRECTORY) ?
|
---|
1365 | GetPString(IDS_DRAGDIRTEXT) :
|
---|
1366 | GetPString(IDS_DRAGFILETEXT));
|
---|
1367 | }
|
---|
1368 | DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE);
|
---|
1369 | if (hwndStatus2) {
|
---|
1370 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1371 | }
|
---|
1372 | }
|
---|
1373 | }
|
---|
1374 | return 0;
|
---|
1375 |
|
---|
1376 | case CN_DROP:
|
---|
1377 | {
|
---|
1378 | LISTINFO *li;
|
---|
1379 | ULONG action = UM_ACTION;
|
---|
1380 |
|
---|
1381 | li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
|
---|
1382 | CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
|
---|
1383 | if (li) {
|
---|
1384 | if (!*li->targetpath) {
|
---|
1385 | if (li->list[0])
|
---|
1386 | PMMkDir(dcd->hwndParent, li->list[0], FALSE);
|
---|
1387 | FreeListInfo(li);
|
---|
1388 | return 0;
|
---|
1389 | }
|
---|
1390 | if (li->list && li->list[0] && IsRoot(li->list[0]))
|
---|
1391 | li->type = DO_LINK;
|
---|
1392 | else if (fDragndropDlg && (!*li->arcname || !li->info)) {
|
---|
1393 |
|
---|
1394 | CHECKLIST cl;
|
---|
1395 |
|
---|
1396 | memset(&cl, 0, sizeof(cl));
|
---|
1397 | cl.size = sizeof(cl);
|
---|
1398 | cl.flags = li->type;
|
---|
1399 | cl.list = li->list;
|
---|
1400 | cl.cmd = li->type;
|
---|
1401 | cl.prompt = li->targetpath;
|
---|
1402 | li->type = WinDlgBox(HWND_DESKTOP,
|
---|
1403 | dcd->hwndParent,
|
---|
1404 | DropListProc,
|
---|
1405 | FM3ModHandle, DND_FRAME, MPFROMP(&cl));
|
---|
1406 | if (li->type == DID_ERROR)
|
---|
1407 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
1408 | "Drag & Drop Dialog");
|
---|
1409 | if (!li->type) {
|
---|
1410 | FreeListInfo(li);
|
---|
1411 | return 0;
|
---|
1412 | }
|
---|
1413 | li->list = cl.list;
|
---|
1414 | if (!li->list || !li->list[0]) {
|
---|
1415 | FreeListInfo(li);
|
---|
1416 | return 0;
|
---|
1417 | }
|
---|
1418 | }
|
---|
1419 | switch (li->type) {
|
---|
1420 | case DO_LINK:
|
---|
1421 | if (fLinkSetsIcon) {
|
---|
1422 | li->type = IDM_SETICON;
|
---|
1423 | action = UM_MASSACTION;
|
---|
1424 | }
|
---|
1425 | else
|
---|
1426 | li->type = IDM_COMPARE;
|
---|
1427 | break;
|
---|
1428 | case DND_EXTRACT:
|
---|
1429 | if (*li->targetpath && !IsFile(li->targetpath))
|
---|
1430 | li->type = IDM_EXTRACT;
|
---|
1431 | break;
|
---|
1432 | case DND_MOVE:
|
---|
1433 | li->type = IDM_MOVE;
|
---|
1434 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1435 | action = UM_MASSACTION;
|
---|
1436 | li->type = IDM_ARCHIVEM;
|
---|
1437 | }
|
---|
1438 | break;
|
---|
1439 | case DND_WILDMOVE:
|
---|
1440 | li->type = IDM_WILDMOVE;
|
---|
1441 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1442 | action = UM_MASSACTION;
|
---|
1443 | li->type = IDM_ARCHIVEM;
|
---|
1444 | }
|
---|
1445 | break;
|
---|
1446 | case DND_OBJECT:
|
---|
1447 | li->type = IDM_OBJECT;
|
---|
1448 | action = UM_MASSACTION;
|
---|
1449 | break;
|
---|
1450 | case DND_SHADOW:
|
---|
1451 | li->type = IDM_SHADOW;
|
---|
1452 | action = UM_MASSACTION;
|
---|
1453 | break;
|
---|
1454 | case DND_COMPARE:
|
---|
1455 | li->type = IDM_COMPARE;
|
---|
1456 | break;
|
---|
1457 | case DND_SETICON:
|
---|
1458 | action = UM_MASSACTION;
|
---|
1459 | li->type = IDM_SETICON;
|
---|
1460 | break;
|
---|
1461 | case DND_COPY:
|
---|
1462 | li->type = IDM_COPY;
|
---|
1463 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1464 | action = UM_MASSACTION;
|
---|
1465 | li->type = IDM_ARCHIVE;
|
---|
1466 | }
|
---|
1467 | break;
|
---|
1468 | case DND_WILDCOPY:
|
---|
1469 | li->type = IDM_WILDCOPY;
|
---|
1470 | if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1471 | action = UM_MASSACTION;
|
---|
1472 | li->type = IDM_ARCHIVE;
|
---|
1473 | }
|
---|
1474 | break;
|
---|
1475 | default:
|
---|
1476 | if (*li->arcname && li->info) {
|
---|
1477 | action = UM_MASSACTION;
|
---|
1478 | li->type = (li->type == DO_MOVE) ?
|
---|
1479 | IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
|
---|
1480 | }
|
---|
1481 | else if (*li->targetpath && IsFile(li->targetpath) == 1) {
|
---|
1482 | action = UM_MASSACTION;
|
---|
1483 | li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
|
---|
1484 | }
|
---|
1485 | else
|
---|
1486 | li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
|
---|
1487 | break;
|
---|
1488 | }
|
---|
1489 | if (!li->list || !li->list[0])
|
---|
1490 | FreeListInfo(li);
|
---|
1491 | else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
|
---|
1492 | FreeListInfo(li);
|
---|
1493 | else {
|
---|
1494 |
|
---|
1495 | USHORT usop = 0;
|
---|
1496 |
|
---|
1497 | switch (li->type) {
|
---|
1498 | case IDM_COPY:
|
---|
1499 | case IDM_WILDCOPY:
|
---|
1500 | usop = DO_COPY;
|
---|
1501 | break;
|
---|
1502 | case IDM_MOVE:
|
---|
1503 | case IDM_WILDMOVE:
|
---|
1504 | case IDM_ARCHIVEM:
|
---|
1505 | usop = DO_MOVE;
|
---|
1506 | break;
|
---|
1507 | }
|
---|
1508 | if (usop)
|
---|
1509 | return MRFROM2SHORT(DOR_DROP, usop);
|
---|
1510 | }
|
---|
1511 | }
|
---|
1512 | }
|
---|
1513 | return 0;
|
---|
1514 |
|
---|
1515 | case CN_EMPHASIS:
|
---|
1516 | if (!fDummy) {
|
---|
1517 |
|
---|
1518 | PNOTIFYRECORDEMPHASIS pre = mp2;
|
---|
1519 |
|
---|
1520 | if (pre->fEmphasisMask & CRA_SELECTED) {
|
---|
1521 | if (pre->pRecord->flRecordAttr & CRA_SELECTED) {
|
---|
1522 | if (((PCNRITEM) (pre->pRecord))->attrFile & FILE_DIRECTORY) {
|
---|
1523 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1524 | if (fFollowTree &&
|
---|
1525 | !(driveflags
|
---|
1526 | [toupper(*((PCNRITEM) pre->pRecord)->szFileName) -
|
---|
1527 | 'A'] & DRIVE_INVALID)) {
|
---|
1528 | if (!LastDir && !ParentIsDesktop(hwnd, dcd->hwndParent))
|
---|
1529 | LastDir = FindDirCnr(dcd->hwndParent);
|
---|
1530 | if (LastDir) {
|
---|
1531 |
|
---|
1532 | NOTIFYRECORDENTER pri;
|
---|
1533 | BOOL tbool = fDCOpens;
|
---|
1534 |
|
---|
1535 | fDCOpens = FALSE;
|
---|
1536 | memset(&pri, 0, sizeof(pri));
|
---|
1537 | pri.hwndCnr = hwnd;
|
---|
1538 | pri.fKey = FALSE;
|
---|
1539 | pri.pRecord = pre->pRecord;
|
---|
1540 | WinSendMsg(hwnd,
|
---|
1541 | WM_CONTROL,
|
---|
1542 | MPFROM2SHORT(SHORT1FROMMP(mp1),
|
---|
1543 | CN_ENTER), MPFROMP(&pri));
|
---|
1544 | fDCOpens = tbool;
|
---|
1545 | }
|
---|
1546 | }
|
---|
1547 | if (*(ULONG *) realappname != FM3UL)
|
---|
1548 | WinSetWindowText(WinWindowFromID(dcd->hwndFrame,
|
---|
1549 | MAIN_STATUS),
|
---|
1550 | ((PCNRITEM) (pre->pRecord))->szFileName);
|
---|
1551 | }
|
---|
1552 | }
|
---|
1553 | }
|
---|
1554 | }
|
---|
1555 | break;
|
---|
1556 |
|
---|
1557 | case CN_CONTEXTMENU:
|
---|
1558 | {
|
---|
1559 | PCNRITEM pci = (PCNRITEM) mp2;
|
---|
1560 | BOOL wasFollowing;
|
---|
1561 |
|
---|
1562 | DosEnterCritSec();
|
---|
1563 | wasFollowing = fFollowTree;
|
---|
1564 | fFollowTree = FALSE;
|
---|
1565 | DosExitCritSec();
|
---|
1566 | if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
|
---|
1567 | WinSendMsg(hwnd,
|
---|
1568 | CM_SETRECORDEMPHASIS,
|
---|
1569 | MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
|
---|
1570 | MarkAll(hwnd, FALSE, FALSE, TRUE);
|
---|
1571 | if (!(pci->attrFile & FILE_DIRECTORY))
|
---|
1572 | dcd->hwndLastMenu = CheckMenu(&FileMenu, FILE_POPUP);
|
---|
1573 | else if (!IsRoot(pci->szFileName))
|
---|
1574 | dcd->hwndLastMenu = CheckMenu(&DirMenu, DIR_POPUP);
|
---|
1575 | else
|
---|
1576 | dcd->hwndLastMenu = CheckMenu(&TreeMenu, TREE_POPUP);
|
---|
1577 | }
|
---|
1578 | else {
|
---|
1579 | dcd->hwndLastMenu = CheckMenu(&TreeCnrMenu, TREECNR_POPUP);
|
---|
1580 | if (dcd->hwndLastMenu && !dcd->cnremphasized) {
|
---|
1581 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
1582 | MPFROM2SHORT(TRUE, CRA_SOURCE));
|
---|
1583 | dcd->cnremphasized = TRUE;
|
---|
1584 | }
|
---|
1585 | }
|
---|
1586 | if (dcd->hwndLastMenu) {
|
---|
1587 | if (dcd->hwndLastMenu == DirMenu)
|
---|
1588 | WinEnableMenuItem(DirMenu, IDM_TREE, FALSE);
|
---|
1589 | if (dcd->hwndLastMenu == TreeCnrMenu) {
|
---|
1590 | if (dcd->flWindowAttr & CV_MINI)
|
---|
1591 | WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
|
---|
1592 | }
|
---|
1593 | if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
|
---|
1594 | if (dcd->cnremphasized) {
|
---|
1595 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
1596 | MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
1597 | dcd->cnremphasized = FALSE;
|
---|
1598 | }
|
---|
1599 | if (dcd->hwndLastMenu != TreeCnrMenu)
|
---|
1600 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
---|
1601 | }
|
---|
1602 | }
|
---|
1603 | DosEnterCritSec();
|
---|
1604 | fFollowTree = wasFollowing;
|
---|
1605 | DosExitCritSec();
|
---|
1606 | }
|
---|
1607 | break;
|
---|
1608 |
|
---|
1609 | case CN_ENTER:
|
---|
1610 | if (mp2) {
|
---|
1611 | PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
|
---|
1612 |
|
---|
1613 | PostMsg(hwnd, UM_ENTER, MPFROMP(pci), MPVOID);
|
---|
1614 | }
|
---|
1615 | break;
|
---|
1616 |
|
---|
1617 | case CN_COLLAPSETREE:
|
---|
1618 | case CN_EXPANDTREE:
|
---|
1619 | {
|
---|
1620 | PCNRITEM pci = (PCNRITEM) mp2;
|
---|
1621 |
|
---|
1622 | if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
|
---|
1623 | if (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_REMOVABLE) {
|
---|
1624 |
|
---|
1625 | struct
|
---|
1626 | {
|
---|
1627 | ULONG serial;
|
---|
1628 | CHAR volumelength;
|
---|
1629 | CHAR volumelabel[CCHMAXPATH];
|
---|
1630 | }
|
---|
1631 | volser;
|
---|
1632 |
|
---|
1633 | memset(&volser, 0, sizeof(volser));
|
---|
1634 | DosError(FERR_DISABLEHARDERR);
|
---|
1635 | if (!DosQueryFSInfo(toupper(*pci->szFileName) - '@',
|
---|
1636 | FSIL_VOLSER, &volser,
|
---|
1637 | (ULONG) sizeof(volser))) {
|
---|
1638 | if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
|
---|
1639 | !volser.serial ||
|
---|
1640 | driveserial[toupper(*pci->szFileName) - 'A'] !=
|
---|
1641 | volser.serial)
|
---|
1642 | UnFlesh(hwnd, pci);
|
---|
1643 | if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
|
---|
1644 | (!volser.serial ||
|
---|
1645 | driveserial[toupper(*pci->szFileName) - 'A'] !=
|
---|
1646 | volser.serial)) {
|
---|
1647 | if (Flesh(hwnd, pci) &&
|
---|
1648 | SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
|
---|
1649 | !dcd->suspendview && fTopDir)
|
---|
1650 | PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
|
---|
1651 | }
|
---|
1652 | driveserial[toupper(*pci->szFileName) - 'A'] = volser.serial;
|
---|
1653 | }
|
---|
1654 | else {
|
---|
1655 | driveserial[toupper(*pci->szFileName) - 'A'] = -1;
|
---|
1656 | UnFlesh(hwnd, pci);
|
---|
1657 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1658 | DosBeep(250, 100);
|
---|
1659 | }
|
---|
1660 | }
|
---|
1661 | else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
|
---|
1662 | if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
|
---|
1663 | PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
|
---|
1664 | }
|
---|
1665 | if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
|
---|
1666 | WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
|
---|
1667 | }
|
---|
1668 | }
|
---|
1669 | break;
|
---|
1670 | } // switch WM_CONTROL
|
---|
1671 | }
|
---|
1672 | return 0;
|
---|
1673 |
|
---|
1674 | case UM_ACTION:
|
---|
1675 | if (mp1) {
|
---|
1676 |
|
---|
1677 | LISTINFO *li = mp1;
|
---|
1678 | ULONG action = (ULONG) mp2;
|
---|
1679 |
|
---|
1680 | if (!li->list || !li->list[0] ||
|
---|
1681 | !PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
|
---|
1682 | FreeListInfo(li);
|
---|
1683 | }
|
---|
1684 | return 0;
|
---|
1685 |
|
---|
1686 | case UM_SHOWME:
|
---|
1687 | if (mp1 && dcd) {
|
---|
1688 | CHAR *dir = xstrdup((CHAR *) mp1, pszSrcFile, __LINE__);
|
---|
1689 |
|
---|
1690 | if (dir) {
|
---|
1691 | if (!PostMsg(dcd->hwndObject, UM_SHOWME, MPFROMP(dir), MPVOID))
|
---|
1692 | free(dir);
|
---|
1693 | }
|
---|
1694 | }
|
---|
1695 | return 0;
|
---|
1696 |
|
---|
1697 | case UM_TOPDIR:
|
---|
1698 | if (mp1) {
|
---|
1699 |
|
---|
1700 | PCNRITEM pci = (PCNRITEM) mp1;
|
---|
1701 |
|
---|
1702 | ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
|
---|
1703 | }
|
---|
1704 | return 0;
|
---|
1705 |
|
---|
1706 | case UM_ENTER:
|
---|
1707 | {
|
---|
1708 | FILEFINDBUF3 ffb;
|
---|
1709 | HDIR hDir = HDIR_CREATE;
|
---|
1710 | ULONG nm = 1L;
|
---|
1711 | APIRET status;
|
---|
1712 | BOOL IsOk = FALSE;
|
---|
1713 | ULONG ulDriveNum, ulDriveMap;
|
---|
1714 | PCNRITEM pciP, pciL, pci;
|
---|
1715 | ULONG fl = SWP_ACTIVATE;
|
---|
1716 |
|
---|
1717 | if (fFollowTree)
|
---|
1718 | fl = 0;
|
---|
1719 | SetShiftState();
|
---|
1720 | pci = (PCNRITEM) mp1;
|
---|
1721 | if (pci &&
|
---|
1722 | (INT) pci != -1 &&
|
---|
1723 | !(pci->rc.flRecordAttr & CRA_INUSE) &&
|
---|
1724 | !(pci->flags & RECFLAGS_ENV) && IsFullName(pci->szFileName)) {
|
---|
1725 | if (driveflags[toupper(*pci->szFileName) - 'A'] & DRIVE_INVALID) {
|
---|
1726 | DosBeep(50, 100);
|
---|
1727 | if (hwndStatus)
|
---|
1728 | WinSetWindowText(hwndStatus, GetPString(IDS_RESCANSUGTEXT));
|
---|
1729 | return 0;
|
---|
1730 | }
|
---|
1731 | DosError(FERR_DISABLEHARDERR);
|
---|
1732 | if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
|
---|
1733 | if (!(ulDriveMap & 1L << (toupper(*pci->szFileName) - 'A'))) {
|
---|
1734 | pciL = pciP = pci;
|
---|
1735 | for (;;) {
|
---|
1736 | pciP = WinSendMsg(hwnd,
|
---|
1737 | CM_QUERYRECORD,
|
---|
1738 | MPFROMP(pciL),
|
---|
1739 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
|
---|
1740 | if (pciP && (INT) pciP != -1)
|
---|
1741 | pciL = pciP;
|
---|
1742 | else {
|
---|
1743 | pciP = pciL;
|
---|
1744 | break;
|
---|
1745 | }
|
---|
1746 | } // for
|
---|
1747 | WinSendMsg(hwnd,
|
---|
1748 | CM_REMOVERECORD,
|
---|
1749 | MPFROMP(&pciP),
|
---|
1750 | MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE));
|
---|
1751 | return 0;
|
---|
1752 | }
|
---|
1753 | }
|
---|
1754 | if (driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
1755 | (DRIVE_REMOVABLE | DRIVE_NOPRESCAN)) {
|
---|
1756 |
|
---|
1757 | struct
|
---|
1758 | {
|
---|
1759 | ULONG serial;
|
---|
1760 | CHAR volumelength;
|
---|
1761 | CHAR volumelabel[CCHMAXPATH];
|
---|
1762 | }
|
---|
1763 | volser;
|
---|
1764 |
|
---|
1765 | pciL = pciP = pci;
|
---|
1766 | for (;;) {
|
---|
1767 | pciP = WinSendMsg(hwnd,
|
---|
1768 | CM_QUERYRECORD,
|
---|
1769 | MPFROMP(pciL),
|
---|
1770 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
|
---|
1771 | if (pciP && (INT) pciP != -1)
|
---|
1772 | pciL = pciP;
|
---|
1773 | else {
|
---|
1774 | pciP = pciL;
|
---|
1775 | break;
|
---|
1776 | }
|
---|
1777 | }
|
---|
1778 | if ((driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
1779 | DRIVE_NOPRESCAN) ||
|
---|
1780 | (toupper(*pci->szFileName) > 'B' &&
|
---|
1781 | !(driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
1782 | DRIVE_CDROM))) {
|
---|
1783 |
|
---|
1784 | INT removable, x = (INT) (toupper(*pci->szFileName) - 'A');
|
---|
1785 | ULONG drvtype;
|
---|
1786 | CHAR FileSystem[CCHMAXPATH];
|
---|
1787 |
|
---|
1788 | DosError(FERR_DISABLEHARDERR);
|
---|
1789 | removable = CheckDrive(toupper(*pciP->szFileName),
|
---|
1790 | FileSystem, &drvtype);
|
---|
1791 | if (removable != -1) {
|
---|
1792 | driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN |
|
---|
1793 | DRIVE_NOLOADICONS | DRIVE_NOLOADSUBJS |
|
---|
1794 | DRIVE_NOLOADLONGS | DRIVE_INCLUDEFILES |
|
---|
1795 | DRIVE_SLOW | DRIVE_NOSTATS);
|
---|
1796 |
|
---|
1797 | if (removable == 1)
|
---|
1798 | driveflags[x] |= DRIVE_REMOVABLE;
|
---|
1799 | if (drvtype & DRIVE_REMOTE)
|
---|
1800 | driveflags[x] |= DRIVE_REMOTE;
|
---|
1801 | if (!strcmp(FileSystem, CBSIFS)) {
|
---|
1802 | driveflags[x] |= DRIVE_ZIPSTREAM;
|
---|
1803 | driveflags[x] &= (~DRIVE_REMOTE);
|
---|
1804 | }
|
---|
1805 | if(!strcmp(FileSystem,NDFS32)) {
|
---|
1806 | driveflags[x] |= DRIVE_VIRTUAL;
|
---|
1807 | driveflags[x] &= (~DRIVE_REMOTE);
|
---|
1808 | }
|
---|
1809 | if(!strcmp(FileSystem,RAMFS)) {
|
---|
1810 | driveflags[x] |= DRIVE_RAMDISK;
|
---|
1811 | driveflags[x] &= (~DRIVE_REMOTE);
|
---|
1812 | }
|
---|
1813 | if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS))
|
---|
1814 | driveflags[x] |= (DRIVE_REMOVABLE |
|
---|
1815 | DRIVE_NOTWRITEABLE | DRIVE_CDROM);
|
---|
1816 | if(!strcmp(FileSystem,NTFS))
|
---|
1817 | driveflags[x] |= DRIVE_NOTWRITEABLE;
|
---|
1818 | if (strcmp(FileSystem, HPFS) &&
|
---|
1819 | strcmp(FileSystem, JFS) &&
|
---|
1820 | strcmp(FileSystem, CDFS) &&
|
---|
1821 | strcmp(FileSystem, ISOFS) &&
|
---|
1822 | strcmp(FileSystem, RAMFS) &&
|
---|
1823 | strcmp(FileSystem, FAT32) &&
|
---|
1824 | strcmp(FileSystem, NDFS32) &&
|
---|
1825 | strcmp(FileSystem, NTFS) &&
|
---|
1826 | strcmp(FileSystem, HPFS386)) {
|
---|
1827 | driveflags[x] |= DRIVE_NOLONGNAMES;
|
---|
1828 | }
|
---|
1829 | SelectDriveIcon(pciP);
|
---|
1830 | WinSendMsg(hwnd,
|
---|
1831 | CM_INVALIDATERECORD,
|
---|
1832 | MPFROMP(&pciP),
|
---|
1833 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
|
---|
1834 | if (hwndMain)
|
---|
1835 | PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
|
---|
1836 | }
|
---|
1837 | }
|
---|
1838 | memset(&volser, 0, sizeof(volser));
|
---|
1839 | DosError(FERR_DISABLEHARDERR);
|
---|
1840 | status = DosQueryFSInfo(toupper(*pci->szFileName) - '@',
|
---|
1841 | FSIL_VOLSER, &volser,
|
---|
1842 | (ULONG) sizeof(volser));
|
---|
1843 | if (!status) {
|
---|
1844 | if (!volser.serial ||
|
---|
1845 | driveserial[toupper(*pci->szFileName) - 'A'] !=
|
---|
1846 | volser.serial) {
|
---|
1847 | UnFlesh(hwnd, pciP);
|
---|
1848 | Flesh(hwnd, pciP);
|
---|
1849 | driveserial[toupper(*pci->szFileName) - 'A'] = volser.serial;
|
---|
1850 | }
|
---|
1851 | pciL = WinSendMsg(hwnd,
|
---|
1852 | CM_QUERYRECORD,
|
---|
1853 | MPFROMP(pciP),
|
---|
1854 | MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
|
---|
1855 | if (!pciL)
|
---|
1856 | Flesh(hwnd, pciP);
|
---|
1857 | }
|
---|
1858 | else {
|
---|
1859 | driveserial[toupper(*pci->szFileName) - 'A'] = -1;
|
---|
1860 | UnFlesh(hwnd, pci);
|
---|
1861 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1862 | PostMsg(hwnd, UM_SETUP2, MPFROMP(pci), MPFROMLONG(status));
|
---|
1863 | return 0;
|
---|
1864 | }
|
---|
1865 | }
|
---|
1866 | status = 0;
|
---|
1867 | IsOk = (IsRoot(pci->szFileName) &&
|
---|
1868 | IsValidDrive(toupper(*pci->szFileName)));
|
---|
1869 | if (!IsOk) {
|
---|
1870 | DosError(FERR_DISABLEHARDERR);
|
---|
1871 | status = DosFindFirst(pci->szFileName, &hDir,
|
---|
1872 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
1873 | FILE_ARCHIVED | FILE_READONLY |
|
---|
1874 | FILE_HIDDEN | FILE_SYSTEM,
|
---|
1875 | &ffb, sizeof(ffb), &nm, FIL_STANDARD);
|
---|
1876 | priority_bumped();
|
---|
1877 | }
|
---|
1878 | if (!status) {
|
---|
1879 | if (!IsOk)
|
---|
1880 | DosFindClose(hDir);
|
---|
1881 | if (IsOk || (ffb.attrFile & FILE_DIRECTORY)) {
|
---|
1882 | if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT)) {
|
---|
1883 | PostMsg(hwnd,
|
---|
1884 | WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
|
---|
1885 | return 0;
|
---|
1886 | }
|
---|
1887 | if ((shiftstate & (KC_CTRL | KC_SHIFT)) == (KC_CTRL | KC_SHIFT)) {
|
---|
1888 | OpenObject(pci->szFileName, Settings, dcd->hwndFrame);
|
---|
1889 | return 0;
|
---|
1890 | }
|
---|
1891 | if (!(shiftstate & (KC_CTRL | KC_SHIFT))) {
|
---|
1892 | if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
1893 | if (FindDirCnrByName(pci->szFileName, TRUE))
|
---|
1894 | return 0;
|
---|
1895 | }
|
---|
1896 | }
|
---|
1897 | if ((shiftstate & KC_CTRL) ||
|
---|
1898 | (!(shiftstate & KC_SHIFT) &&
|
---|
1899 | ParentIsDesktop(hwnd, dcd->hwndParent) && fVTreeOpensWPS)) {
|
---|
1900 |
|
---|
1901 | ULONG size = sizeof(ULONG), flWindowAttr = CV_ICON;
|
---|
1902 | CHAR s[33];
|
---|
1903 |
|
---|
1904 | strcpy(s, "ICON");
|
---|
1905 | PrfQueryProfileData(fmprof,
|
---|
1906 | appname,
|
---|
1907 | "DirflWindowAttr",
|
---|
1908 | (PVOID) & flWindowAttr, &size);
|
---|
1909 | if (flWindowAttr & CV_DETAIL) {
|
---|
1910 | if (IsRoot(pci->szFileName))
|
---|
1911 | strcpy(s, "TREE");
|
---|
1912 | else
|
---|
1913 | strcpy(s, "DETAILS");
|
---|
1914 | }
|
---|
1915 | OpenObject(pci->szFileName, s, dcd->hwndFrame);
|
---|
1916 | return 0;
|
---|
1917 | }
|
---|
1918 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
1919 | !fDCOpens && !LastDir && !(shiftstate & KC_SHIFT))
|
---|
1920 | LastDir = FindDirCnr(dcd->hwndParent);
|
---|
1921 | if (LastDir && !fDCOpens && !(shiftstate & KC_SHIFT)) {
|
---|
1922 | WinSendMsg(LastDir,
|
---|
1923 | UM_SETDIR, MPFROMP(pci->szFileName), MPVOID);
|
---|
1924 | WinSetWindowPos(WinQueryWindow(WinQueryWindow(LastDir,
|
---|
1925 | QW_PARENT),
|
---|
1926 | QW_PARENT),
|
---|
1927 | HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | fl);
|
---|
1928 | }
|
---|
1929 | else
|
---|
1930 | OpenDirCnr(hwnd,
|
---|
1931 | dcd->hwndParent,
|
---|
1932 | dcd->hwndFrame, FALSE, pci->szFileName);
|
---|
1933 | }
|
---|
1934 | else {
|
---|
1935 | if (!(driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
1936 | DRIVE_INCLUDEFILES))
|
---|
1937 | WinSendMsg(hwnd,
|
---|
1938 | CM_REMOVERECORD,
|
---|
1939 | MPFROMP(&pci),
|
---|
1940 | MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE));
|
---|
1941 | else {
|
---|
1942 |
|
---|
1943 | SWP swp;
|
---|
1944 |
|
---|
1945 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
1946 | DefaultViewKeys(hwnd,
|
---|
1947 | dcd->hwndFrame,
|
---|
1948 | dcd->hwndParent, &swp, pci->szFileName);
|
---|
1949 | }
|
---|
1950 | }
|
---|
1951 | }
|
---|
1952 | else {
|
---|
1953 | if (!IsRoot(pci->szFileName)) {
|
---|
1954 | NotifyError(pci->szFileName, status);
|
---|
1955 | WinSendMsg(hwnd,
|
---|
1956 | CM_REMOVERECORD,
|
---|
1957 | MPFROMP(&pci),
|
---|
1958 | MPFROM2SHORT(1, CMA_FREE | CMA_INVALIDATE));
|
---|
1959 | }
|
---|
1960 | }
|
---|
1961 | }
|
---|
1962 | else if (!pci)
|
---|
1963 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
|
---|
1964 | if (fFollowTree)
|
---|
1965 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
1966 | }
|
---|
1967 | return 0;
|
---|
1968 |
|
---|
1969 | case WM_MENUEND:
|
---|
1970 | if (dcd) {
|
---|
1971 |
|
---|
1972 | HWND hwndMenu = (HWND) mp2;
|
---|
1973 |
|
---|
1974 | if (hwndMenu == TreeCnrMenu || hwndMenu == TreeMenu ||
|
---|
1975 | hwndMenu == DirMenu) {
|
---|
1976 | MarkAll(hwnd, TRUE, FALSE, TRUE);
|
---|
1977 | if (dcd->cnremphasized) {
|
---|
1978 | WinSendMsg(hwnd,
|
---|
1979 | CM_SETRECORDEMPHASIS,
|
---|
1980 | MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
1981 | dcd->cnremphasized = FALSE;
|
---|
1982 | }
|
---|
1983 | }
|
---|
1984 | }
|
---|
1985 | break;
|
---|
1986 |
|
---|
1987 | case UM_OPENWINDOWFORME:
|
---|
1988 | if (dcd) {
|
---|
1989 | if (mp1 && !IsFile((CHAR *) mp1))
|
---|
1990 | OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
|
---|
1991 | }
|
---|
1992 | return 0;
|
---|
1993 |
|
---|
1994 | case MM_PORTHOLEINIT:
|
---|
1995 | if (dcd) {
|
---|
1996 | switch (SHORT1FROMMP(mp1)) {
|
---|
1997 | case 0:
|
---|
1998 | case 1:
|
---|
1999 | {
|
---|
2000 | ULONG wmsg;
|
---|
2001 |
|
---|
2002 | wmsg = ((SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU);
|
---|
2003 | PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
|
---|
2004 | wmsg, MPVOID, MPVOID), mp1, mp2);
|
---|
2005 | }
|
---|
2006 | break;
|
---|
2007 | }
|
---|
2008 | }
|
---|
2009 | break;
|
---|
2010 |
|
---|
2011 | case UM_INITMENU:
|
---|
2012 | case WM_INITMENU:
|
---|
2013 | if (dcd) {
|
---|
2014 | switch (SHORT1FROMMP(mp1)) {
|
---|
2015 | case IDM_FILESMENU:
|
---|
2016 | {
|
---|
2017 | PCNRITEM pci;
|
---|
2018 |
|
---|
2019 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2020 | if (pci && (INT) pci != -1) {
|
---|
2021 | BOOL rdy;
|
---|
2022 | BOOL writeable;
|
---|
2023 | BOOL removable;
|
---|
2024 | BOOL remote;
|
---|
2025 | BOOL underenv;
|
---|
2026 | CHAR chDrvU;
|
---|
2027 | CHAR szDrv[CCHMAXPATH];
|
---|
2028 |
|
---|
2029 | strcpy(szDrv, pci->szFileName);
|
---|
2030 | chDrvU = *pci->szFileName;
|
---|
2031 | chDrvU = toupper(chDrvU);
|
---|
2032 | MakeValidDir(szDrv);
|
---|
2033 | rdy = *szDrv == chDrvU; // Drive not ready if MakeValidDir changes drive letter
|
---|
2034 | removable = rdy
|
---|
2035 | && (driveflags[chDrvU - 'A'] & DRIVE_REMOVABLE) != 0;
|
---|
2036 | writeable = rdy
|
---|
2037 | && !(driveflags[chDrvU - 'A'] & DRIVE_NOTWRITEABLE);
|
---|
2038 | remote = rdy && (driveflags[chDrvU - 'A'] & (DRIVE_REMOTE || DRIVE_VIRTUAL)) != 0;
|
---|
2039 | underenv = (pci->flags & RECFLAGS_UNDERENV) != 0;
|
---|
2040 |
|
---|
2041 | WinEnableMenuItem((HWND) mp2, IDM_INFO, rdy);
|
---|
2042 |
|
---|
2043 | WinEnableMenuItem((HWND) mp2, IDM_ATTRS, writeable);
|
---|
2044 | WinEnableMenuItem((HWND) mp2, IDM_EAS, writeable);
|
---|
2045 | WinEnableMenuItem((HWND) mp2, IDM_SUBJECT, writeable);
|
---|
2046 | WinEnableMenuItem((HWND) mp2, IDM_DRVFLAGS, 1); // fixme to allow if not ready
|
---|
2047 |
|
---|
2048 | WinEnableMenuItem((HWND) mp2, IDM_ARCHIVE, rdy);
|
---|
2049 |
|
---|
2050 | WinEnableMenuItem((HWND) mp2, IDM_UPDATE, !underenv);
|
---|
2051 | WinEnableMenuItem((HWND) mp2, IDM_EXPANDSUBMENU, !underenv);
|
---|
2052 | WinEnableMenuItem((HWND) mp2, IDM_EXPAND, !underenv);
|
---|
2053 | WinEnableMenuItem((HWND) mp2, IDM_COLLAPSE, !underenv);
|
---|
2054 |
|
---|
2055 | WinEnableMenuItem((HWND) mp2, IDM_SIZES, rdy);
|
---|
2056 | WinEnableMenuItem((HWND) mp2, IDM_MKDIR, writeable);
|
---|
2057 | WinEnableMenuItem((HWND) mp2, IDM_SHOWALLFILES, rdy);
|
---|
2058 | WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, writeable);
|
---|
2059 |
|
---|
2060 | WinEnableMenuItem((HWND) mp2, IDM_CHKDSK, writeable && !remote);
|
---|
2061 | WinEnableMenuItem((HWND) mp2, IDM_FORMAT, writeable && !remote);
|
---|
2062 | WinEnableMenuItem((HWND) mp2, IDM_OPTIMIZE, writeable && !remote);
|
---|
2063 | WinEnableMenuItem((HWND) mp2, IDM_PARTITIONSMENU, !remote);
|
---|
2064 |
|
---|
2065 | WinEnableMenuItem((HWND) mp2, IDM_DETACH, remote);
|
---|
2066 |
|
---|
2067 | WinEnableMenuItem((HWND) mp2, IDM_EJECT, removable);
|
---|
2068 |
|
---|
2069 | WinEnableMenuItem((HWND) mp2, IDM_LOCK, removable);
|
---|
2070 | WinEnableMenuItem((HWND) mp2, IDM_UNLOCK, removable);
|
---|
2071 |
|
---|
2072 | WinEnableMenuItem((HWND) mp2, IDM_DELETE, !underenv && writeable);
|
---|
2073 | WinEnableMenuItem((HWND) mp2, IDM_PERMDELETE, !underenv
|
---|
2074 | && writeable);
|
---|
2075 | WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, !underenv
|
---|
2076 | && writeable);
|
---|
2077 | WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, !underenv
|
---|
2078 | && writeable);
|
---|
2079 | WinEnableMenuItem((HWND) mp2, IDM_RENAME, !underenv && writeable);
|
---|
2080 |
|
---|
2081 | }
|
---|
2082 | }
|
---|
2083 | break;
|
---|
2084 |
|
---|
2085 | case IDM_VIEWSMENU:
|
---|
2086 | WinCheckMenuItem((HWND) mp2,
|
---|
2087 | IDM_MINIICONS, ((dcd->flWindowAttr & CV_MINI) != 0));
|
---|
2088 | WinEnableMenuItem((HWND) mp2, IDM_RESELECT, FALSE);
|
---|
2089 | break;
|
---|
2090 |
|
---|
2091 | case IDM_COMMANDSMENU:
|
---|
2092 | SetupCommandMenu((HWND) mp2, hwnd);
|
---|
2093 | break;
|
---|
2094 |
|
---|
2095 | case IDM_SORTSUBMENU:
|
---|
2096 | SetSortChecks((HWND) mp2, TreesortFlags);
|
---|
2097 | break;
|
---|
2098 |
|
---|
2099 | case IDM_WINDOWSMENU:
|
---|
2100 | SetupWinList((HWND) mp2,
|
---|
2101 | (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
|
---|
2102 | break;
|
---|
2103 | }
|
---|
2104 | dcd->hwndLastMenu = (HWND) mp2;
|
---|
2105 | }
|
---|
2106 | if (msg == WM_INITMENU)
|
---|
2107 | break;
|
---|
2108 | return 0;
|
---|
2109 |
|
---|
2110 | case UM_COMMAND:
|
---|
2111 | if (!mp1)
|
---|
2112 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
2113 | else {
|
---|
2114 | if (!dcd) {
|
---|
2115 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
2116 | FreeListInfo((LISTINFO *) mp1);
|
---|
2117 | }
|
---|
2118 | else {
|
---|
2119 | if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
|
---|
2120 | Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
|
---|
2121 | FreeListInfo((LISTINFO *) mp1);
|
---|
2122 | }
|
---|
2123 | else
|
---|
2124 | return (MRESULT) TRUE;
|
---|
2125 | }
|
---|
2126 | }
|
---|
2127 | return 0;
|
---|
2128 |
|
---|
2129 | case UM_LOADFILE:
|
---|
2130 | if (dcd && mp2) {
|
---|
2131 |
|
---|
2132 | HWND ret;
|
---|
2133 |
|
---|
2134 | ret = StartMLEEditor(dcd->hwndParent, (INT) mp1, (CHAR *) mp2,
|
---|
2135 | dcd->hwndFrame);
|
---|
2136 | if (mp2)
|
---|
2137 | free((CHAR *) mp2);
|
---|
2138 | return MRFROMLONG(ret);
|
---|
2139 | }
|
---|
2140 | return 0;
|
---|
2141 |
|
---|
2142 | case UM_FIXCNRMLE:
|
---|
2143 | case UM_FIXEDITNAME:
|
---|
2144 | return CommonCnrProc(hwnd, msg, mp1, mp2);
|
---|
2145 |
|
---|
2146 | case UM_NOTIFY:
|
---|
2147 | if (mp2)
|
---|
2148 | Notify((CHAR *) mp2);
|
---|
2149 | return 0;
|
---|
2150 |
|
---|
2151 | case UM_FILTER:
|
---|
2152 | if (dcd) {
|
---|
2153 |
|
---|
2154 | BOOL tempsusp = dcd->suspendview;
|
---|
2155 |
|
---|
2156 | if (mp1) {
|
---|
2157 | DosEnterCritSec();
|
---|
2158 | SetMask((CHAR *) mp1, &dcd->mask);
|
---|
2159 | DosExitCritSec();
|
---|
2160 | }
|
---|
2161 | dcd->suspendview = TRUE;
|
---|
2162 | dcd->mask.attrFile |= FILE_DIRECTORY;
|
---|
2163 | WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
|
---|
2164 | dcd->suspendview = tempsusp;
|
---|
2165 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2166 | }
|
---|
2167 | return 0;
|
---|
2168 |
|
---|
2169 | case UM_DRIVECMD:
|
---|
2170 | if (mp1)
|
---|
2171 | ShowTreeRec(hwnd, (CHAR *) mp1, FALSE, TRUE);
|
---|
2172 | return 0;
|
---|
2173 |
|
---|
2174 | case WM_APPTERMINATENOTIFY:
|
---|
2175 | {
|
---|
2176 | APPNOTIFY *info;
|
---|
2177 | PCNRITEM pci;
|
---|
2178 | CHAR s[] = " :\\";
|
---|
2179 |
|
---|
2180 | if (!mp2) {
|
---|
2181 | if (hwndMain)
|
---|
2182 | PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
|
---|
2183 | }
|
---|
2184 | info = apphead;
|
---|
2185 | while (info) {
|
---|
2186 | if (info->happ == (HAPP) mp1) {
|
---|
2187 | *s = info->device;
|
---|
2188 | pci = FindCnrRecord(hwnd, s, NULL, FALSE, FALSE, TRUE);
|
---|
2189 | if (pci && (INT) pci != -1) {
|
---|
2190 | driveserial[info->device - 'A'] = -1;
|
---|
2191 | DriveFlagsOne(info->device - 'A');
|
---|
2192 | if (driveflags[info->device - 'A'] &
|
---|
2193 | (DRIVE_INVALID | DRIVE_IGNORE))
|
---|
2194 | WinSendMsg(hwnd,
|
---|
2195 | CM_REMOVERECORD,
|
---|
2196 | MPFROMP(&pci), MPFROM2SHORT(1, CMA_FREE));
|
---|
2197 | else
|
---|
2198 | Flesh(hwnd, pci);
|
---|
2199 | }
|
---|
2200 | if (info->prev)
|
---|
2201 | info->prev->next = info->next;
|
---|
2202 | if (info->next)
|
---|
2203 | info->next->prev = info->prev;
|
---|
2204 | if (apphead == info)
|
---|
2205 | apphead = info->next;
|
---|
2206 | if (apptail == info)
|
---|
2207 | apptail = info->prev;
|
---|
2208 | free(info);
|
---|
2209 | break;
|
---|
2210 | }
|
---|
2211 | info = info->next;
|
---|
2212 | }
|
---|
2213 | }
|
---|
2214 | break;
|
---|
2215 |
|
---|
2216 | case WM_COMMAND:
|
---|
2217 | DosError(FERR_DISABLEHARDERR);
|
---|
2218 | if (dcd) {
|
---|
2219 | if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
|
---|
2220 | return 0;
|
---|
2221 | switch (SHORT1FROMMP(mp1)) {
|
---|
2222 | case IDM_SETTARGET:
|
---|
2223 | SetTargetDir(hwnd, FALSE);
|
---|
2224 | break;
|
---|
2225 |
|
---|
2226 | case IDM_DETACH:
|
---|
2227 | {
|
---|
2228 | CHAR d[3] = " :";
|
---|
2229 | PCNRITEM pci;
|
---|
2230 | PROGDETAILS pgd;
|
---|
2231 | CHAR params[368], *p;
|
---|
2232 | HAPP happ;
|
---|
2233 |
|
---|
2234 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2235 | if (pci && (INT) pci != -1 && isalpha(*pci->szFileName)) {
|
---|
2236 | *d = toupper(*pci->szFileName);
|
---|
2237 | p = GetCmdSpec(FALSE);
|
---|
2238 | memset(&pgd, 0, sizeof(pgd));
|
---|
2239 | pgd.Length = sizeof(pgd);
|
---|
2240 | pgd.progt.progc = PROG_WINDOWABLEVIO;
|
---|
2241 | pgd.progt.fbVisible = SHE_VISIBLE;
|
---|
2242 | pgd.pszTitle = GetPString(IDS_DETACHREQUESTTEXT);
|
---|
2243 | pgd.pszExecutable = p;
|
---|
2244 | pgd.pszParameters = params;
|
---|
2245 | pgd.pszStartupDir = NULL;
|
---|
2246 | pgd.pszIcon = NULL;
|
---|
2247 | pgd.pszEnvironment = NULL;
|
---|
2248 | pgd.swpInitial.hwndInsertBehind = HWND_TOP;
|
---|
2249 | pgd.swpInitial.hwnd = hwnd;
|
---|
2250 | pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
|
---|
2251 | sprintf(params, "/C NET USE %s /D", d);
|
---|
2252 | happ = WinStartApp(hwnd, &pgd, pgd.pszParameters,
|
---|
2253 | NULL, SAF_MAXIMIZED);
|
---|
2254 | if (!happ) {
|
---|
2255 | saymsg(MB_CANCEL | MB_ICONEXCLAMATION, hwnd,
|
---|
2256 | GetPString(IDS_ERRORTEXT),
|
---|
2257 | GetPString(IDS_CANTSTARTTEXT), p, params);
|
---|
2258 | }
|
---|
2259 | else {
|
---|
2260 | APPNOTIFY *info;
|
---|
2261 |
|
---|
2262 | info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__);
|
---|
2263 | if (info) {
|
---|
2264 | info->happ = happ;
|
---|
2265 | info->device = *d;
|
---|
2266 | if (!apphead)
|
---|
2267 | apphead = info;
|
---|
2268 | else {
|
---|
2269 | apptail->next = info;
|
---|
2270 | info->prev = apptail;
|
---|
2271 | }
|
---|
2272 | apptail = info;
|
---|
2273 | }
|
---|
2274 | }
|
---|
2275 | }
|
---|
2276 | }
|
---|
2277 | break;
|
---|
2278 |
|
---|
2279 | case IDM_REMAP:
|
---|
2280 | WinDlgBox(HWND_DESKTOP, hwnd, RemapDlgProc,
|
---|
2281 | FM3ModHandle, MAP_FRAME, NULL);
|
---|
2282 | break;
|
---|
2283 |
|
---|
2284 | case IDM_CONTEXTMENU:
|
---|
2285 | {
|
---|
2286 | PCNRITEM pci;
|
---|
2287 |
|
---|
2288 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2289 | PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
|
---|
2290 | MPFROMP(pci));
|
---|
2291 | }
|
---|
2292 | break;
|
---|
2293 |
|
---|
2294 | case IDM_FINDINTREE:
|
---|
2295 | {
|
---|
2296 | CHAR dir[CCHMAXPATH];
|
---|
2297 | PCNRITEM pci;
|
---|
2298 |
|
---|
2299 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2300 | if (pci && (INT) pci != -1) {
|
---|
2301 | strcpy(dir, pci->szFileName);
|
---|
2302 | MakeValidDir(dir);
|
---|
2303 | }
|
---|
2304 | else
|
---|
2305 | save_dir2(dir);
|
---|
2306 | if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
|
---|
2307 | WalkAllDlgProc,
|
---|
2308 | FM3ModHandle, WALK_FRAME, MPFROMP(dir)) && *dir)
|
---|
2309 | WinSendMsg(hwnd, UM_SHOWME, MPFROMP(dir), MPFROMLONG(1L));
|
---|
2310 | }
|
---|
2311 | break;
|
---|
2312 |
|
---|
2313 | case IDM_BEGINEDIT:
|
---|
2314 | OpenEdit(hwnd);
|
---|
2315 | break;
|
---|
2316 |
|
---|
2317 | case IDM_ENDEDIT:
|
---|
2318 | WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
|
---|
2319 | break;
|
---|
2320 |
|
---|
2321 | case IDM_FILTER:
|
---|
2322 | {
|
---|
2323 | BOOL empty = FALSE;
|
---|
2324 | PCNRITEM pci;
|
---|
2325 |
|
---|
2326 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2327 | if (!*dcd->mask.szMask)
|
---|
2328 | empty = TRUE;
|
---|
2329 | dcd->mask.fIsTree = TRUE;
|
---|
2330 | *dcd->mask.prompt = 0;
|
---|
2331 | if (pci && (INT) pci != -1)
|
---|
2332 | dcd->mask.fFilesIncluded =
|
---|
2333 | ((driveflags[toupper(*pci->szFileName) - 'A'] &
|
---|
2334 | DRIVE_INCLUDEFILES) != 0);
|
---|
2335 | else
|
---|
2336 | dcd->mask.fFilesIncluded = FALSE;
|
---|
2337 | if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
|
---|
2338 | FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
|
---|
2339 | WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
|
---|
2340 | else if (empty)
|
---|
2341 | *dcd->mask.szMask = 0;
|
---|
2342 | PrfWriteProfileData(fmprof, appname, "TreeFilter", &dcd->mask,
|
---|
2343 | sizeof(MASK));
|
---|
2344 | }
|
---|
2345 | break;
|
---|
2346 |
|
---|
2347 | case IDM_SHOWSORT:
|
---|
2348 | QuickPopup(hwnd, dcd, CheckMenu(&TreeCnrMenu, TREECNR_POPUP),
|
---|
2349 | IDM_SORTSUBMENU);
|
---|
2350 | break;
|
---|
2351 |
|
---|
2352 | case IDM_SHOWSELECT:
|
---|
2353 | QuickPopup(hwnd, dcd, CheckMenu(&TreeCnrMenu, TREECNR_POPUP),
|
---|
2354 | IDM_SELECTSUBMENU);
|
---|
2355 | break;
|
---|
2356 |
|
---|
2357 | case IDM_NOTEBOOK:
|
---|
2358 | if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
|
---|
2359 | PostMsg(dcd->hwndParent, msg, mp1, mp2);
|
---|
2360 | else
|
---|
2361 | WinDlgBox(HWND_DESKTOP, hwnd, CfgDlgProc, FM3ModHandle,
|
---|
2362 | CFG_FRAME, (PVOID) "Tree");
|
---|
2363 | break;
|
---|
2364 |
|
---|
2365 | case IDM_WALKDIR:
|
---|
2366 | case IDM_OPENWALK:
|
---|
2367 | {
|
---|
2368 | CHAR newpath[CCHMAXPATH];
|
---|
2369 | PCNRITEM pci;
|
---|
2370 |
|
---|
2371 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2372 | if (pci && (INT) pci != -1) {
|
---|
2373 | strcpy(newpath, pci->szFileName);
|
---|
2374 | MakeValidDir(newpath);
|
---|
2375 | }
|
---|
2376 | else
|
---|
2377 | save_dir2(newpath);
|
---|
2378 | if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc,
|
---|
2379 | FM3ModHandle, WALK_FRAME,
|
---|
2380 | MPFROMP(newpath)) || !*newpath)
|
---|
2381 | break;
|
---|
2382 | WinSendMsg(hwnd, UM_OPENWINDOWFORME, MPFROMP(newpath), MPVOID);
|
---|
2383 | }
|
---|
2384 | break;
|
---|
2385 |
|
---|
2386 | case IDM_HELP:
|
---|
2387 | if (hwndHelp) {
|
---|
2388 | if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
|
---|
2389 | PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
|
---|
2390 | else
|
---|
2391 | WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
|
---|
2392 | }
|
---|
2393 | break;
|
---|
2394 |
|
---|
2395 | case IDM_PARTITION:
|
---|
2396 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, NULL, NULL,
|
---|
2397 | "%s", "MINILVM.EXE");
|
---|
2398 | break;
|
---|
2399 |
|
---|
2400 | case IDM_PARTITIONDF:
|
---|
2401 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, NULL, NULL,
|
---|
2402 | "%s", "DFSOS2.EXE");
|
---|
2403 | break;
|
---|
2404 |
|
---|
2405 | case IDM_PARTITIONLVMG:
|
---|
2406 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, NULL, NULL,
|
---|
2407 | "%s", "LVMGUI.CMD");
|
---|
2408 | break;
|
---|
2409 |
|
---|
2410 | case IDM_PARTITIONFD:
|
---|
2411 | runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, NULL, NULL,
|
---|
2412 | "%s", "FDISKPM.EXE");
|
---|
2413 | break;
|
---|
2414 |
|
---|
2415 | case IDM_SORTNAME:
|
---|
2416 | case IDM_SORTFILENAME:
|
---|
2417 | case IDM_SORTSIZE:
|
---|
2418 | case IDM_SORTEASIZE:
|
---|
2419 | case IDM_SORTFIRST:
|
---|
2420 | case IDM_SORTLAST:
|
---|
2421 | case IDM_SORTLWDATE:
|
---|
2422 | case IDM_SORTLADATE:
|
---|
2423 | case IDM_SORTCRDATE:
|
---|
2424 | TreesortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
|
---|
2425 | case IDM_SORTDIRSFIRST:
|
---|
2426 | case IDM_SORTDIRSLAST:
|
---|
2427 | case IDM_SORTREVERSE:
|
---|
2428 | switch (SHORT1FROMMP(mp1)) {
|
---|
2429 | case IDM_SORTFILENAME:
|
---|
2430 | TreesortFlags |= SORT_FILENAME;
|
---|
2431 | break;
|
---|
2432 | case IDM_SORTSIZE:
|
---|
2433 | TreesortFlags |= SORT_SIZE;
|
---|
2434 | break;
|
---|
2435 | case IDM_SORTEASIZE:
|
---|
2436 | TreesortFlags |= SORT_EASIZE;
|
---|
2437 | break;
|
---|
2438 | case IDM_SORTFIRST:
|
---|
2439 | TreesortFlags |= SORT_FIRSTEXTENSION;
|
---|
2440 | break;
|
---|
2441 | case IDM_SORTLAST:
|
---|
2442 | TreesortFlags |= SORT_LASTEXTENSION;
|
---|
2443 | break;
|
---|
2444 | case IDM_SORTLWDATE:
|
---|
2445 | TreesortFlags |= SORT_LWDATE;
|
---|
2446 | break;
|
---|
2447 | case IDM_SORTLADATE:
|
---|
2448 | TreesortFlags |= SORT_LADATE;
|
---|
2449 | break;
|
---|
2450 | case IDM_SORTCRDATE:
|
---|
2451 | TreesortFlags |= SORT_CRDATE;
|
---|
2452 | break;
|
---|
2453 | case IDM_SORTDIRSFIRST:
|
---|
2454 | if (TreesortFlags & SORT_DIRSFIRST)
|
---|
2455 | TreesortFlags &= (~SORT_DIRSFIRST);
|
---|
2456 | else {
|
---|
2457 | TreesortFlags |= SORT_DIRSFIRST;
|
---|
2458 | TreesortFlags &= (~SORT_DIRSLAST);
|
---|
2459 | }
|
---|
2460 | break;
|
---|
2461 | case IDM_SORTDIRSLAST:
|
---|
2462 | if (TreesortFlags & SORT_DIRSLAST)
|
---|
2463 | TreesortFlags &= (~SORT_DIRSLAST);
|
---|
2464 | else {
|
---|
2465 | TreesortFlags |= SORT_DIRSLAST;
|
---|
2466 | TreesortFlags &= (~SORT_DIRSFIRST);
|
---|
2467 | }
|
---|
2468 | break;
|
---|
2469 | case IDM_SORTREVERSE:
|
---|
2470 | if (TreesortFlags & SORT_REVERSE)
|
---|
2471 | TreesortFlags &= (~SORT_REVERSE);
|
---|
2472 | else
|
---|
2473 | TreesortFlags |= SORT_REVERSE;
|
---|
2474 | break;
|
---|
2475 | }
|
---|
2476 | PrfWriteProfileData(fmprof, appname, "TreeSort", &TreesortFlags,
|
---|
2477 | sizeof(INT));
|
---|
2478 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
|
---|
2479 | break;
|
---|
2480 |
|
---|
2481 | case IDM_COLLECT:
|
---|
2482 | if (!Collector) {
|
---|
2483 |
|
---|
2484 | HWND hwndC;
|
---|
2485 | SWP swp;
|
---|
2486 |
|
---|
2487 | if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
|
---|
2488 | !fAutoTile &&
|
---|
2489 | (!fExternalCollector && *(ULONG *) realappname == FM3UL))
|
---|
2490 | GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
|
---|
2491 | hwndC = StartCollector((fExternalCollector ||
|
---|
2492 | *(ULONG *) realappname != FM3UL) ?
|
---|
2493 | HWND_DESKTOP : dcd->hwndParent, 4);
|
---|
2494 | if (hwndC) {
|
---|
2495 | if (!ParentIsDesktop(hwnd,
|
---|
2496 | dcd->hwndParent) &&
|
---|
2497 | !fAutoTile &&
|
---|
2498 | (!fExternalCollector && *(ULONG *) realappname == FM3UL))
|
---|
2499 | WinSetWindowPos(hwndC,
|
---|
2500 | HWND_TOP,
|
---|
2501 | swp.x,
|
---|
2502 | swp.y,
|
---|
2503 | swp.cx,
|
---|
2504 | swp.cy,
|
---|
2505 | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
|
---|
2506 | else if (!ParentIsDesktop(hwnd,
|
---|
2507 | dcd->hwndParent) &&
|
---|
2508 | fAutoTile && *(ULONG *) realappname == FM3UL)
|
---|
2509 | TileChildren(dcd->hwndParent, TRUE);
|
---|
2510 | }
|
---|
2511 | WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
|
---|
2512 | DosSleep(250L);
|
---|
2513 | }
|
---|
2514 | else
|
---|
2515 | StartCollector(dcd->hwndParent, 4);
|
---|
2516 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
|
---|
2517 | break;
|
---|
2518 |
|
---|
2519 | case IDM_COLLECTOR:
|
---|
2520 | DosSleep(64L);
|
---|
2521 | {
|
---|
2522 | CHAR **list;
|
---|
2523 |
|
---|
2524 | list = BuildList(hwnd);
|
---|
2525 | if (list) {
|
---|
2526 | if (Collector) {
|
---|
2527 | if (!PostMsg(Collector, WM_COMMAND,
|
---|
2528 | MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
|
---|
2529 | FreeList(list);
|
---|
2530 | }
|
---|
2531 | else
|
---|
2532 | FreeList(list);
|
---|
2533 | }
|
---|
2534 | }
|
---|
2535 | break;
|
---|
2536 |
|
---|
2537 | case IDM_COLLAPSEALL:
|
---|
2538 | WinSendMsg(hwnd, CM_COLLAPSETREE, MPVOID, MPVOID);
|
---|
2539 | break;
|
---|
2540 |
|
---|
2541 | case IDM_COLLAPSE:
|
---|
2542 | case IDM_EXPAND:
|
---|
2543 | {
|
---|
2544 | PCNRITEM pci = NULL;
|
---|
2545 |
|
---|
2546 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2547 | if (pci && (INT) pci != -1) {
|
---|
2548 | if (pci->flags & RECFLAGS_UNDERENV)
|
---|
2549 | break;
|
---|
2550 | PostMsg(dcd->hwndObject, UM_EXPAND, mp1, MPFROMP(pci));
|
---|
2551 | }
|
---|
2552 | }
|
---|
2553 | break;
|
---|
2554 |
|
---|
2555 | case IDM_UPDATE:
|
---|
2556 | {
|
---|
2557 | PCNRITEM pci = (PCNRITEM)CurrentRecord(hwnd);
|
---|
2558 | if (pci && (INT)pci != -1) {
|
---|
2559 | UINT driveflag = driveflags[toupper(*pci->szFileName) - 'A'];
|
---|
2560 | if (pci->attrFile & FILE_DIRECTORY) {
|
---|
2561 | if (pci->flags & RECFLAGS_UNDERENV)
|
---|
2562 | break;
|
---|
2563 | UnFlesh(hwnd, pci);
|
---|
2564 | // Check if drive type might need update
|
---|
2565 | if ((driveflag & (DRIVE_INVALID | DRIVE_NOPRESCAN)) ||
|
---|
2566 | (~driveflag & DRIVE_NOPRESCAN && pci->rc.hptrIcon == hptrDunno))
|
---|
2567 | {
|
---|
2568 | driveflags[toupper(*pci->szFileName) - 'A'] &=
|
---|
2569 | (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
|
---|
2570 | DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | DRIVE_NOSTATS);
|
---|
2571 | DriveFlagsOne(toupper(*pci->szFileName) - 'A');
|
---|
2572 | driveflag = driveflags[toupper(*pci->szFileName) - 'A'];
|
---|
2573 | if (driveflag & DRIVE_INVALID)
|
---|
2574 | pci->rc.hptrIcon = hptrDunno;
|
---|
2575 | else {
|
---|
2576 | SelectDriveIcon(pci);
|
---|
2577 | }
|
---|
2578 | WinSendMsg(hwnd,
|
---|
2579 | CM_INVALIDATERECORD,
|
---|
2580 | MPFROMP(&pci),
|
---|
2581 | MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
|
---|
2582 | if (hwndMain)
|
---|
2583 | PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
|
---|
2584 | }
|
---|
2585 | if (~driveflag & DRIVE_INVALID)
|
---|
2586 | Flesh(hwnd, pci);
|
---|
2587 | }
|
---|
2588 | }
|
---|
2589 | }
|
---|
2590 | break;
|
---|
2591 |
|
---|
2592 | case IDM_RESCAN:
|
---|
2593 | PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
|
---|
2594 | break;
|
---|
2595 |
|
---|
2596 | case IDM_RESORT:
|
---|
2597 | WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortTreeCnr), MPVOID);
|
---|
2598 | break;
|
---|
2599 |
|
---|
2600 | case IDM_TEXT:
|
---|
2601 | case IDM_MINIICONS:
|
---|
2602 | {
|
---|
2603 | CNRINFO cnri;
|
---|
2604 |
|
---|
2605 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
2606 | cnri.cb = sizeof(CNRINFO);
|
---|
2607 | WinSendMsg(hwnd,
|
---|
2608 | CM_QUERYCNRINFO,
|
---|
2609 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
2610 | if (SHORT1FROMMP(mp1) == IDM_MINIICONS) {
|
---|
2611 | if (cnri.flWindowAttr & CV_MINI)
|
---|
2612 | cnri.flWindowAttr &= (~CV_MINI);
|
---|
2613 | else
|
---|
2614 | cnri.flWindowAttr |= CV_MINI;
|
---|
2615 | }
|
---|
2616 | else {
|
---|
2617 | if (cnri.flWindowAttr & CV_TEXT) {
|
---|
2618 | cnri.flWindowAttr &= (~CV_TEXT);
|
---|
2619 | cnri.flWindowAttr |= CV_ICON;
|
---|
2620 | }
|
---|
2621 | else {
|
---|
2622 | cnri.flWindowAttr &= (~CV_ICON);
|
---|
2623 | cnri.flWindowAttr |= CV_TEXT;
|
---|
2624 | }
|
---|
2625 | }
|
---|
2626 | dcd->flWindowAttr = cnri.flWindowAttr;
|
---|
2627 | PrfWriteProfileData(fmprof,
|
---|
2628 | appname,
|
---|
2629 | "TreeflWindowAttr",
|
---|
2630 | &cnri.flWindowAttr, sizeof(ULONG));
|
---|
2631 | WinSendMsg(hwnd,
|
---|
2632 | CM_SETCNRINFO,
|
---|
2633 | MPFROMP(&cnri),
|
---|
2634 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_TREEICON |
|
---|
2635 | CMA_SLTREEBITMAPORICON));
|
---|
2636 | }
|
---|
2637 | break;
|
---|
2638 |
|
---|
2639 | case IDM_SIZES:
|
---|
2640 | case IDM_DRVFLAGS:
|
---|
2641 | case IDM_SHOWALLFILES:
|
---|
2642 | case IDM_UNDELETE:
|
---|
2643 | case IDM_OPTIMIZE:
|
---|
2644 | case IDM_CHKDSK:
|
---|
2645 | case IDM_FORMAT:
|
---|
2646 | case IDM_MKDIR:
|
---|
2647 | case IDM_LOCK:
|
---|
2648 | case IDM_UNLOCK:
|
---|
2649 | case IDM_EJECT:
|
---|
2650 | case IDM_CLOSETRAY:
|
---|
2651 | {
|
---|
2652 | PCNRITEM pci;
|
---|
2653 |
|
---|
2654 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2655 | if (pci && (INT) pci != -1)
|
---|
2656 | CommonDriveCmd(hwnd, pci->szFileName, SHORT1FROMMP(mp1));
|
---|
2657 | }
|
---|
2658 | break;
|
---|
2659 |
|
---|
2660 | case IDM_SAVETOLIST:
|
---|
2661 | WinDlgBox(HWND_DESKTOP,
|
---|
2662 | hwnd,
|
---|
2663 | SaveListDlgProc, FM3ModHandle, SAV_FRAME, MPFROMP(&hwnd));
|
---|
2664 | break;
|
---|
2665 |
|
---|
2666 | case IDM_DELETE:
|
---|
2667 | case IDM_PERMDELETE:
|
---|
2668 | case IDM_MOVE:
|
---|
2669 | case IDM_WPSMOVE:
|
---|
2670 | case IDM_WILDMOVE:
|
---|
2671 | case IDM_RENAME:
|
---|
2672 | {
|
---|
2673 | PCNRITEM pci;
|
---|
2674 |
|
---|
2675 | pci = (PCNRITEM) CurrentRecord(hwnd);
|
---|
2676 | if (pci && (INT) pci != -1) {
|
---|
2677 | if (pci->flags & RECFLAGS_UNDERENV)
|
---|
2678 | break;
|
---|
2679 | }
|
---|
2680 | }
|
---|
2681 | /* else intentional fallthru */
|
---|
2682 | case IDM_ATTRS:
|
---|
2683 | case IDM_INFO:
|
---|
2684 | case IDM_COPY:
|
---|
2685 | case IDM_WPSCOPY:
|
---|
2686 | case IDM_WILDCOPY:
|
---|
2687 | case IDM_DOITYOURSELF:
|
---|
2688 | case IDM_OPENWINDOW:
|
---|
2689 | case IDM_OPENSETTINGS:
|
---|
2690 | case IDM_OPENDEFAULT:
|
---|
2691 | case IDM_OPENICON:
|
---|
2692 | case IDM_OPENDETAILS:
|
---|
2693 | case IDM_OPENTREE:
|
---|
2694 | case IDM_SHADOW:
|
---|
2695 | case IDM_SHADOW2:
|
---|
2696 | case IDM_COMPARE:
|
---|
2697 | case IDM_VIEW:
|
---|
2698 | case IDM_VIEWTEXT:
|
---|
2699 | case IDM_VIEWBINARY:
|
---|
2700 | case IDM_EDIT:
|
---|
2701 | case IDM_EDITTEXT:
|
---|
2702 | case IDM_EDITBINARY:
|
---|
2703 | case IDM_EAS:
|
---|
2704 | case IDM_SUBJECT:
|
---|
2705 | case IDM_APPENDTOCLIP:
|
---|
2706 | case IDM_SAVETOCLIP:
|
---|
2707 | case IDM_ARCHIVE:
|
---|
2708 | case IDM_MCIPLAY:
|
---|
2709 | case IDM_UUDECODE:
|
---|
2710 | {
|
---|
2711 | LISTINFO *li;
|
---|
2712 | ULONG action = UM_ACTION;
|
---|
2713 |
|
---|
2714 | li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
|
---|
2715 | if (li) {
|
---|
2716 | li->type = SHORT1FROMMP(mp1);
|
---|
2717 | li->hwnd = hwnd;
|
---|
2718 | li->list = BuildList(hwnd);
|
---|
2719 | if (!li->list || !li->list[0]) {
|
---|
2720 | free(li);
|
---|
2721 | break;
|
---|
2722 | }
|
---|
2723 | if (IsRoot(li->list[0])) {
|
---|
2724 | switch (SHORT1FROMMP(mp1)) {
|
---|
2725 | case IDM_MOVE:
|
---|
2726 | case IDM_COPY:
|
---|
2727 | case IDM_WILDCOPY:
|
---|
2728 | case IDM_WILDMOVE:
|
---|
2729 | case IDM_WPSMOVE:
|
---|
2730 | case IDM_WPSCOPY:
|
---|
2731 | case IDM_RENAME:
|
---|
2732 | case IDM_DELETE:
|
---|
2733 | case IDM_PERMDELETE:
|
---|
2734 | mp1 = MPFROM2SHORT(IDM_INFO, SHORT2FROMMP(mp1));
|
---|
2735 | li->type = IDM_INFO;
|
---|
2736 | break;
|
---|
2737 | }
|
---|
2738 | }
|
---|
2739 | switch (SHORT1FROMMP(mp1)) {
|
---|
2740 | case IDM_APPENDTOCLIP:
|
---|
2741 | case IDM_SAVETOCLIP:
|
---|
2742 | case IDM_ARCHIVE:
|
---|
2743 | case IDM_DELETE:
|
---|
2744 | case IDM_PERMDELETE:
|
---|
2745 | case IDM_ATTRS:
|
---|
2746 | case IDM_SHADOW:
|
---|
2747 | case IDM_SHADOW2:
|
---|
2748 | case IDM_DOITYOURSELF:
|
---|
2749 | case IDM_EAS:
|
---|
2750 | case IDM_VIEW:
|
---|
2751 | case IDM_VIEWTEXT:
|
---|
2752 | case IDM_VIEWBINARY:
|
---|
2753 | case IDM_EDIT:
|
---|
2754 | case IDM_EDITTEXT:
|
---|
2755 | case IDM_EDITBINARY:
|
---|
2756 | case IDM_MCIPLAY:
|
---|
2757 | action = UM_MASSACTION;
|
---|
2758 | break;
|
---|
2759 | }
|
---|
2760 | if (SHORT1FROMMP(mp1) == IDM_SHADOW ||
|
---|
2761 | SHORT1FROMMP(mp1) == IDM_SHADOW2)
|
---|
2762 | *li->targetpath = 0;
|
---|
2763 | if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
|
---|
2764 | Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
|
---|
2765 | FreeListInfo(li);
|
---|
2766 | }
|
---|
2767 | }
|
---|
2768 | }
|
---|
2769 | break;
|
---|
2770 |
|
---|
2771 | default:
|
---|
2772 | if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
|
---|
2773 | SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
|
---|
2774 |
|
---|
2775 | INT x;
|
---|
2776 |
|
---|
2777 | if (!cmdloaded)
|
---|
2778 | load_commands();
|
---|
2779 | x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
|
---|
2780 | if (x >= 0) {
|
---|
2781 | x++;
|
---|
2782 | RunCommand(hwnd, x);
|
---|
2783 | if (fUnHilite)
|
---|
2784 | UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
|
---|
2785 | }
|
---|
2786 | }
|
---|
2787 | break;
|
---|
2788 | }
|
---|
2789 | }
|
---|
2790 | return 0;
|
---|
2791 |
|
---|
2792 | case WM_SAVEAPPLICATION:
|
---|
2793 | if (dcd && !ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
2794 |
|
---|
2795 | SWP swp, swpP;
|
---|
2796 | INT ratio;
|
---|
2797 |
|
---|
2798 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
2799 | if (!(swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE | SWP_HIDE))) {
|
---|
2800 | WinQueryWindowPos(dcd->hwndParent, &swpP);
|
---|
2801 | ratio = (swpP.cx * 100) / swp.cx;
|
---|
2802 | if (ratio > 0)
|
---|
2803 | PrfWriteProfileData(fmprof, appname, "TreeWindowRatio",
|
---|
2804 | &ratio, sizeof(INT));
|
---|
2805 | }
|
---|
2806 | }
|
---|
2807 | else if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
|
---|
2808 |
|
---|
2809 | SWP swp;
|
---|
2810 |
|
---|
2811 | WinQueryWindowPos(dcd->hwndFrame, &swp);
|
---|
2812 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
|
---|
2813 | WinStoreWindowPos(FM2Str, "VTreeWindowPos", dcd->hwndFrame);
|
---|
2814 | }
|
---|
2815 | break;
|
---|
2816 |
|
---|
2817 | case UM_MINIMIZE:
|
---|
2818 | if (dcd && hwndMain) {
|
---|
2819 | fOkayMinimize = TRUE;
|
---|
2820 | if (dcd->hwndObject && !fDummy) {
|
---|
2821 | DosSleep(100L);
|
---|
2822 | if (!fDummy) {
|
---|
2823 | fOkayMinimize = FALSE;
|
---|
2824 | WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
|
---|
2825 | dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0,
|
---|
2826 | SWP_MINIMIZE | SWP_DEACTIVATE);
|
---|
2827 | }
|
---|
2828 | }
|
---|
2829 | }
|
---|
2830 | return 0;
|
---|
2831 |
|
---|
2832 | case UM_MAXIMIZE:
|
---|
2833 | if (dcd || hwndMain)
|
---|
2834 | WinSetWindowPos(((hwndMain) ? WinQueryWindow(hwndMain, QW_PARENT) :
|
---|
2835 | dcd->hwndFrame), HWND_TOP, 0, 0, 0, 0, SWP_MAXIMIZE |
|
---|
2836 | SWP_SHOW);
|
---|
2837 | return 0;
|
---|
2838 |
|
---|
2839 | case UM_CLOSE:
|
---|
2840 | {
|
---|
2841 | HWND hwndParent = WinQueryWindow(WinQueryWindow(WinQueryWindow(hwnd,
|
---|
2842 | QW_PARENT),
|
---|
2843 | QW_PARENT), QW_PARENT);
|
---|
2844 |
|
---|
2845 | if (!mp1) {
|
---|
2846 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
2847 | WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
2848 | if (hwndParent && !ParentIsDesktop(hwnd, hwndParent))
|
---|
2849 | WinDestroyWindow(hwndParent);
|
---|
2850 | }
|
---|
2851 | else
|
---|
2852 | WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
2853 | QW_PARENT));
|
---|
2854 | }
|
---|
2855 | return 0;
|
---|
2856 |
|
---|
2857 | case WM_CLOSE:
|
---|
2858 | WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
|
---|
2859 | if (dcd)
|
---|
2860 | dcd->stopflag++;
|
---|
2861 | if (dcd && dcd->hwndObject) {
|
---|
2862 | /* kill object window */
|
---|
2863 | if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
|
---|
2864 | WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
|
---|
2865 | }
|
---|
2866 | else
|
---|
2867 | WinSendMsg(hwnd, UM_CLOSE, MPFROMLONG(1L), MPVOID);
|
---|
2868 | return 0;
|
---|
2869 |
|
---|
2870 | case WM_DESTROY:
|
---|
2871 | if (TreeCnrMenu)
|
---|
2872 | WinDestroyWindow(TreeCnrMenu);
|
---|
2873 | if (DirMenu)
|
---|
2874 | WinDestroyWindow(DirMenu);
|
---|
2875 | if (FileMenu)
|
---|
2876 | WinDestroyWindow(FileMenu);
|
---|
2877 | TreeCnrMenu = FileMenu = DirMenu = (HWND) 0;
|
---|
2878 | EmptyCnr(hwnd);
|
---|
2879 | if (apphead) {
|
---|
2880 |
|
---|
2881 | APPNOTIFY *info, *next;
|
---|
2882 |
|
---|
2883 | info = apphead;
|
---|
2884 | while (info) {
|
---|
2885 | next = info->next;
|
---|
2886 | free(info);
|
---|
2887 | info = next;
|
---|
2888 | }
|
---|
2889 | apphead = apptail = NULL;
|
---|
2890 | }
|
---|
2891 | break;
|
---|
2892 | }
|
---|
2893 | return (dcd && dcd->oldproc) ? dcd->oldproc(hwnd, msg, mp1, mp2) :
|
---|
2894 | PFNWPCnr(hwnd, msg, mp1, mp2);
|
---|
2895 | }
|
---|
2896 |
|
---|
2897 | HWND StartTreeCnr(HWND hwndParent, ULONG flags)
|
---|
2898 | {
|
---|
2899 | /* bitmapped flags:
|
---|
2900 | * 0x00000001 = don't close app when window closes
|
---|
2901 | * 0x00000002 = no frame controls
|
---|
2902 | */
|
---|
2903 |
|
---|
2904 | HWND hwndFrame = (HWND) 0, hwndClient;
|
---|
2905 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
|
---|
2906 | FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
|
---|
2907 | DIRCNRDATA *dcd;
|
---|
2908 |
|
---|
2909 | if (!hwndParent)
|
---|
2910 | hwndParent = HWND_DESKTOP;
|
---|
2911 | if (ParentIsDesktop(hwndParent, hwndParent))
|
---|
2912 | FrameFlags |= (FCF_TASKLIST | FCF_MENU);
|
---|
2913 | if (flags & 2)
|
---|
2914 | FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
|
---|
2915 | FCF_MINMAX | FCF_ICON));
|
---|
2916 | hwndFrame = WinCreateStdWindow(hwndParent,
|
---|
2917 | WS_VISIBLE,
|
---|
2918 | &FrameFlags,
|
---|
2919 | WC_TREECONTAINER,
|
---|
2920 | NULL,
|
---|
2921 | WS_VISIBLE | fwsAnimate,
|
---|
2922 | FM3ModHandle, TREE_FRAME, &hwndClient);
|
---|
2923 | if (hwndFrame && hwndClient) {
|
---|
2924 | dcd = xmalloc(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
|
---|
2925 | if (!dcd) {
|
---|
2926 | Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_OUTOFMEMORY));
|
---|
2927 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
---|
2928 | hwndFrame = (HWND) 0;
|
---|
2929 | }
|
---|
2930 | else {
|
---|
2931 | SWP swp;
|
---|
2932 |
|
---|
2933 | WinQueryWindowPos(hwndFrame, &swp);
|
---|
2934 | if (*(ULONG *) realappname == FM3UL) {
|
---|
2935 | if (!WinCreateWindow(hwndFrame,
|
---|
2936 | WC_TREEOPENBUTTON,
|
---|
2937 | "O",
|
---|
2938 | WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
|
---|
2939 | ((swp.cx -
|
---|
2940 | WinQuerySysValue(HWND_DESKTOP,
|
---|
2941 | SV_CXMINMAXBUTTON)) -
|
---|
2942 | WinQuerySysValue(HWND_DESKTOP,
|
---|
2943 | SV_CXMINMAXBUTTON) / 2) -
|
---|
2944 | WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER),
|
---|
2945 | (swp.cy -
|
---|
2946 | WinQuerySysValue(HWND_DESKTOP,
|
---|
2947 | SV_CYMINMAXBUTTON)) -
|
---|
2948 | WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER),
|
---|
2949 | WinQuerySysValue(HWND_DESKTOP,
|
---|
2950 | SV_CXMINMAXBUTTON) / 2,
|
---|
2951 | WinQuerySysValue(HWND_DESKTOP,
|
---|
2952 | SV_CYMINMAXBUTTON), hwndFrame,
|
---|
2953 | HWND_TOP, IDM_OPENWINDOW, NULL, NULL)) {
|
---|
2954 | Win_Error2(hwndFrame, hwndParent, pszSrcFile, __LINE__,
|
---|
2955 | IDS_WINCREATEWINDOW);
|
---|
2956 | }
|
---|
2957 | }
|
---|
2958 | else {
|
---|
2959 | if (!WinCreateWindow(hwndFrame,
|
---|
2960 | WC_TREESTATUS,
|
---|
2961 | GetPString(IDS_YOUAREHERETEXT),
|
---|
2962 | WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER,
|
---|
2963 | swp.x + 4 + WinQuerySysValue(HWND_DESKTOP,
|
---|
2964 | SV_CXSIZEBORDER),
|
---|
2965 | swp.cy - (22 + WinQuerySysValue(HWND_DESKTOP,
|
---|
2966 | SV_CYSIZEBORDER)),
|
---|
2967 | (swp.cx - 8) - (WinQuerySysValue(HWND_DESKTOP,
|
---|
2968 | SV_CXSIZEBORDER)
|
---|
2969 | * 2), 22, hwndFrame, HWND_TOP,
|
---|
2970 | MAIN_STATUS, NULL, NULL)) {
|
---|
2971 | Win_Error2(hwndFrame, hwndParent, pszSrcFile, __LINE__,
|
---|
2972 | IDS_WINCREATEWINDOW);
|
---|
2973 | }
|
---|
2974 | }
|
---|
2975 | memset(dcd, 0, sizeof(DIRCNRDATA));
|
---|
2976 | dcd->size = sizeof(DIRCNRDATA);
|
---|
2977 | dcd->type = TREE_FRAME;
|
---|
2978 | dcd->dontclose = ((flags & 1) != 0);
|
---|
2979 | dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
|
---|
2980 | dcd->hwndClient = hwndClient;
|
---|
2981 | dcd->hwndFrame = hwndFrame;
|
---|
2982 | {
|
---|
2983 | PFNWP oldproc;
|
---|
2984 |
|
---|
2985 | oldproc = WinSubclassWindow(hwndFrame, TreeFrameWndProc);
|
---|
2986 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
|
---|
2987 | oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR),
|
---|
2988 | (PFNWP) TreeTitleWndProc);
|
---|
2989 | WinSetWindowPtr(WinWindowFromID(hwndFrame, FID_TITLEBAR),
|
---|
2990 | QWL_USER, (PVOID) oldproc);
|
---|
2991 | }
|
---|
2992 | dcd->hwndCnr = WinCreateWindow(hwndClient,
|
---|
2993 | WC_CONTAINER,
|
---|
2994 | NULL,
|
---|
2995 | CCS_AUTOPOSITION | CCS_MINIICONS |
|
---|
2996 | CCS_MINIRECORDCORE | WS_VISIBLE,
|
---|
2997 | 0,
|
---|
2998 | 0,
|
---|
2999 | 0,
|
---|
3000 | 0,
|
---|
3001 | hwndClient,
|
---|
3002 | HWND_TOP, (ULONG) TREE_CNR, NULL, NULL);
|
---|
3003 | if (!dcd->hwndCnr) {
|
---|
3004 | Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
|
---|
3005 | IDS_WINCREATEWINDOW);
|
---|
3006 | PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
|
---|
3007 | free(dcd);
|
---|
3008 | hwndFrame = (HWND) 0;
|
---|
3009 | }
|
---|
3010 | else {
|
---|
3011 | WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
|
---|
3012 | if (ParentIsDesktop(hwndFrame, hwndParent)) {
|
---|
3013 | WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR), "VTree");
|
---|
3014 | FixSwitchList(hwndFrame, "VTree");
|
---|
3015 | }
|
---|
3016 | else {
|
---|
3017 | WinSetWindowText(hwndFrame, GetPString(IDS_TREETEXT));
|
---|
3018 | WinSetWindowText(WinWindowFromID(hwndFrame, FID_TITLEBAR),
|
---|
3019 | GetPString(IDS_TREETEXT));
|
---|
3020 | }
|
---|
3021 | dcd->oldproc = WinSubclassWindow(dcd->hwndCnr, TreeCnrWndProc);
|
---|
3022 | if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
|
---|
3023 | WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
|
---|
3024 | }
|
---|
3025 | }
|
---|
3026 | }
|
---|
3027 | return hwndFrame;
|
---|
3028 | }
|
---|