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