source: trunk/dll/treecnr.c@ 953

Last change on this file since 953 was 953, checked in by Steven Levine, 18 years ago

Rework code and resources to support settings menu conditional cascade
Optimize last settings menu save/restore

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