source: trunk/dll/treecnr.c@ 793

Last change on this file since 793 was 793, checked in by Gregg Young, 18 years ago

Move #pragma alloc_text to end for OpenWatcom compat

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