source: trunk/dll/treecnr.c@ 1178

Last change on this file since 1178 was 1178, checked in by John Small, 17 years ago

Ticket 187: Draft 2: Move remaining function declarations

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