source: trunk/dll/treecnr.c@ 1157

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

Ticket 187: Draft 1: Functions only

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