source: trunk/dll/treecnr.c@ 985

Last change on this file since 985 was 985, checked in by Gregg Young, 17 years ago

Update sizes dialog (ticket 44); Make max command line length user settable (ticket 199); use xfree for free in most cases (ticket 212); initial code to check for valid ini file (ticket 102); Some additional refactoring and structure rework; Some documentation updates;

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