source: trunk/dll/treecnr.c@ 1227

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

Ticket 187: Moved typedef's and some #define's from fm3dll.h

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