source: trunk/dll/treecnr.c@ 1391

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

Move nontranslated strings to init.c and codepage.c; use those strings in place of GetPString calls. Move other strings to a StringTable; minor cleanup and code changes to codepage.c to use a string array instead of GetPString calls. Ticket 340

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