source: trunk/dll/treecnr.c@ 1411

Last change on this file since 1411 was 1411, checked in by Steven Levine, 16 years ago

Rework extended container search to use common logic
Update docs to match code
Shift now reverses configured state of extended container search enable
Backslash optional in not ambiguous

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