source: trunk/dll/treecnr.c@ 551

Last change on this file since 551 was 551, checked in by Gregg Young, 19 years ago

Indentation cleanup

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