source: trunk/dll/dircnrs.c@ 1777

Last change on this file since 1777 was 1777, checked in by Steven Levine, 11 years ago

Rework FM/2 Config menu. Add confirm delete toggle. (Steven)
Rework FM/2 Lite Config menu. Add drag&drop dialog toggle and confirm delete toggles. (Steven)
Correct View, Sort and Filter button initialization. (Steven)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 105.6 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 1777 2014-06-13 01:51:31Z stevenhl $
5
6 Directory containers
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2010 Steven H. Levine
10
11 16 Oct 02 SHL Handle large partitions
12 01 Aug 04 SHL Rework lstrip/rstrip usage
13 23 May 05 SHL Use QWL_USER
14 24 May 05 SHL Rework Win_Error usage
15 25 May 05 SHL Use ULONGLONG and CommaFmtULL
16 26 May 05 SHL More large file formatting updates
17 05 Jun 05 SHL Use QWL_USER
18 10 Nov 05 SHL Comments
19 13 Jul 06 SHL Use Runtime_Error
20 26 Jul 06 SHL Use chop_at_crnl
21 15 Aug 06 SHL Rework warning message text
22 07 Jan 07 GKY Move error strings etc. to string file
23 30 Mar 07 GKY Remove GetPString for window class names
24 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
25 06 Apr 07 GKY Add some error checking in drag/drop
26 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checking.
27 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
28 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
29 02 Aug 07 SHL Sync with CNRITEM mods
30 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
31 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
32 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
33 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
34 10 Jan 08 SHL Sync with CfgDlgProc mods
35 19 Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
36 15 Feb 08 SHL Sync with settings menu rework
37 22 Feb 08 JBS Ticket 230: Fix/improve various code related to state or presparam values in the INI file.
38 11 May 08 GKY Avoid using stale dcd after free
39 11 May 08 SHL Add stale dcd sanity checks
40 21 Jun 08 GKY Fix columns to honor preferences on new container open.
41 22 Jun 08 GKY Included free_... functions for fortify checking
42 06 Jul 08 GKY Update delete/undelete to include move to and open XWP trashcan
43 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
44 all the details view settings (both the global variables and those in the
45 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
46 20 Jul 08 GKY Add save/append filename to clipboard.
47 Change menu wording to make these easier to find
48 02 Aug 08 GKY Always pass temp variable point to treecnr UM_SHOWME to avoid
49 freeing dcd->directory early
50 25 Aug 08 GKY Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if
51 less than 10 KiB (It hangs and can't be closed)
52 29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate.
53 10 Dec 08 SHL Integrate exception handler support
54 26 Dec 08 GKY Fixed DROPHELP to check for copy as default is action is DO_DEFAULT
55 01 Jan 09 GKY Add Seek and Scan to drives & directory context menus pass drive/dir as search root
56 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
57 07 Feb 09 GKY Move repeated strings to PCSZs.
58 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
59 07 Feb 09 GKY Add *DateFormat functions to format dates based on locale
60 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
61 08 Mar 09 GKY Additional strings move to PCSZs in init.c
62 12 Mar 09 SHL Use common SearchContainer
63 14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring
64 29 Mar 09 SHL Keep more keys away from PM if extended search in progress
65 29 Mar 09 SHL Increase extended search timeout to 3 seconds
66 28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
67 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
68 22 Jul 09 SHL Cleanup of SETFOCUS code
69 14 Sep 09 SHL Drop experimental code
70 15 Sep 09 SHL Show rescan progress while filling container
71 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
72 profile calls for user settings that work and are setable in more than one
73 miniapp; FM3Str should be used for setting only relavent to FM/2 or that
74 aren't user settable; realappname should be used for setting applicable to
75 one or more miniapp but not to FM/2
76 17 Jan 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10).
77 Mostly cast CHAR CONSTANT * as CHAR *.
78 28 May 10 GKY Yet another attempt to prevent duplicate directory names in the tree by
79 suppressing SHOW_ME during initial drive scan.
80 20 Nov 10 GKY Rework scanning code to remove redundant scans, prevent double directory
81 entries in the tree container, fix related semaphore performance using
82 combination of event and mutex semaphores
83 04 Aug 12 GKY Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of
84 copy, move and delete operations
85 22 Feb 14 GKY Fix warn readonly yes don't ask to work when recursing directories.
86 02 Mar 14 GKY Speed up intial drive scans Ticket 528
87
88***********************************************************************/
89
90#include <stdlib.h>
91#include <string.h>
92#include <ctype.h>
93#include <limits.h>
94// #include <process.h> // _beginthread
95
96#define INCL_DOS
97#define INCL_WIN
98#define INCL_DOSERRORS
99#define INCL_LONGLONG
100#define INCL_WINWORKPLACE
101
102#include "fm3dll.h"
103#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
104#include "mainwnd2.h" // Data declaration(s)
105#include "grep.h" // Data declaration(s)
106#include "info.h" // Data declaration(s)
107#include "treecnr.h" // Data declaration(s)
108#include "dircnrs.h" // Data declaration(s)
109#include "init.h" // Data declaration(s)
110#include "fm3dlg.h"
111#include "fm3str.h"
112#include "mle.h"
113#include "arccnrs.h" // StartArcCnr
114#include "comp.h" // COMPARE
115#include "filldir.h" // EmptyCnr...
116#include "errutil.h" // Dos_Error...
117#include "strutil.h" // GetPString
118#include "notebook.h" // CfgDlgProc
119#include "command.h" // RunCommand
120#include "worker.h" // Action, MassAction
121#include "misc.h" // GetTidForThread, AdjustCnrColsForFSType, AdjustCnrColsForPref
122 // AdjustDetailsSwitches, CnrDirectEdit, OpenEdit, QuickPopup
123 // SayFilter, SaySort, SayView, SetCnrCols, SetDetailsSwitches
124 // SetSortChecks, SetViewMenu, SwitchCommand, CheckMenu
125 // CurrentRecord, DrawTargetEmphasis, IsFm2Window
126#include "chklist.h" // CenterOverWindow, DropListProc
127#include "common.h" // CommonCnrProc, CommonCreateTextChildren, CommonFrameWndProc
128 // CommonTextPaint, CommonTextButton, CommonTextProc
129#include "mainwnd.h" // CountDirCnrs, GetNextWindowPos, MakeBubble, TopWindow
130#include "select.h" // DeselectAll, HideAll, InvertAll, SelectAll, SelectList
131 // SpecialSelect2
132#include "dirsize.h" // DirSizeProc
133#include "flesh.h" // Flesh, Stubby, UnFlesh
134#include "valid.h" // IsValidDir
135#include "objwin.h" // MakeObjWin
136#include "notify.h" // NotifyError
137#include "objcnr.h" // ObjCnrDlgProc
138#include "draglist.h" // DoFileDrag, FreeDragInfoData, PickUp
139#include "saveclip.h" // SaveListDlgProc
140#include "findrec.h" // ShowCnrRecord
141#include "sortcnr.h" // SortDirCnr
142#include "seeall.h" // StartSeeAll
143#include "update.h" // UpdateCnrList, UpdateCnrRecord
144#include "walkem.h" // add_udir
145#include "strips.h" // chop_at_crnl
146#include "droplist.h" // AcceptOneDrop, CheckPmDrgLimit, DropHelp, GetOneDrop
147#include "presparm.h" // CopyPresParams
148#include "defview.h" // DefaultViewKeys
149#include "systemf.h" // ExecOnList
150#include "filter.h" // Filter
151#include "findrec.h" // FindCnrRecord
152#include "input.h" // InputDlgProc
153#include "shadow.h" // OpenObject
154#include "mkdir.h" // PMMkDir
155#include "collect.h" // StartCollector
156#include "viewer.h" // StartMLEEditor
157#include "newview.h" // StartViewer
158#include "undel.h" // UndeleteDlgProc
159#include "i18nutil.h" // commafmt
160#include "getnames.h" // insert_filename
161#include "wrappers.h" // xfree
162#include "fortify.h"
163#include "excputil.h" // 06 May 08 SHL added
164#include "pathutil.h" // AddBackslashToPath
165#include "copyf.h" // ignorereadonly
166
167// Data definitions
168#pragma data_seg(GLOBAL1)
169HWND DirCnrMenu;
170HWND hwndAttr;
171HWND hwndDate;
172
173#pragma data_seg(GLOBAL2)
174INT sortFlags;
175
176#pragma data_seg(DATA1)
177
178static PSZ pszSrcFile = __FILE__;
179
180MRESULT EXPENTRY DirFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
181{
182 return CommonFrameWndProc(DIR_CNR, hwnd, msg, mp1, mp2);
183}
184
185MRESULT EXPENTRY DirTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
186{
187 static BOOL emphasized = FALSE;
188 static HWND hwndButtonPopup = (HWND) 0;
189 static USHORT lastid = 0;
190 static ULONG timestamp = ULONG_MAX;
191
192 switch (msg) {
193 case WM_CREATE:
194 return CommonTextProc(hwnd, msg, mp1, mp2);
195
196 case WM_COMMAND:
197 {
198 DIRCNRDATA *dcd;
199 MRESULT mr;
200
201 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
202 QW_PARENT),
203 DIR_CNR), msg, mp1, mp2);
204 if (hwndButtonPopup &&
205 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
206 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
207 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
208 QW_PARENT),
209 DIR_CNR), QWL_USER);
210 if (dcd)
211 SetDetailsSwitches(hwndButtonPopup, &dcd->ds);
212 }
213 return mr;
214 }
215
216 case UM_CONTEXTMENU:
217 case WM_CONTEXTMENU:
218 {
219 USHORT id;
220
221 id = WinQueryWindowUShort(hwnd, QWS_ID);
222 switch (id) {
223 case DIR_FOLDERICON:
224 if (fNoFoldMenu) {
225 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
226 DIR_CNR),
227 WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), mp2);
228 break;
229 }
230 // else intentional fallthru
231 case DIR_SELECTED:
232 case DIR_VIEW:
233 case DIR_SORT:
234 {
235 POINTL ptl = { 0, 0 };
236 SWP swp;
237 DIRCNRDATA *dcd;
238
239 if (hwndButtonPopup)
240 WinDestroyWindow(hwndButtonPopup);
241 if (id == DIR_SELECTED && msg == WM_CONTEXTMENU)
242 id = DIR_MAX;
243 if (id == lastid) {
244
245 ULONG check;
246
247 DosQuerySysInfo(QSV_MS_COUNT,
248 QSV_MS_COUNT, &check, sizeof(check));
249 if (check < timestamp + 500) {
250 lastid = 0;
251 goto MenuAbort;
252 }
253 }
254 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
255 CopyPresParams(hwndButtonPopup, hwnd);
256 if (hwndButtonPopup) {
257 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
258 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
259 QW_PARENT),
260 DIR_CNR), QWL_USER);
261 if (id == DIR_SORT) { // don't have sort pathname in dirs
262 WinSendMsg(hwndButtonPopup,
263 MM_DELETEITEM,
264 MPFROM2SHORT(IDM_SORTNAME, FALSE), MPVOID);
265 WinSendMsg(hwndButtonPopup,
266 MM_DELETEITEM,
267 MPFROM2SHORT(IDM_SORTNONE, FALSE), MPVOID);
268 if (dcd)
269 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
270 }
271 else if (id == DIR_VIEW) {
272 if (dcd) {
273 SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
274 SetDetailsSwitches(hwndButtonPopup, &dcd->ds);
275 }
276 }
277 else if (id == DIR_MAX) {
278
279 int x;
280 BOOL enable;
281 USHORT ids[] = { IDM_SELECTBOTH,
282 IDM_SELECTMORE,
283 IDM_SELECTONE,
284 IDM_SELECTNEWER,
285 IDM_SELECTOLDER,
286 IDM_SELECTBIGGER,
287 IDM_SELECTSMALLER,
288 IDM_DESELECTBOTH,
289 IDM_DESELECTMORE,
290 IDM_DESELECTONE,
291 IDM_DESELECTNEWER,
292 IDM_DESELECTOLDER,
293 IDM_DESELECTBIGGER,
294 IDM_DESELECTSMALLER,
295 0
296 };
297
298 enable = (CountDirCnrs(dcd->hwndParent) > 1);
299 for (x = 0; ids[x]; x++)
300 WinEnableMenuItem(hwndButtonPopup, ids[x], enable);
301 }
302 else if (id == DIR_SELECTED) {
303 if (dcd)
304 WinEnableMenuItem(hwndButtonPopup,
305 IDM_RESELECT, (dcd->lastselection != NULL));
306 }
307 ptl.x = 0;
308 if (WinPopupMenu(HWND_OBJECT,
309 HWND_OBJECT,
310 hwndButtonPopup, -32767, -32767, 0, 0)) {
311 WinQueryWindowPos(hwndButtonPopup, &swp);
312 ptl.y = -(swp.cy + 2);
313 }
314 else {
315 WinQueryWindowPos(hwnd, &swp);
316 ptl.y = swp.cy + 2;
317 }
318 if (WinPopupMenu(hwnd,
319 hwnd,
320 hwndButtonPopup,
321 ptl.x,
322 ptl.y,
323 0,
324 PU_HCONSTRAIN | PU_VCONSTRAIN |
325 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
326 CenterOverWindow(hwndButtonPopup);
327 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
328 }
329 }
330 }
331 break;
332 default:
333 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), DIR_CNR),
334 WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU), MPVOID);
335 break;
336 }
337 } // case WM_CONTENT_MENU
338
339 MenuAbort:
340
341 if (msg == UM_CONTEXTMENU)
342 return 0;
343 break;
344
345 case WM_MENUEND:
346 if (hwndButtonPopup == (HWND) mp2) {
347 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
348 WinDestroyWindow(hwndButtonPopup);
349 hwndButtonPopup = (HWND) 0;
350 DosQuerySysInfo(QSV_MS_COUNT,
351 QSV_MS_COUNT, &timestamp, sizeof(timestamp));
352 switch (lastid) {
353 case DIR_VIEW:
354 case DIR_SORT:
355 case DIR_FOLDERICON:
356 case DIR_SELECTED:
357 case DIR_MAX:
358 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
359 break;
360 }
361 }
362 break;
363
364 case WM_BUTTON3DOWN:
365 case WM_BUTTON1DOWN:
366 case WM_BUTTON3UP:
367 case WM_BUTTON1UP:
368 {
369 USHORT id;
370
371 id = WinQueryWindowUShort(hwnd, QWS_ID);
372 switch (id) {
373 case DIR_FILTER:
374 case DIR_VIEW:
375 case DIR_SORT:
376 case DIR_SELECTED:
377 case DIR_FOLDERICON:
378 case DIR_MAX:
379 return CommonTextButton(hwnd, msg, mp1, mp2);
380 }
381 }
382 break;
383
384 case WM_BUTTON1DBLCLK:
385 {
386 NOTIFYRECORDENTER nr;
387
388 if (WinQueryWindowUShort(hwnd, QWS_ID) != DIR_FOLDERICON) {
389 memset(&nr, 0, sizeof(NOTIFYRECORDENTER));
390 nr.hwndCnr = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), DIR_CNR);
391 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
392 WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_ENTER), MPFROMP(&nr));
393 }
394 }
395 break;
396
397 case WM_MOUSEMOVE:
398 {
399 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
400 PCSZ s = NULL;
401
402 if (fOtherHelp) {
403 if ((!hwndBubble ||
404 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
405 !WinQueryCapture(HWND_DESKTOP)) {
406 switch (id) {
407 case DIR_TOTALS:
408 s = GetPString(IDS_DIRCNRTOTALHELP);
409 break;
410 case DIR_SELECTED:
411 s = GetPString(IDS_DIRCNRSELECTEDHELP);
412 break;
413 case DIR_VIEW:
414 s = GetPString(IDS_DIRCNRVIEWHELP);
415 break;
416 case DIR_SORT:
417 s = GetPString(IDS_DIRCNRSORTHELP);
418 break;
419 case DIR_FILTER:
420 s = GetPString(IDS_DIRCNRFILTERHELP);
421 break;
422 case DIR_MAX:
423 s = GetPString(IDS_DIRCNRMAXHELP);
424 break;
425 case DIR_FOLDERICON:
426 s = GetPString(IDS_DIRCNRFOLDERHELP);
427 break;
428 default:
429 break;
430 }
431 if (s)
432 MakeBubble(hwnd, TRUE, s);
433 else if (hwndBubble)
434 WinDestroyWindow(hwndBubble);
435 }
436 }
437 switch (id) {
438 case DIR_MAX:
439 case DIR_FOLDERICON:
440 case DIR_FILTER:
441 case DIR_SORT:
442 case DIR_VIEW:
443 case DIR_SELECTED:
444 return CommonTextButton(hwnd, msg, mp1, mp2);
445 }
446 }
447 break;
448
449 case WM_CHORD:
450 case WM_BUTTON3CLICK:
451 case WM_BUTTON1CLICK:
452 case UM_CLICKED:
453 case UM_CLICKED3:
454 {
455 USHORT id, cmd = 0;
456
457 id = WinQueryWindowUShort(hwnd, QWS_ID);
458 if (msg == UM_CLICKED || msg == UM_CLICKED3) {
459 switch (id) {
460 case DIR_MAX:
461 cmd = IDM_MAXIMIZE;
462 break;
463 case DIR_VIEW:
464 case DIR_SELECTED:
465 case DIR_SORT:
466 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
467 break;
468 case DIR_FILTER:
469 cmd = IDM_FILTER;
470 break;
471 default:
472 break;
473 }
474 }
475 else if (id == DIR_FOLDERICON) {
476 if ((msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_CTRL)))
477 cmd = IDM_PREVIOUS;
478 else if (msg == WM_BUTTON3CLICK || msg == WM_CHORD)
479 cmd = IDM_RESCAN;
480 else if (msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_SHIFT))
481 cmd = IDM_WALKDIR;
482 else if (msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_ALT))
483 cmd = IDM_WINDOWDLG;
484 else
485 cmd = IDM_PARENT;
486 }
487 if (cmd)
488 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
489 DIR_CNR),
490 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
491 }
492 if (msg == UM_CLICKED || msg == UM_CLICKED3)
493 return 0;
494 break;
495
496 case DM_DROP:
497 case DM_DRAGOVER:
498 case DM_DRAGLEAVE:
499 case DM_DROPHELP:
500 case WM_BEGINDRAG:
501 if (msg == DM_DRAGOVER) {
502 if (!emphasized) {
503 emphasized = TRUE;
504 DrawTargetEmphasis(hwnd, emphasized);
505 }
506 }
507 else if (msg != WM_BEGINDRAG) {
508 if (emphasized) {
509 emphasized = FALSE;
510 DrawTargetEmphasis(hwnd, emphasized);
511 }
512 }
513 switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
514 case DIR_FOLDERICON:
515 switch (msg) {
516 case DM_DRAGOVER:
517 if (AcceptOneDrop(hwnd, mp1, mp2))
518 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
519 return (MRFROM2SHORT(DOR_NODROP, 0)); // Drop not valid
520 case DM_DROPHELP:
521 DropHelp(mp1, mp2, hwnd, GetPString(IDS_DIRCNRFOLDERDROPHELP));
522 return 0;
523 case DM_DROP:
524 {
525 char szFrom[CCHMAXPATH + 2];
526
527 if (emphasized) {
528 emphasized = FALSE;
529 DrawTargetEmphasis(hwnd, emphasized);
530 }
531 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
532 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
533 DIR_CNR),
534 WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0),
535 MPFROMP(szFrom));
536 }
537 return 0;
538 default:
539 return PFNWPStatic(hwnd, msg, mp1, mp2);
540 }
541 case DIR_MAX:
542 if (msg == WM_BEGINDRAG)
543 return PFNWPStatic(hwnd, msg, mp1, mp2);
544 default:
545 {
546 CNRDRAGINFO cnd;
547 USHORT dcmd;
548
549 switch (msg) {
550 case DM_DROP:
551 dcmd = CN_DROP;
552 break;
553 case DM_DRAGOVER:
554 dcmd = CN_DRAGOVER;
555 break;
556 case DM_DRAGLEAVE:
557 dcmd = CN_DRAGLEAVE;
558 break;
559 case DM_DROPHELP:
560 dcmd = CN_DROPHELP;
561 break;
562 case WM_BEGINDRAG:
563 dcmd = CN_INITDRAG;
564 break;
565 }
566 memset(&cnd, 0, sizeof(cnd));
567 cnd.pDragInfo = (PDRAGINFO) mp1;
568 cnd.pRecord = NULL;
569 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
570 WM_CONTROL,
571 MPFROM2SHORT(DIR_CNR, dcmd), MPFROMP(&cnd));
572 }
573 }
574 }
575 return PFNWPStatic(hwnd, msg, mp1, mp2);
576}
577
578MRESULT EXPENTRY DirClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
579 MPARAM mp2)
580{
581 switch (msg) {
582 case UM_CONTAINERDIR:
583 if (mp1) {
584
585 DIRCNRDATA *dcd;
586
587 *(CHAR *)mp1 = 0;
588 dcd = WinQueryWindowPtr(WinWindowFromID(hwnd, DIR_CNR), QWL_USER);
589 if (dcd)
590 strcpy((CHAR *)mp1, dcd->directory);
591 return MRFROMLONG(TRUE);
592 }
593 return 0;
594
595 case UM_CONTAINERHWND:
596 return MRFROMLONG(WinWindowFromID(hwnd, DIR_CNR));
597
598 case UM_VIEWSMENU:
599 return MRFROMLONG(CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP));
600
601 case UM_DRIVECMD:
602 case WM_INITMENU:
603 case UM_FILTER:
604 case UM_INITMENU:
605 case MM_PORTHOLEINIT:
606 case UM_COMMAND:
607 case UM_FILESMENU:
608 case UM_UPDATERECORD:
609 case UM_UPDATERECORDLIST:
610 return WinSendMsg(WinWindowFromID(hwnd, DIR_CNR), msg, mp1, mp2);
611
612 case WM_PSETFOCUS:
613 case WM_SETFOCUS:
614 if (mp2)
615 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
616 break;
617
618 case UM_FOCUSME:
619 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, DIR_CNR));
620 break;
621
622 case WM_PAINT:
623 {
624 HPS hps;
625 RECTL rcl;
626
627 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
628 if (hps) {
629 WinQueryWindowRect(hwnd, &rcl);
630 WinFillRect(hps, &rcl, CLR_PALEGRAY);
631 CommonTextPaint(hwnd, hps);
632 WinEndPaint(hps);
633 }
634 }
635 break;
636
637 case UM_SIZE:
638 case WM_SIZE:
639 if (msg == UM_SIZE) {
640
641 SWP swp;
642
643 WinQueryWindowPos(hwnd, &swp);
644 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
645 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
646 }
647 {
648 USHORT cx, cy, bx;
649
650 cx = SHORT1FROMMP(mp2);
651 cy = SHORT2FROMMP(mp2);
652 WinSetWindowPos(WinWindowFromID(hwnd, DIR_CNR), HWND_TOP,
653 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
654 if (WinWindowFromID(hwnd, DIR_MAX) != (HWND) 0) {
655 WinSetWindowPos(WinWindowFromID(hwnd, DIR_MAX), HWND_TOP,
656 cx - 22,
657 cy - 22, 20, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
658 cx -= 24;
659 }
660 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FOLDERICON), HWND_TOP,
661 2, cy - 22, 24, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
662 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
663 29,
664 cy - 22,
665 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
666 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
667 29 + (cx / 3) + 2,
668 cy - 22,
669 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
670 bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
671 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
672 29 + (((cx / 3) + 2) * 2),
673 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
674 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
675 29 + (((cx / 3) + 2) * 2) + bx,
676 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
677 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
678 29 + (((cx / 3) + 2) * 2) + (bx * 2),
679 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
680 }
681 CommonTextPaint(hwnd, (HPS) 0);
682 if (msg == UM_SIZE) {
683 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
684 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
685 return 0;
686 }
687 break;
688
689 case WM_COMMAND:
690 case WM_CONTROL:
691 case WM_CLOSE:
692 return WinSendMsg(WinWindowFromID(hwnd, DIR_CNR), msg, mp1, mp2);
693 }
694 return WinDefWindowProc(hwnd, msg, mp1, mp2);
695}
696
697MRESULT EXPENTRY DirObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
698{
699 DIRCNRDATA *dcd;
700 CHAR tf[64];
701 CHAR tb[64];
702 CHAR s[CCHMAXPATH * 2];
703
704 switch (msg) {
705 case WM_CREATE:
706 DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2); // 18 Jul 08 SHL fixme
707 break;
708
709 case DM_PRINTOBJECT:
710 return MRFROMLONG(DRR_TARGET);
711
712 case DM_DISCARDOBJECT:
713 dcd = INSTDATA(hwnd);
714 if (fFM2Deletes && dcd) {
715 LISTINFO *li;
716 CNRDRAGINFO cni;
717 cni.pRecord = NULL;
718 cni.pDragInfo = (PDRAGINFO) mp1;
719 li =
720 DoFileDrop(dcd->hwndCnr, dcd->directory, FALSE, MPVOID,
721 MPFROMP(&cni));
722 CheckPmDrgLimit(cni.pDragInfo);
723 if (li) {
724 li->type = (fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE;
725 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
726 FreeListInfo(li);
727 else
728 return MRFROMLONG(DRR_SOURCE);
729 }
730 }
731 return MRFROMLONG(DRR_TARGET);
732
733 case UM_UPDATERECORDLIST:
734 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
735 if (dcd && mp1) {
736
737 INT numentries = 0;
738 CHAR **list = (CHAR **) mp1;
739
740 while (list[numentries])
741 numentries++;
742 if (numentries)
743 UpdateCnrList(dcd->hwndCnr, list, numentries, TRUE, dcd);
744 }
745 return 0;
746
747 case UM_SETUP:
748# ifdef FORTIFY
749 // DbgMsg(pszSrcFile, __LINE__, "UM_SETUP hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
750 Fortify_EnterScope();
751# endif
752 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
753 if (dcd) {
754# ifdef FORTIFY
755 Fortify_BecomeOwner(dcd); // We free dcd
756 if (GetTidForThread() != 1)
757 Fortify_ChangeScope(dcd, -1);
758# endif
759 // set unique id
760 WinSetWindowUShort(hwnd, QWS_ID, DIROBJ_FRAME + (DIR_FRAME - dcd->id));
761 dcd->hwndObject = hwnd;
762 if (ParentIsDesktop(hwnd, dcd->hwndParent))
763 DosSleep(100);
764 }
765 else
766 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
767# ifdef FORTIFY
768 // TID 1 will free data
769 if (GetTidForThread() != 1)
770 Fortify_LeaveScope();
771# endif
772 return 0;
773
774 case UM_RESCAN2:
775 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
776 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
777 FSALLOCATE fsa;
778 CHAR szFree[64];
779 DosError(FERR_DISABLEHARDERR);
780 if (!DosQueryFSInfo(toupper(*dcd->directory) - '@',
781 FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
782 CommaFmtULL(tb, sizeof(tb),
783 (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit *
784 fsa.cbSector), 'K');
785 sprintf(szFree, " {%s %s}", tb, GetPString(IDS_FREETEXT));
786 }
787 else
788 *szFree = 0;
789 commafmt(tf, sizeof(tf), dcd->totalfiles);
790 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
791 if (!fMoreButtons) {
792 sprintf(s, " [%s / %s]%s%s%s%s %s",
793 tf, tb, szFree,
794 (*dcd->mask.szMask || dcd->mask.antiattr ||
795 dcd->mask.attrFile != ALLATTRS) ? " (" : NullStr,
796 (*dcd->mask.szMask) ? dcd->mask.szMask :
797 (dcd->mask.antiattr ||
798 dcd->mask.attrFile != ALLATTRS) ?
799 GetPString(IDS_ALLTEXT) : NullStr,
800 (*dcd->mask.szMask || dcd->mask.antiattr ||
801 dcd->mask.attrFile != ALLATTRS) ? ")" : NullStr,
802 dcd->directory);
803 }
804 else {
805 sprintf(s, " [%s / %s]%s %s", tf, tb, szFree, dcd->directory);
806 }
807 if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
808 WinSetWindowText(hwndStatus, s);
809 }
810 return 0;
811
812 case UM_FLESH:
813 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
814 if (dcd) {
815
816 PCNRITEM pci, pciC;
817
818 pci = WinSendMsg(dcd->hwndCnr,
819 CM_QUERYRECORD,
820 MPVOID, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
821 while (pci && (INT) pci != -1) {
822 if (pci->attrFile & FILE_DIRECTORY) {
823 pciC = WinSendMsg(dcd->hwndCnr,
824 CM_QUERYRECORD,
825 MPFROMP(pci),
826 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
827 if (!pciC) {
828 Stubby(dcd->hwndCnr, pci);
829 }
830 }
831 pci = WinSendMsg(dcd->hwndCnr,
832 CM_QUERYRECORD,
833 MPFROMP(pci), MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
834 }
835 dcd->firsttree = TRUE;
836 }
837 return 0;
838
839 case UM_RESCAN:
840 // populate container
841 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
842 if (dcd) {
843 DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT);
844 if (dcd->stopflag)
845 dcd->stopflag--;
846 if (dcd->stopflag) {
847 DosReleaseMutexSem(hmtxFM2Globals);
848 return 0;
849 }
850 DosReleaseMutexSem(hmtxFM2Globals);
851 if (mp1) {
852 strcpy(dcd->previous, dcd->directory);
853 strcpy(dcd->directory, (CHAR *)mp1);
854 }
855 MakeValidDir(dcd->directory);
856 {
857 sprintf(s,
858 "%s%s%s",
859 (ParentIsDesktop(dcd->hwndFrame, (HWND) 0)) ?
860 "VDir" :
861 NullStr,
862 (ParentIsDesktop(dcd->hwndFrame, (HWND) 0)) ?
863 (!dcd->dontclose) ?
864 " Master: " : ": " : NullStr, dcd->directory);
865 WinSetWindowText(dcd->hwndFrame, s);
866 WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR), s);
867 }
868 RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
869 AdjustCnrColsForFSType(dcd->hwndCnr, dcd->directory, &dcd->ds, FALSE);
870 dcd->ullTotalBytes = dcd->totalfiles =
871 dcd->selectedfiles = dcd->selectedbytes = 0;
872 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0 / 0k");
873 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
874 if (hwndStatus &&
875 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
876 WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_PLEASEWAITSCANNINGTEXT));
877 if (hwndMain)
878 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
879 }
880 while (fInitialDriveScan) {
881 DosSleep(100); // Allow to complete
882 }
883 if (fSwitchTree && hwndTree) {
884 // Keep drive tree in sync with directory container
885 PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
886 if (pszTempDir) {
887 if (hwndMain) {
888 if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame)
889 if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
890 free(pszTempDir);
891 }
892 else {
893 if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
894 free(pszTempDir);
895 }
896 }
897 }
898 dcd->firsttree = FALSE;
899 WinStartTimer(WinQueryAnchorBlock(hwnd), dcd->hwndCnr, ID_DIRCNR_TIMER, 500);
900 // fixme to check errors
901 FillDirCnr(dcd->hwndCnr, dcd->directory, dcd, &dcd->ullTotalBytes);
902 WinStopTimer(WinQueryAnchorBlock(hwnd), dcd->hwndCnr, ID_DIRCNR_TIMER);
903 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
904 if (mp2 && !fLeaveTree && (dcd->flWindowAttr & CV_TREE)) {
905 ULONG flWindowAttr = dcd->flWindowAttr;
906 CNRINFO cnri;
907 flWindowAttr &= ~(CV_NAME | CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT);
908 if (dcd->lastattr) {
909 if (dcd->lastattr & CV_TEXT)
910 flWindowAttr |= CV_TEXT;
911 else if (dcd->lastattr & CV_DETAIL)
912 flWindowAttr |= CV_DETAIL;
913 else if (dcd->lastattr & CV_ICON)
914 flWindowAttr |= CV_ICON;
915 else
916 flWindowAttr |= CV_NAME;
917 }
918 else
919 flWindowAttr |= CV_NAME;
920 flWindowAttr |= CV_FLOW;
921 memset(&cnri, 0, sizeof(CNRINFO));
922 cnri.cb = sizeof(CNRINFO);
923 if (WinSendMsg(dcd->hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnri),
924 MPFROMLONG(sizeof(CNRINFO)))) {
925 dcd->flWindowAttr = cnri.flWindowAttr = flWindowAttr;
926 WinSendMsg(dcd->hwndCnr, CM_SETCNRINFO,
927 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
928 SayView(WinWindowFromID(dcd->hwndClient,
929 DIR_VIEW), dcd->flWindowAttr);
930 }
931 }
932 if (dcd->flWindowAttr & CV_TREE)
933 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
934 if (*dcd->previous) {
935 if (strlen(dcd->previous) > strlen(dcd->directory) &&
936 !strnicmp(dcd->directory, dcd->previous,
937 strlen(dcd->directory)))
938 {
939 PCNRITEM pci = FindCnrRecord(dcd->hwndCnr,
940 dcd->previous,
941 NULL, TRUE, FALSE, TRUE);
942 if (pci && (INT) pci != -1) {
943 // make found item current (cursored) item
944 WinSendMsg(dcd->hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
945 MPFROM2SHORT(TRUE, CRA_CURSORED));
946 // make sure that record shows in viewport
947 ShowCnrRecord(dcd->hwndCnr, (PMINIRECORDCORE) pci);
948 }
949 }
950 }
951 }
952 return 0;
953
954 case UM_COMMAND:
955 if (mp1) {
956
957 LISTINFO *li = (LISTINFO *) mp1;
958
959 switch (li->type) {
960 case IDM_DOITYOURSELF:
961 case IDM_APPENDTOCLIP:
962 case IDM_APPENDTOCLIPFILENAME:
963 case IDM_SAVETOCLIP:
964 case IDM_SAVETOCLIPFILENAME:
965 case IDM_ARCHIVE:
966 case IDM_ARCHIVEM:
967 case IDM_VIEWTEXT:
968 case IDM_VIEWBINARY:
969 case IDM_VIEWARCHIVE:
970 case IDM_VIEW:
971 case IDM_EDITTEXT:
972 case IDM_EDITBINARY:
973 case IDM_EDIT:
974 case IDM_OBJECT:
975 case IDM_SHADOW:
976 case IDM_SHADOW2:
977 case IDM_PRINT:
978 case IDM_ATTRS:
979 case IDM_DELETE:
980 case IDM_PERMDELETE:
981 case IDM_MCIPLAY:
982 case IDM_UPDATE:
983 if (li->type == IDM_DELETE)
984 ignorereadonly = FALSE;
985 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
986 return (MRESULT) TRUE;
987 break;
988 default:
989 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
990 return (MRESULT) TRUE;
991 }
992 }
993 return 0;
994
995 case UM_SELECT:
996 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
997 if (dcd) {
998 switch (SHORT1FROMMP(mp1)) {
999 case IDM_SELECTBOTH:
1000 case IDM_SELECTONE:
1001 case IDM_SELECTMORE:
1002 case IDM_SELECTNEWER:
1003 case IDM_SELECTOLDER:
1004 case IDM_SELECTBIGGER:
1005 case IDM_SELECTSMALLER:
1006 case IDM_DESELECTBOTH:
1007 case IDM_DESELECTONE:
1008 case IDM_DESELECTMORE:
1009 case IDM_DESELECTNEWER:
1010 case IDM_DESELECTOLDER:
1011 case IDM_DESELECTBIGGER:
1012 case IDM_DESELECTSMALLER:
1013 SpecialSelect2(dcd->hwndParent, SHORT1FROMMP(mp1));
1014 break;
1015 case IDM_SELECTLIST:
1016 {
1017 CHAR filename[CCHMAXPATH], *p, *pp;
1018 ULONG size;
1019
1020 strcpy(filename, PCSZ_STARDOTLST);
1021 size = CCHMAXPATH;
1022 PrfQueryProfileData(fmprof, appname, "SaveToListName",
1023 filename, &size);
1024 pp = strrchr(filename, '\\');
1025 if (!pp)
1026 pp = filename;
1027 p = strrchr(pp, '.');
1028 if (p && *(p + 1) && p > pp + 1) {
1029 if (pp > filename)
1030 pp++;
1031 *pp = '*';
1032 pp++;
1033 if (p > pp)
1034 memmove(pp, p, strlen(p) + 1);
1035 }
1036 if (insert_filename(hwnd, filename, FALSE, FALSE))
1037 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
1038 NULL);
1039 }
1040 break;
1041 case IDM_SELECTALL:
1042 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
1043 break;
1044 case IDM_DESELECTALL:
1045 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
1046 break;
1047 case IDM_SELECTALLFILES:
1048 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
1049 break;
1050 case IDM_DESELECTALLFILES:
1051 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
1052 break;
1053 case IDM_SELECTALLDIRS:
1054 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
1055 break;
1056 case IDM_DESELECTALLDIRS:
1057 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
1058 break;
1059 case IDM_DESELECTMASK:
1060 case IDM_SELECTMASK:
1061 {
1062 MASK mask;
1063 PCNRITEM pci = (PCNRITEM) mp2;
1064
1065 memset(&mask, 0, sizeof(MASK));
1066 mask.fNoAttribs = TRUE;
1067 mask.fNoDirs = TRUE;
1068 mask.fText = TRUE;
1069 strcpy(mask.prompt,
1070 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
1071 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
1072 if (pci && (INT) pci != -1)
1073 strcpy(mask.szMask, pci->pszFileName);
1074 if (WinDlgBox(HWND_DESKTOP,
1075 dcd->hwndCnr,
1076 PickMaskDlgProc,
1077 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
1078 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
1079 SelectAll(dcd->hwndCnr,
1080 TRUE, TRUE, mask.szMask, mask.szText, FALSE);
1081 else
1082 DeselectAll(dcd->hwndCnr,
1083 TRUE, TRUE, mask.szMask, mask.szText, FALSE);
1084 }
1085 }
1086 break;
1087
1088 case IDM_DESELECTCLIP:
1089 case IDM_SELECTCLIP:
1090 {
1091 CHAR **list;
1092
1093 list = ListFromClipboard(hwnd);
1094 if (list) {
1095 SelectList(dcd->hwndCnr, TRUE, FALSE,
1096 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
1097 NULL, NULL, list);
1098 FreeList(list);
1099 }
1100 }
1101 break;
1102
1103 case IDM_INVERT:
1104 InvertAll(dcd->hwndCnr);
1105 break;
1106 }
1107 }
1108 return 0;
1109
1110 case UM_MASSACTION:
1111 if (mp1) {
1112 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1113 if (dcd) {
1114 WORKER *wk;
1115# ifdef FORTIFY
1116 Fortify_EnterScope();
1117# endif
1118 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1119 if (!wk)
1120 FreeListInfo((LISTINFO *) mp1);
1121 else {
1122 wk->size = sizeof(WORKER);
1123 wk->hwndCnr = dcd->hwndCnr;
1124 wk->hwndParent = dcd->hwndParent;
1125 wk->hwndFrame = dcd->hwndFrame;
1126 wk->hwndClient = dcd->hwndClient;
1127 wk->li = (LISTINFO *) mp1;
1128 strcpy(wk->directory, dcd->directory);
1129 if (xbeginthread(MassAction,
1130 122880,
1131 wk,
1132 pszSrcFile,
1133 __LINE__) == -1)
1134 {
1135 free(wk);
1136 FreeListInfo((LISTINFO *)mp1);
1137 }
1138 }
1139# ifdef FORTIFY
1140 DosSleep(1); // Allow MassAction to take ownership
1141 Fortify_LeaveScope();
1142# endif
1143 }
1144 }
1145 return 0;
1146
1147 case UM_ACTION:
1148 if (mp1) {
1149
1150 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1151 if (dcd) {
1152
1153 WORKER *wk;
1154# ifdef FORTIFY
1155 Fortify_EnterScope();
1156# endif
1157 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1158 if (!wk)
1159 FreeListInfo((LISTINFO *) mp1);
1160 else {
1161 wk->size = sizeof(WORKER);
1162 wk->hwndCnr = dcd->hwndCnr;
1163 wk->hwndParent = dcd->hwndParent;
1164 wk->hwndFrame = dcd->hwndFrame;
1165 wk->hwndClient = dcd->hwndClient;
1166 wk->li = (LISTINFO *) mp1;
1167 strcpy(wk->directory, dcd->directory);
1168
1169 if (xbeginthread(Action,
1170 122880,
1171 wk,
1172 pszSrcFile,
1173 __LINE__) == -1)
1174 {
1175 Runtime_Error(pszSrcFile, __LINE__,
1176 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1177 free(wk);
1178 FreeListInfo((LISTINFO *) mp1);
1179 }
1180 }
1181# ifdef FORTIFY
1182 Fortify_LeaveScope();
1183# endif
1184 }
1185 }
1186 return 0;
1187
1188 case WM_CLOSE:
1189 WinDestroyWindow(hwnd);
1190 break;
1191
1192 case WM_DESTROY:
1193# ifdef FORTIFY
1194 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
1195# endif
1196 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1197 if (!dcd)
1198 Runtime_Error(pszSrcFile, __LINE__, NULL);
1199 else {
1200 if (dcd->hwndRestore)
1201 WinSetWindowPos(dcd->hwndRestore,
1202 HWND_TOP,
1203 0,
1204 0,
1205 0,
1206 0,
1207 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
1208 FreeList(dcd->lastselection);
1209 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL); // 13 Apr 10 SHL Set NULL before freeing dcd
1210 xfree(dcd, pszSrcFile, __LINE__);
1211 DosPostEventSem(CompactSem);
1212 }
1213# ifdef FORTIFY
1214 Fortify_LeaveScope();
1215# endif
1216 // 22 Jul 08 SHL fixme to understand
1217 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1218 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1219 break;
1220 }
1221 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1222}
1223
1224MRESULT EXPENTRY DirCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1225{
1226 DIRCNRDATA *dcd = INSTDATA(hwnd);
1227 CHAR tf[64];
1228 CHAR tb[64];
1229 CHAR s[CCHMAXPATH];
1230
1231 switch (msg) {
1232 case WM_CREATE:
1233# ifdef FORTIFY
1234 Fortify_EnterScope();
1235# endif
1236 break;
1237
1238 case DM_PRINTOBJECT:
1239 return MRFROMLONG(DRR_TARGET);
1240
1241 case DM_DISCARDOBJECT:
1242 if (dcd)
1243 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1244 else
1245 return MRFROMLONG(DRR_TARGET);
1246
1247 case WM_CHAR:
1248 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1249 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1250 return (MRESULT) TRUE;
1251 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1252 switch (SHORT2FROMMP(mp2)) {
1253 case VK_INSERT:
1254 if ((shiftstate & KC_CTRL) == KC_CTRL)
1255 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
1256 // Alt-Insert - create file
1257 else if ((shiftstate & KC_ALT) == KC_ALT)
1258 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_CREATE, 0), MPVOID);
1259 break;
1260 case VK_PAGEUP:
1261 if ((shiftstate & KC_CTRL) == KC_CTRL)
1262 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PARENT, 0), MPVOID);
1263 break;
1264 case VK_PAGEDOWN:
1265 if ((shiftstate & KC_CTRL) == KC_CTRL)
1266 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), MPVOID);
1267 break;
1268 case VK_HOME:
1269 if ((shiftstate & KC_CTRL) == KC_CTRL && dcd) {
1270 PSZ p;
1271 strcpy(s, dcd->directory);
1272 p = strchr(s, '\\');
1273 if (p) {
1274 p++;
1275 *p = 0;
1276 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(s), MPVOID);
1277 }
1278 }
1279 break;
1280 case VK_DELETE:
1281 if ((shiftstate & KC_CTRL) == KC_CTRL)
1282 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1283 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1284 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1285 else
1286 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1287 break;
1288 } // switch
1289 }
1290
1291 if (SearchContainer(hwnd, msg, mp1, mp2))
1292 return (MRESULT)TRUE; // Avoid default handler
1293 break; // Let default handler see key too
1294
1295 case WM_MOUSEMOVE:
1296 case WM_BUTTON1UP:
1297 case WM_BUTTON2UP:
1298 case WM_BUTTON3UP:
1299 case WM_CHORD:
1300 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1301 break;
1302
1303 case WM_BUTTON1MOTIONEND:
1304 {
1305 CNRINFO cnri;
1306
1307 memset(&cnri, 0, sizeof(CNRINFO));
1308 cnri.cb = sizeof(CNRINFO);
1309 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1310 MPFROMLONG(sizeof(CNRINFO)))) {
1311 if (cnri.flWindowAttr & CV_DETAIL)
1312 PrfWriteProfileData(fmprof, appname, "CnrSplitBar",
1313 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1314 }
1315 }
1316 break;
1317
1318 case UM_COMPARE:
1319 if (dcd && mp1 && mp2) {
1320
1321 COMPARE *cmp;
1322 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
1323
1324 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1325# ifdef FORTIFY
1326 Fortify_EnterScope();
1327# endif
1328 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1329 if (cmp) {
1330 cmp->size = sizeof(COMPARE);
1331 strcpy(cmp->leftdir, leftdir);
1332 strcpy(cmp->rightdir, rightdir);
1333 cmp->hwndParent = dcd->hwndParent;
1334 cmp->dcd.hwndParent = dcd->hwndParent;
1335 WinDlgBox(HWND_DESKTOP,
1336 HWND_DESKTOP,
1337 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1338 }
1339# ifdef FORTIFY
1340 Fortify_LeaveScope();
1341# endif
1342 }
1343 }
1344 return 0;
1345
1346 case WM_PRESPARAMCHANGED:
1347 PresParamChanged(hwnd, PCSZ_DIRCNR, mp1, mp2);
1348 break;
1349
1350 case UM_UPDATERECORDLIST:
1351 if (dcd && mp1)
1352 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1353 return 0;
1354
1355 case UM_UPDATERECORD:
1356 if (dcd && mp1) {
1357
1358 CHAR *filename;
1359
1360 filename = mp1;
1361 if (filename)
1362 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1363 }
1364 return 0;
1365
1366 case WM_SETFOCUS:
1367 // put name of our window (directory name) on status line
1368 if (mp2) {
1369 // Getting focus
1370 if (dcd && hwndStatus) {
1371 // put name of our window (directory name) on status line
1372 PCNRITEM pci = NULL;
1373 if (fAutoView && hwndMain) {
1374 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
1375 MPFROMSHORT(CRA_CURSORED));
1376 if (pci && (INT) pci != -1 &&
1377 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1378 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1379 else
1380 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1381 }
1382 if (*dcd->directory) {
1383 if (hwndMain)
1384 WinSendMsg(hwndMain,
1385 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1386 else
1387 add_udir(FALSE, dcd->directory);
1388 }
1389
1390 if (hwndMain)
1391 PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
1392 }
1393
1394 LastDir = hwnd;
1395 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1396 if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory) {
1397 PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
1398 if (pszTempDir) {
1399 if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID))
1400 free(pszTempDir); // Failed
1401 }
1402 }
1403 }
1404 break;
1405
1406 case UM_SETDIR:
1407 if (dcd && mp1) {
1408
1409 CHAR fullname[CCHMAXPATH];
1410
1411 DosError(FERR_DISABLEHARDERR);
1412 if (!DosQueryPathInfo((CHAR *)mp1,
1413 FIL_QUERYFULLNAME, fullname, sizeof(fullname))) {
1414 if (stricmp(dcd->directory, fullname)) {
1415 strcpy(dcd->previous, dcd->directory);
1416 strcpy(dcd->directory, fullname);
1417 // DosEnterCritSec(); // GKY 11-27-08
1418 dcd->stopflag++;
1419 // DosExitCritSec();
1420 // DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
1421 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
1422 strcpy(dcd->directory, dcd->previous);
1423 // DosEnterCritSec(); // GKY 11-27-08
1424 dcd->stopflag--;
1425 // DosExitCritSec();
1426 }
1427 else if (*dcd->directory) {
1428 if (hwndMain)
1429 WinSendMsg(hwndMain,
1430 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1431 else
1432 add_udir(FALSE, dcd->directory);
1433 }
1434 }
1435 }
1436 }
1437 break;
1438
1439 case WM_TIMER:
1440 // Started/stopped by DirObjWndPro
1441 // dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1442 if (dcd) {
1443 commafmt(tb, sizeof(tb), dcd->totalfiles);
1444 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
1445 sprintf(s, "%s / %s", tb, tf);
1446 // DbgMsg(pszSrcFile, __LINE__, "WM_TIMER %s", s); // 15 Sep 09 SHL fixme debug
1447 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1448 }
1449 break; // WM_TIMER
1450
1451 case UM_RESCAN:
1452 if (dcd) {
1453
1454 CNRINFO cnri;
1455 CHAR szDate[DATE_BUF_BYTES];
1456 PCNRITEM pci;
1457
1458 memset(&cnri, 0, sizeof(CNRINFO));
1459 cnri.cb = sizeof(CNRINFO);
1460 WinSendMsg(hwnd,
1461 CM_QUERYCNRINFO,
1462 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1463 cnri.pszCnrTitle = dcd->directory;
1464 WinSendMsg(hwnd,
1465 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
1466 dcd->totalfiles = cnri.cRecords;
1467 commafmt(tb, sizeof(tb), dcd->totalfiles);
1468 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
1469 sprintf(s, "%s / %s", tb, tf);
1470 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1471 commafmt(tb, sizeof(tb), dcd->selectedfiles);
1472 CommaFmtULL(tf, sizeof(tf), dcd->selectedbytes, 'K');
1473 sprintf(s, "%s / %s", tb, tf);
1474 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1475 if (hwndStatus &&
1476 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1477 PostMsg(dcd->hwndObject, UM_RESCAN2, MPVOID, MPVOID);
1478 if ((fSplitStatus && hwndStatus2) || fMoreButtons) {
1479 pci = WinSendMsg(hwnd,
1480 CM_QUERYRECORDEMPHASIS,
1481 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1482 if (pci && (INT) pci != -1) {
1483 if (fSplitStatus && hwndStatus2) {
1484 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1485 if (!fMoreButtons) {
1486 DateFormat(szDate, pci->date);
1487 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
1488 tb,
1489 szDate,
1490 pci->time.hours,
1491 TimeSeparator,
1492 pci->time.minutes,
1493 TimeSeparator,
1494 pci->time.seconds,
1495 pci->pszDispAttr, pci->pszFileName);
1496 }
1497 else {
1498 *tf = 0;
1499 if (pci->cbFile + pci->easize > 1024) {
1500 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1501 }
1502 sprintf(s,
1503 GetPString(IDS_STATUSSIZETEXT),
1504 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1505 }
1506 WinSetWindowText(hwndStatus2, s);
1507 }
1508 else
1509 WinSetWindowText(hwndStatus2, NullStr);
1510 if (fMoreButtons) {
1511 WinSetWindowText(hwndName, pci->pszFileName);
1512 DateFormat(szDate, pci->date);
1513 sprintf(s, "%s %02u%s%02u%s%02u",
1514 szDate,
1515 pci->time.hours, TimeSeparator,
1516 pci->time.minutes, TimeSeparator,
1517 pci->time.seconds);
1518 WinSetWindowText(hwndDate, s);
1519 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1520 }
1521 }
1522 else {
1523 WinSetWindowText(hwndStatus2, NullStr);
1524 WinSetWindowText(hwndName, NullStr);
1525 WinSetWindowText(hwndDate, NullStr);
1526 WinSetWindowText(hwndAttr, NullStr);
1527 }
1528 }
1529 }
1530 }
1531 return 0;
1532
1533 case UM_SORTRECORD:
1534 if (dcd) {
1535
1536 CNRINFO cnri;
1537
1538 memset(&cnri, 0, sizeof(CNRINFO));
1539 cnri.cb = sizeof(CNRINFO);
1540 WinSendMsg(hwnd,
1541 CM_QUERYCNRINFO,
1542 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1543 cnri.pSortRecord = (PVOID) SortDirCnr;
1544 WinSendMsg(hwnd,
1545 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PSORTRECORD));
1546 WinSendMsg(hwnd,
1547 CM_SORTRECORD,
1548 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
1549 }
1550 return 0;
1551
1552 case UM_SETUP:
1553 if (dcd) {
1554 if (!dcd->hwndObject) {
1555 // first time through -- set things up
1556
1557 CNRINFO cnri;
1558
1559 memset(&cnri, 0, sizeof(CNRINFO));
1560 cnri.cb = sizeof(CNRINFO);
1561 WinSendMsg(hwnd,
1562 CM_QUERYCNRINFO,
1563 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1564 cnri.cyLineSpacing = 0;
1565 cnri.cxTreeIndent = 12L;
1566
1567 cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1568 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
1569 CV_FLOW);
1570 cnri.pSortRecord = (PVOID) SortDirCnr;
1571
1572 {
1573 ULONG size = sizeof(ULONG);
1574
1575 PrfQueryProfileData(fmprof, appname, "DirflWindowAttr",
1576 (PVOID) & cnri.flWindowAttr, &size);
1577 size = sizeof(MASK);
1578 if (!*dcd->mask.szMask &&
1579 !dcd->mask.attrFile && !dcd->mask.antiattr) {
1580 if (PrfQueryProfileSize(fmprof, appname, "DirFilter", &size) && size) {
1581 PrfQueryProfileData(fmprof, appname, "DirFilter", &dcd->mask, &size);
1582 SetMask(dcd->mask.szMask, &dcd->mask);
1583 }
1584 else
1585 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1586 FILE_ARCHIVED | FILE_DIRECTORY |
1587 FILE_HIDDEN | FILE_SYSTEM);
1588 }
1589 *(dcd->mask.prompt) = 0;
1590 }
1591 if (dcd->flWindowAttr)
1592 cnri.flWindowAttr = dcd->flWindowAttr;
1593 else
1594 dcd->flWindowAttr = cnri.flWindowAttr;
1595 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH |
1596 CA_TITLEREADONLY | CA_TITLESEPARATOR));
1597 cnri.flWindowAttr |= CV_FLOW;
1598 dcd->flWindowAttr |= CV_FLOW;
1599 if (WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR))
1600 cnri.flWindowAttr &= (~CA_CONTAINERTITLE);
1601 else
1602 cnri.flWindowAttr |= CA_CONTAINERTITLE;
1603 if (!dcd->sortFlags)
1604 dcd->sortFlags = sortFlags;
1605 WinSendMsg(hwnd,
1606 CM_SETCNRINFO,
1607 MPFROMP(&cnri),
1608 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1609 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1610 SetCnrCols(hwnd, FALSE);
1611 if (xbeginthread(MakeObjWin,
1612 245760,
1613 dcd,
1614 pszSrcFile,
1615 __LINE__) == -1)
1616 {
1617 Runtime_Error(pszSrcFile, __LINE__,
1618 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1619 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1620 return 0;
1621 }
1622 else
1623 DosSleep(32); // 05 Aug 07 GKY 64
1624 WinEnableMenuItem(DirCnrMenu, IDM_FINDINTREE, (hwndTree != (HWND) 0));
1625 }
1626 // 2014-06-11 SHL fm/2 lite can get here before drive scan completes
1627 if (!fInitialDriveScan)
1628 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1629 }
1630 else {
1631 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1632 return 0;
1633 }
1634 return 0;
1635
1636 case UM_SETUP2:
1637 if (dcd) {
1638 // DbgMsg(pszSrcFile, __LINE__, "DirCnrWndProc UM_SETUP2 %x", hwnd);
1639 AdjustCnrColsForPref(hwnd, NULL, &dcd->ds, FALSE);
1640 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1641 DIR_FILTER), &dcd->mask, FALSE);
1642 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1643 DIR_SORT), dcd->sortFlags, FALSE);
1644 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1645 DIR_VIEW), dcd->flWindowAttr);
1646 } else
1647 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1648 return 0;
1649
1650 case WM_MENUEND:
1651 if (dcd) {
1652
1653 HWND hwndMenu = (HWND) mp2;
1654
1655 if (hwndMenu == DirCnrMenu ||
1656 hwndMenu == FileMenu ||
1657 hwndMenu == DirMenu) {
1658 MarkAll(hwnd, TRUE, FALSE, TRUE);
1659 if (dcd->cnremphasized) {
1660 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1661 MPFROM2SHORT(FALSE, CRA_SOURCE));
1662 dcd->cnremphasized = FALSE;
1663 }
1664 }
1665 }
1666 break;
1667
1668 case UM_OPENWINDOWFORME:
1669 if (dcd) {
1670 if (mp1 && !IsFile((CHAR *)mp1)) {
1671 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
1672 }
1673 else if (mp1 && IsFile(mp1) == 1 &&
1674 CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2) {
1675 StartArcCnr(HWND_DESKTOP,
1676 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
1677 }
1678 }
1679 return 0;
1680
1681 case MM_PORTHOLEINIT:
1682 if (dcd) {
1683 switch (SHORT1FROMMP(mp1)) {
1684 case 0:
1685 case 1:
1686 {
1687 ULONG wmsg;
1688
1689 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1690 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
1691 wmsg, MPVOID, MPVOID), mp1, mp2);
1692 }
1693 break;
1694 }
1695 }
1696 break;
1697
1698 case UM_INITMENU:
1699 case WM_INITMENU:
1700 if (dcd) {
1701 switch (SHORT1FROMMP(mp1)) {
1702 case IDM_FILESMENU:
1703 CopyPresParams((HWND) mp2, hwndMainMenu);
1704 if (isalpha(*dcd->directory)) {
1705 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1706 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
1707 WinEnableMenuItem((HWND) mp2, IDM_RENAME, FALSE);
1708 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1709 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, FALSE);
1710 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, FALSE);
1711 WinEnableMenuItem((HWND) mp2, IDM_DELETE, FALSE);
1712 WinEnableMenuItem((HWND) mp2, IDM_EDIT, FALSE);
1713 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, FALSE);
1714 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, FALSE);
1715 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, FALSE);
1716 }
1717 else {
1718 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, TRUE);
1719 WinEnableMenuItem((HWND) mp2, IDM_RENAME, TRUE);
1720 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1721 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, TRUE);
1722 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, TRUE);
1723 WinEnableMenuItem((HWND) mp2, IDM_DELETE, TRUE);
1724 WinEnableMenuItem((HWND) mp2, IDM_EDIT, TRUE);
1725 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
1726 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
1727 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
1728 }
1729 WinEnableMenuItem((HWND) mp2, IDM_UNLOCKFILE, fUnlock);
1730 }
1731 break;
1732
1733 case IDM_VIEWSMENU:
1734 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1735 CopyPresParams((HWND) mp2, hwndMainMenu);
1736 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1737 (dcd->lastselection != NULL));
1738 if (isalpha(*dcd->directory)) {
1739 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
1740 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1741 else
1742 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1743 }
1744 WinEnableMenuItem((HWND) mp2,
1745 IDM_SELECTCOMPAREMENU,
1746 (CountDirCnrs(dcd->hwndParent) > 1));
1747 break;
1748
1749 case IDM_DETAILSSETUP:
1750 SetDetailsSwitches((HWND) mp2, &dcd->ds);
1751 break;
1752
1753 case IDM_COMMANDSMENU:
1754 SetupCommandMenu((HWND) mp2, hwnd);
1755 break;
1756
1757 case IDM_SORTSUBMENU:
1758 SetSortChecks((HWND) mp2, dcd->sortFlags);
1759 break;
1760
1761 case IDM_WINDOWSMENU:
1762 SetupWinList((HWND) mp2,
1763 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
1764 break;
1765 }
1766 dcd->hwndLastMenu = (HWND) mp2;
1767 }
1768 if (msg == WM_INITMENU)
1769 break;
1770 return 0;
1771
1772 case UM_FILTER:
1773 if (dcd) {
1774
1775 PCNRITEM pci;
1776
1777 if (mp1)
1778 SetMask((CHAR *)mp1, &dcd->mask);
1779
1780 dcd->suspendview = 1;
1781 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1782 dcd->suspendview = 0;
1783 if (fAutoView && hwndMain) {
1784 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1785 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1786 if (pci && (INT) pci != -1 &&
1787 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1788 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1789 else
1790 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1791 }
1792 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1793 }
1794 return 0;
1795
1796 case UM_COMMAND:
1797 if (mp1) {
1798 if (dcd) {
1799 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1800 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
1801 FreeListInfo((LISTINFO *) mp1);
1802 }
1803 else
1804 return (MRESULT) TRUE;
1805 }
1806 else
1807 FreeListInfo((LISTINFO *) mp1);
1808 }
1809 return 0;
1810
1811 case UM_NOTIFY:
1812 if (mp2)
1813 Notify((CHAR *)mp2);
1814 return 0;
1815
1816 case UM_DRIVECMD:
1817 if (mp1)
1818 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0), mp1);
1819 return 0;
1820
1821 case WM_COMMAND:
1822 DosError(FERR_DISABLEHARDERR);
1823 if (dcd) {
1824 switch (SHORT1FROMMP(mp1)) {
1825 case IDM_SETTARGET:
1826 SetTargetDir(hwnd, FALSE, NULL);
1827 break;
1828
1829 case IDM_CREATE:
1830 {
1831 STRINGINPARMS sip;
1832 CHAR filename[CCHMAXPATHCOMP];
1833
1834 memset(&sip, 0, sizeof(sip));
1835 sip.help = GetPString(IDS_CREATETEXT);
1836 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1837 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1838 strcpy(filename, "NEWFILE.TXT");
1839 sip.ret = filename;
1840 sip.title = GetPString(IDS_CREATETITLETEXT);
1841 if (WinDlgBox(HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle,
1842 STR_FRAME, &sip)) {
1843 bstrip(sip.ret);
1844 if (*sip.ret) {
1845 CHAR newfile[CCHMAXPATH];
1846 FILE *fp;
1847 INT test;
1848 PCNRITEM pci;
1849
1850 strcpy(newfile, dcd->directory);
1851 AddBackslashToPath(newfile);
1852# if 0
1853 if (newfile[strlen(newfile) - 1] != '\\')
1854 strcat(newfile, "\\");
1855# endif
1856 strcat(newfile, sip.ret);
1857 test = IsFile(newfile);
1858 if (test != 1) {
1859 CHAR *modew = "w";
1860
1861 fp = xfopen(newfile, modew, pszSrcFile, __LINE__, TRUE);
1862 }
1863 if (test != 1 && !fp) {
1864 saymsg(MB_ENTER,
1865 hwnd,
1866 GetPString(IDS_ERRORTEXT),
1867 GetPString(IDS_CREATEERRORTEXT), newfile);
1868 }
1869 else {
1870 if (fp) {
1871 WinSendMsg(hwnd, UM_UPDATERECORD, MPFROMP(newfile), MPVOID);
1872 fclose(fp);
1873 }
1874 if (*editor) {
1875
1876 CHAR *dummy[2];
1877
1878 dummy[0] = newfile;
1879 dummy[1] = NULL;
1880 ExecOnList(hwnd,
1881 editor, WINDOWED | SEPARATE, NULL, NULL,
1882 dummy, NULL, pszSrcFile, __LINE__);
1883 }
1884 else
1885 StartMLEEditor(dcd->hwndParent, 4, newfile, dcd->hwndFrame);
1886 pci = FindCnrRecord(hwnd, newfile, NULL, TRUE, FALSE, TRUE);
1887 if (pci && (INT) pci != -1)
1888 // make sure that record shows in viewport
1889 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1890 }
1891 }
1892 }
1893 }
1894 break;
1895
1896 case IDM_CONTEXTMENU:
1897 {
1898 PCNRITEM pci;
1899
1900 pci = (PCNRITEM) CurrentRecord(hwnd);
1901 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
1902 MPFROMP(pci));
1903 }
1904 break;
1905
1906 case IDM_MAXIMIZE:
1907 PostMsg(hwndMain, UM_MAXIMIZE, MPFROMLONG(dcd->hwndFrame), MPVOID);
1908 break;
1909
1910 case IDM_SHOWALLFILESCNR:
1911 StartSeeAll(HWND_DESKTOP, FALSE, dcd->directory);
1912 break;
1913
1914 case IDM_SHOWALLFILES:
1915 {
1916 PCNRITEM pci;
1917
1918 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1919 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1920 if (pci && (INT) pci != -1) {
1921
1922 static CHAR dirname[CCHMAXPATH];
1923
1924 strcpy(dirname, pci->pszFileName);
1925 MakeValidDir(dirname);
1926 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1927 }
1928 }
1929 break;
1930
1931 case IDM_FINDINTREE:
1932 if (hwndTree) {
1933 PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
1934
1935 if (pszTempDir) {
1936 if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir),
1937 MPFROMLONG(1L)))
1938 free(pszTempDir);
1939 }
1940 }
1941 break;
1942
1943 case IDM_BEGINEDIT:
1944 OpenEdit(hwnd);
1945 break;
1946
1947 case IDM_ENDEDIT:
1948 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1949 break;
1950
1951 case IDM_SHOWSELECT:
1952 QuickPopup(hwnd,
1953 dcd,
1954 CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP), IDM_SELECTSUBMENU);
1955 break;
1956
1957 case IDM_SHOWSORT:
1958 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP),
1959 IDM_SORTSUBMENU);
1960 break;
1961
1962 case IDM_VIEWORARC:
1963 {
1964 SWP swp;
1965 PCNRITEM pci;
1966
1967 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1968 MPFROMLONG(CMA_FIRST),
1969 MPFROMSHORT(CRA_CURSORED));
1970 if (pci && (INT) pci != -1) {
1971 WinQueryWindowPos(dcd->hwndFrame, &swp);
1972 DefaultViewKeys(hwnd,
1973 dcd->hwndFrame,
1974 dcd->hwndParent, &swp, pci->pszFileName);
1975 }
1976 }
1977 break;
1978
1979 case IDM_DIRCNRSETTINGS:
1980 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1981 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_DIRCNRSETTINGS), mp2);
1982 else {
1983 WinDlgBox(HWND_DESKTOP,
1984 hwnd,
1985 CfgDlgProc,
1986 FM3ModHandle,
1987 CFG_FRAME,
1988 MPFROMLONG(IDM_DIRCNRSETTINGS));
1989 }
1990 break;
1991
1992 case IDM_QTREE:
1993 case IDM_TREE:
1994 {
1995 CHAR newpath[CCHMAXPATH];
1996 APIRET rc;
1997 PCNRITEM pci;
1998
1999 if (SHORT1FROMMP(mp1) == IDM_TREE) {
2000 pci = (PCNRITEM) CurrentRecord(hwnd);
2001 if (pci && (INT) pci != -1)
2002 strcpy(newpath, pci->pszFileName);
2003 else
2004 strcpy(newpath, dcd->directory);
2005 }
2006 else
2007 strcpy(newpath, dcd->directory);
2008 MakeValidDir(newpath);
2009 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ObjCnrDlgProc,
2010 FM3ModHandle, QTREE_FRAME, MPFROMP(newpath));
2011 if (rc)
2012 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(newpath), MPVOID);
2013 }
2014 break;
2015
2016 case IDM_RESELECT:
2017 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
2018 break;
2019
2020 case IDM_HELP:
2021 if (hwndHelp) {
2022 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2023 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
2024 else
2025 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
2026 }
2027 break;
2028
2029 case IDM_WINDOWDLG:
2030 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2031 PostMsg(dcd->hwndParent, UM_COMMAND,
2032 MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
2033 break;
2034
2035 case IDM_SORTSMARTNAME:
2036 case IDM_SORTNAME:
2037 case IDM_SORTFILENAME:
2038 case IDM_SORTSIZE:
2039 case IDM_SORTEASIZE:
2040 case IDM_SORTFIRST:
2041 case IDM_SORTLAST:
2042 case IDM_SORTLWDATE:
2043 case IDM_SORTLADATE:
2044 case IDM_SORTCRDATE:
2045 case IDM_SORTSUBJECT:
2046 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
2047 case IDM_SORTDIRSFIRST:
2048 case IDM_SORTDIRSLAST:
2049 case IDM_SORTREVERSE:
2050 switch (SHORT1FROMMP(mp1)) {
2051 case IDM_SORTSUBJECT:
2052 dcd->sortFlags |= SORT_SUBJECT;
2053 break;
2054 case IDM_SORTSMARTNAME:
2055 case IDM_SORTFILENAME:
2056 dcd->sortFlags |= SORT_FILENAME;
2057 break;
2058 case IDM_SORTSIZE:
2059 dcd->sortFlags |= SORT_SIZE;
2060 break;
2061 case IDM_SORTEASIZE:
2062 dcd->sortFlags |= SORT_EASIZE;
2063 break;
2064 case IDM_SORTFIRST:
2065 dcd->sortFlags |= SORT_FIRSTEXTENSION;
2066 break;
2067 case IDM_SORTLAST:
2068 dcd->sortFlags |= SORT_LASTEXTENSION;
2069 break;
2070 case IDM_SORTLWDATE:
2071 dcd->sortFlags |= SORT_LWDATE;
2072 break;
2073 case IDM_SORTLADATE:
2074 dcd->sortFlags |= SORT_LADATE;
2075 break;
2076 case IDM_SORTCRDATE:
2077 dcd->sortFlags |= SORT_CRDATE;
2078 break;
2079 case IDM_SORTDIRSFIRST:
2080 if (dcd->sortFlags & SORT_DIRSFIRST)
2081 dcd->sortFlags &= (~SORT_DIRSFIRST);
2082 else {
2083 dcd->sortFlags |= SORT_DIRSFIRST;
2084 dcd->sortFlags &= (~SORT_DIRSLAST);
2085 }
2086 break;
2087 case IDM_SORTDIRSLAST:
2088 if (dcd->sortFlags & SORT_DIRSLAST)
2089 dcd->sortFlags &= (~SORT_DIRSLAST);
2090 else {
2091 dcd->sortFlags |= SORT_DIRSLAST;
2092 dcd->sortFlags &= (~SORT_DIRSFIRST);
2093 }
2094 break;
2095 case IDM_SORTREVERSE:
2096 if (dcd->sortFlags & SORT_REVERSE)
2097 dcd->sortFlags &= (~SORT_REVERSE);
2098 else
2099 dcd->sortFlags |= SORT_REVERSE;
2100 break;
2101 }
2102 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
2103 MPFROMLONG(dcd->sortFlags));
2104 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2105 DIR_SORT), dcd->sortFlags, FALSE);
2106 break;
2107
2108 case IDM_COLLECT:
2109 case IDM_GREP:
2110 if (!Collector) {
2111
2112 HWND hwndC;
2113 SWP swp;
2114
2115 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2116 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2117 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2118 hwndC = StartCollector((fExternalCollector ||
2119 strcmp(realappname, FM3Str)) ?
2120 HWND_DESKTOP : dcd->hwndParent, 4);
2121 if (hwndC) {
2122 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2123 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2124 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2125 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2126 SWP_SHOW | SWP_ZORDER);
2127 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) && fAutoTile &&
2128 !strcmp(realappname, FM3Str))
2129 TileChildren(dcd->hwndParent, TRUE);
2130 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2131 DosSleep(100); // 05 Aug 07 GKY 250
2132 }
2133 }
2134 else
2135 StartCollector(dcd->hwndParent, 4);
2136 if (SHORT1FROMMP(mp1) == IDM_GREP) {
2137 PCNRITEM pci = NULL;
2138
2139 pci = WinSendMsg(hwnd,
2140 CM_QUERYRECORDEMPHASIS,
2141 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
2142 if (pci && (INT) pci != -1)
2143 PostMsg(Collector, WM_COMMAND,
2144 MPFROM2SHORT(IDM_GREP, 0), MPFROMP(pci->pszFileName));
2145 else
2146 PostMsg(Collector, WM_COMMAND,
2147 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
2148 }
2149 else
2150 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2151 break;
2152
2153 case IDM_COLLECTOR:
2154 DosSleep(32); // 05 Aug 07 GKY 64
2155 {
2156 CHAR **list;
2157
2158 list = BuildList(hwnd);
2159 if (list) {
2160 if (Collector) {
2161 if (!PostMsg(Collector,
2162 WM_COMMAND,
2163 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2164 FreeList(list);
2165 else if (fUnHilite)
2166 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2167 }
2168 else
2169 FreeList(list);
2170 }
2171 }
2172 break;
2173
2174 case IDM_UNDELETE:
2175 {
2176 PCNRITEM pci;
2177 CHAR path[CCHMAXPATH];
2178 HOBJECT hObject;
2179 HWND hwndDesktop;
2180
2181 hObject = WinQueryObject("<XWP_TRASHCAN>");
2182 if (hObject != NULLHANDLE && fTrashCan) {
2183 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2184 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2185 WinOpenObject(hObject, 0, TRUE);
2186 }
2187 else {
2188 pci = (PCNRITEM) CurrentRecord(hwnd);
2189 if (pci && (INT) pci != -1) {
2190 strcpy(path, pci->pszFileName);
2191 MakeValidDir(path);
2192 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2193 UNDEL_FRAME, MPFROMP(path));
2194 }
2195 }
2196 }
2197 break;
2198
2199 case IDM_UNDELETESPEC:
2200 {
2201 HOBJECT hObject;
2202 HWND hwndDesktop;
2203
2204 hObject = WinQueryObject("<XWP_TRASHCAN>");
2205 if (hObject != NULLHANDLE && fTrashCan) {
2206 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2207 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2208 WinOpenObject(hObject, 0, TRUE);
2209 }
2210 else
2211 WinDlgBox(HWND_DESKTOP,
2212 hwnd,
2213 UndeleteDlgProc,
2214 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2215 }
2216 break;
2217
2218 case IDM_RESORT:
2219# if 0
2220 WinSendMsg(hwnd,
2221 CM_SORTRECORD,
2222 MPFROMP(SortDirCnr),
2223 MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
2224#endif
2225 WinSendMsg(hwnd,
2226 CM_SORTRECORD,
2227 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2228 break;
2229
2230 case IDM_FILTER:
2231 {
2232 BOOL empty = FALSE;
2233 PCNRITEM pci;
2234 CHAR *p;
2235
2236 if (!*dcd->mask.szMask) {
2237 empty = TRUE;
2238 pci = (PCNRITEM) CurrentRecord(hwnd);
2239 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2240 p = strrchr(pci->pszFileName, '\\');
2241 if (p) {
2242 p++;
2243 strcpy(dcd->mask.szMask, p);
2244 }
2245 }
2246 }
2247 *(dcd->mask.prompt) = 0;
2248
2249 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2250 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2251 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2252 else if (empty)
2253 *dcd->mask.szMask = 0;
2254 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2255 DIR_FILTER), &dcd->mask, FALSE);
2256 }
2257 break;
2258
2259 case IDM_UNHIDEALL:
2260 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2261 break;
2262
2263 case IDM_HIDEALL:
2264 if (fAutoView && hwndMain)
2265 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2266 dcd->suspendview = 1;
2267 HideAll(hwnd);
2268 dcd->suspendview = 0;
2269 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2270 break;
2271
2272 case IDM_SELECTBOTH:
2273 case IDM_SELECTONE:
2274 case IDM_SELECTMORE:
2275 case IDM_SELECTNEWER:
2276 case IDM_SELECTOLDER:
2277 case IDM_SELECTBIGGER:
2278 case IDM_SELECTSMALLER:
2279 case IDM_DESELECTBOTH:
2280 case IDM_DESELECTONE:
2281 case IDM_DESELECTMORE:
2282 case IDM_DESELECTNEWER:
2283 case IDM_DESELECTOLDER:
2284 case IDM_DESELECTBIGGER:
2285 case IDM_DESELECTSMALLER:
2286 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2287 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2288 break;
2289 }
2290 case IDM_SELECTLIST:
2291 case IDM_SELECTALL:
2292 case IDM_DESELECTALL:
2293 case IDM_SELECTALLFILES:
2294 case IDM_DESELECTALLFILES:
2295 case IDM_SELECTALLDIRS:
2296 case IDM_DESELECTALLDIRS:
2297 case IDM_SELECTMASK:
2298 case IDM_DESELECTMASK:
2299 case IDM_INVERT:
2300 case IDM_SELECTCLIP:
2301 case IDM_DESELECTCLIP:
2302 {
2303 PCNRITEM pci;
2304
2305 pci = (PCNRITEM) CurrentRecord(hwnd);
2306 if ((INT) pci == -1)
2307 pci = NULL;
2308 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2309 if (pci) {
2310 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2311 pci->rc.flRecordAttr |= CRA_FILTERED;
2312 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2313 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2314 break;
2315 }
2316 }
2317 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2318 }
2319 break;
2320
2321 case IDM_RESCAN:
2322 //DosEnterCritSec(); //GKY 11-27-08
2323 dcd->stopflag++;
2324 // DosExitCritSec();
2325 // DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2326 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2327 //DosEnterCritSec(); //GKY 11-27-08
2328 dcd->stopflag--;
2329 //DosExitCritSec();
2330 }
2331 break;
2332
2333 case IDM_SHOWLNAMES:
2334 case IDM_SHOWSUBJECT:
2335 case IDM_SHOWEAS:
2336 case IDM_SHOWSIZE:
2337 case IDM_SHOWICON:
2338 case IDM_SHOWLWDATE:
2339 case IDM_SHOWLWTIME:
2340 case IDM_SHOWLADATE:
2341 case IDM_SHOWLATIME:
2342 case IDM_SHOWCRDATE:
2343 case IDM_SHOWCRTIME:
2344 case IDM_SHOWATTR:
2345 AdjustDetailsSwitches(hwnd,
2346 dcd->hwndLastMenu,
2347 SHORT1FROMMP(mp1),
2348 dcd->directory, NULL, &dcd->ds, FALSE);
2349 break;
2350
2351 case IDM_TREEVIEW:
2352 case IDM_ICON:
2353 case IDM_TEXT:
2354 case IDM_DETAILS:
2355 case IDM_NAME:
2356 case IDM_MINIICONS:
2357 case IDM_DETAILSTITLES:
2358 {
2359 CNRINFO cnri;
2360
2361 memset(&cnri, 0, sizeof(CNRINFO));
2362 cnri.cb = sizeof(CNRINFO);
2363 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2364 MPFROMLONG(sizeof(CNRINFO)));
2365 switch (SHORT1FROMMP(mp1)) {
2366 case IDM_TREEVIEW:
2367 if (!(cnri.flWindowAttr & CV_TREE))
2368 dcd->lastattr = cnri.flWindowAttr;
2369 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2370 CV_DETAIL | CV_NAME | CA_TREELINE));
2371 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2372 if (!dcd->firsttree)
2373 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2374 break;
2375 case IDM_ICON:
2376 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2377 CV_DETAIL | CV_NAME | CA_TREELINE));
2378 cnri.flWindowAttr |= CV_ICON;
2379 break;
2380 case IDM_NAME:
2381 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2382 CV_DETAIL | CV_NAME | CA_TREELINE));
2383 cnri.flWindowAttr |= CV_NAME;
2384 break;
2385 case IDM_TEXT:
2386 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2387 CV_DETAIL | CV_NAME | CA_TREELINE));
2388 cnri.flWindowAttr |= CV_TEXT;
2389 break;
2390 case IDM_DETAILS:
2391 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2392 CV_DETAIL | CV_NAME | CA_TREELINE));
2393 cnri.flWindowAttr |= CV_DETAIL;
2394 break;
2395 case IDM_MINIICONS:
2396 if (cnri.flWindowAttr & CV_MINI)
2397 cnri.flWindowAttr &= (~CV_MINI);
2398 else
2399 cnri.flWindowAttr |= CV_MINI;
2400 break;
2401 case IDM_DETAILSTITLES:
2402 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2403 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2404 else
2405 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2406 break;
2407 }
2408 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2409 cnri.flWindowAttr |= CV_FLOW;
2410 dcd->flWindowAttr = cnri.flWindowAttr;
2411 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2412 MPFROMLONG(CMA_FLWINDOWATTR));
2413 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2414 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2415 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2416 DIR_VIEW), dcd->flWindowAttr);
2417 }
2418 break;
2419
2420 case IDM_SAVETOLIST:
2421 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2422 SAV_FRAME, MPFROMP(&hwnd));
2423 break;
2424
2425 case IDM_SIZES:
2426 {
2427 PCNRITEM pci;
2428 CHAR path[CCHMAXPATH];
2429
2430 pci = (PCNRITEM) CurrentRecord(hwnd);
2431 if (pci && (INT) pci != -1)
2432 strcpy(path, pci->pszFileName);
2433 else
2434 strcpy(path, dcd->directory);
2435 MakeValidDir(path);
2436 WinDlgBox(HWND_DESKTOP,
2437 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2438 }
2439 break;
2440
2441 case IDM_MKDIR:
2442 {
2443 PCNRITEM pci;
2444 BOOL saved;
2445
2446 saved = fSelectedAlways;
2447 fSelectedAlways = FALSE;
2448 pci = (PCNRITEM)CurrentRecord(hwnd);
2449 // 01 Oct 07 SHL Make below selected directory or in current directory
2450 PMMkDir(dcd->hwndParent,
2451 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2452 FALSE);
2453 fSelectedAlways = saved;
2454 }
2455 break;
2456
2457 case IDM_SWITCH:
2458 if (mp2) {
2459 strcpy(dcd->previous, dcd->directory);
2460 strcpy(dcd->directory, (CHAR *)mp2);
2461 //DosEnterCritSec(); // GKY 11-27-08
2462 dcd->stopflag++;
2463 //DosExitCritSec();
2464 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2465 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2466 strcpy(dcd->directory, dcd->previous);
2467 //DosEnterCritSec(); // GKY 11-27-08
2468 dcd->stopflag--;
2469 //DosExitCritSec();
2470 }
2471 else if (*dcd->directory) {
2472 if (hwndMain)
2473 WinSendMsg(hwndMain,
2474 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2475 else
2476 add_udir(FALSE, dcd->directory);
2477 }
2478 }
2479 break;
2480
2481 case IDM_PARENT:
2482 {
2483 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
2484
2485 strcpy(tempname1, dcd->directory);
2486 AddBackslashToPath(tempname1);
2487 strcat(tempname1, "..");
2488 DosError(FERR_DISABLEHARDERR);
2489 if (!DosQueryPathInfo(tempname1,
2490 FIL_QUERYFULLNAME,
2491 tempname2, sizeof(tempname2))) {
2492 if (stricmp(dcd->directory, tempname2)) {
2493 strcpy(dcd->previous, dcd->directory);
2494 strcpy(dcd->directory, tempname2);
2495 dcd->stopflag++;
2496 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2497 if (!PostMsg(dcd->hwndObject,
2498 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2499 strcpy(dcd->directory, dcd->previous);
2500 dcd->stopflag--;
2501 }
2502 else if (*dcd->directory) {
2503 if (hwndMain)
2504 WinSendMsg(hwndMain,
2505 UM_SETUSERLISTNAME,
2506 MPFROMP(dcd->directory), MPVOID);
2507 else
2508 add_udir(FALSE, dcd->directory);
2509 }
2510 }
2511 }
2512 }
2513 break;
2514
2515 case IDM_PREVIOUS:
2516 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
2517
2518 CHAR tempname[CCHMAXPATH];
2519
2520 if (IsValidDir(dcd->previous)) {
2521 strcpy(tempname, dcd->directory);
2522 strcpy(dcd->directory, dcd->previous);
2523 strcpy(dcd->previous, tempname);
2524 dcd->stopflag++; ;
2525 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2526 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2527 strcpy(dcd->directory, dcd->previous);
2528 dcd->stopflag--;
2529 }
2530 else if (*dcd->directory) {
2531 if (hwndMain)
2532 WinSendMsg(hwndMain,
2533 UM_SETUSERLISTNAME,
2534 MPFROMP(dcd->directory), MPVOID);
2535 else
2536 add_udir(FALSE, dcd->directory);
2537 }
2538 }
2539 else
2540 *dcd->previous = 0;
2541 }
2542 break;
2543
2544 case IDM_WALKDIR:
2545 {
2546 CHAR newdir[CCHMAXPATH];
2547
2548 strcpy(newdir, dcd->directory);
2549 if (!WinDlgBox(HWND_DESKTOP,
2550 dcd->hwndParent,
2551 WalkAllDlgProc,
2552 FM3ModHandle,
2553 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2554 break;
2555 if (stricmp(newdir, dcd->directory)) {
2556 strcpy(dcd->previous, dcd->directory);
2557 strcpy(dcd->directory, newdir);
2558 dcd->stopflag++;
2559 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2560 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2561 strcpy(dcd->directory, dcd->previous);
2562 dcd->stopflag--;
2563 }
2564 else if (*dcd->directory) {
2565 if (hwndMain)
2566 WinSendMsg(hwndMain,
2567 UM_SETUSERLISTNAME,
2568 MPFROMP(dcd->directory), MPVOID);
2569 else
2570 add_udir(FALSE, dcd->directory);
2571 }
2572 }
2573 }
2574 break;
2575
2576 case IDM_OPENICONME:
2577 OpenObject(dcd->directory, PCSZ_ICON, dcd->hwndFrame);
2578 break;
2579 case IDM_OPENDETAILSME:
2580 OpenObject(dcd->directory, Details, dcd->hwndFrame);
2581 break;
2582 case IDM_OPENTREEME:
2583 OpenObject(dcd->directory, PCSZ_TREE, dcd->hwndFrame);
2584 break;
2585 case IDM_OPENSETTINGSME:
2586 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2587 break;
2588
2589 case IDM_DOITYOURSELF:
2590 case IDM_UPDATE:
2591 case IDM_OPENWINDOW:
2592 case IDM_OPENSETTINGS:
2593 case IDM_OPENDEFAULT:
2594 case IDM_OPENICON:
2595 case IDM_OPENDETAILS:
2596 case IDM_OPENTREE:
2597 case IDM_OBJECT:
2598 case IDM_SHADOW:
2599 case IDM_SHADOW2:
2600 case IDM_DELETE:
2601 case IDM_PERMDELETE:
2602 case IDM_PRINT:
2603 case IDM_ATTRS:
2604 case IDM_INFO:
2605 case IDM_COPY:
2606 case IDM_MOVE:
2607 case IDM_WPSMOVE:
2608 case IDM_WPSCOPY:
2609 case IDM_WILDCOPY:
2610 case IDM_WILDMOVE:
2611 case IDM_RENAME:
2612 case IDM_COMPARE:
2613 case IDM_EAS:
2614 case IDM_SUBJECT:
2615 case IDM_VIEW:
2616 case IDM_VIEWTEXT:
2617 case IDM_VIEWBINARY:
2618 case IDM_VIEWARCHIVE:
2619 case IDM_EDIT:
2620 case IDM_EDITTEXT:
2621 case IDM_EDITBINARY:
2622 case IDM_SAVETOCLIP:
2623 case IDM_SAVETOCLIPFILENAME:
2624 case IDM_APPENDTOCLIP:
2625 case IDM_APPENDTOCLIPFILENAME:
2626 case IDM_ARCHIVE:
2627 case IDM_ARCHIVEM:
2628 case IDM_EXTRACT:
2629 case IDM_MCIPLAY:
2630 case IDM_COLLECTFROMFILE:
2631 case IDM_UUDECODE:
2632 case IDM_UNLOCKFILE:
2633 case IDM_MERGE:
2634 {
2635 LISTINFO *li;
2636 ULONG action = UM_ACTION;
2637 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2638 if (li) {
2639 li->type = SHORT1FROMMP(mp1);
2640 li->hwnd = hwnd;
2641 li->list = BuildList(hwnd);
2642 if (li->type == IDM_DELETE)
2643 ignorereadonly = FALSE;
2644 switch (SHORT1FROMMP(mp1)) {
2645 case IDM_WILDMOVE:
2646 case IDM_WILDCOPY:
2647 case IDM_MOVE:
2648 case IDM_COPY:
2649 case IDM_WPSMOVE:
2650 case IDM_WPSCOPY:
2651 break;
2652 default:
2653 strcpy(li->targetpath, dcd->directory);
2654 break;
2655 }
2656 if (li->list) {
2657 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2658 if (!Collector) {
2659
2660 HWND hwndC;
2661 SWP swp;
2662
2663 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2664 !fAutoTile &&
2665 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2666 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2667 hwndC = StartCollector((fExternalCollector ||
2668 strcmp(realappname, FM3Str)) ?
2669 HWND_DESKTOP : dcd->hwndParent, 4);
2670 if (hwndC) {
2671 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2672 !fAutoTile && (!fExternalCollector &&
2673 !strcmp(realappname, FM3Str)))
2674 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2675 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2676 SWP_SHOW | SWP_ZORDER);
2677 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2678 fAutoTile && !strcmp(realappname, FM3Str))
2679 TileChildren(dcd->hwndParent, TRUE);
2680 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2681 SWP_ACTIVATE);
2682 DosSleep(100); //05 Aug 07 GKY 250
2683 }
2684 }
2685 else
2686 StartCollector(dcd->hwndParent, 4);
2687 }
2688 switch (SHORT1FROMMP(mp1)) {
2689 case IDM_APPENDTOCLIP:
2690 case IDM_APPENDTOCLIPFILENAME:
2691 case IDM_SAVETOCLIP:
2692 case IDM_SAVETOCLIPFILENAME:
2693 case IDM_ARCHIVE:
2694 case IDM_ARCHIVEM:
2695 case IDM_DELETE:
2696 case IDM_PERMDELETE:
2697 case IDM_ATTRS:
2698 case IDM_PRINT:
2699 case IDM_SHADOW:
2700 case IDM_SHADOW2:
2701 case IDM_OBJECT:
2702 case IDM_VIEW:
2703 case IDM_VIEWTEXT:
2704 case IDM_VIEWBINARY:
2705 case IDM_EDIT:
2706 case IDM_EDITTEXT:
2707 case IDM_EDITBINARY:
2708 case IDM_MCIPLAY:
2709 case IDM_UPDATE:
2710 case IDM_DOITYOURSELF:
2711 case IDM_INFO:
2712 case IDM_EAS:
2713 action = UM_MASSACTION;
2714 break;
2715 }
2716 if (li->type == IDM_DELETE)
2717 ignorereadonly = FALSE;
2718 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2719 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2720 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2721 *li->targetpath = 0;
2722 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2723 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2724 FreeListInfo(li);
2725 }
2726 else if (fUnHilite)
2727 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2728 }
2729 else
2730 free(li);
2731 }
2732 }
2733 break;
2734
2735 case IDM_DRIVESMENU:
2736 if (!hwndMain)
2737 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2738 break;
2739
2740 default:
2741 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2742 return 0;
2743 else {
2744 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2745 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2746
2747 register INT x;
2748
2749 if (!cmdloaded)
2750 load_commands();
2751 x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
2752 if (x >= 0) {
2753 //x++;
2754 RunCommand(hwnd, x);
2755 if (fUnHilite)
2756 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2757 }
2758 }
2759 }
2760 break;
2761 }
2762 }
2763 return 0;
2764
2765 case UM_FIXCNRMLE:
2766 case UM_FIXEDITNAME:
2767 return CommonCnrProc(hwnd, msg, mp1, mp2);
2768
2769 case UM_FILESMENU:
2770 {
2771 PCNRITEM pci;
2772 HWND menuHwnd = (HWND) 0;
2773
2774 pci = (PCNRITEM) CurrentRecord(hwnd);
2775 if (pci && (INT) pci != -1) {
2776 if (pci->attrFile & FILE_DIRECTORY) {
2777 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2778 // WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2779 }
2780 else
2781 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2782 }
2783 return MRFROMLONG(menuHwnd);
2784 }
2785
2786 case WM_CONTROL:
2787 DosError(FERR_DISABLEHARDERR);
2788 if (dcd) {
2789 switch (SHORT2FROMMP(mp1)) {
2790 case CN_COLLAPSETREE:
2791 case CN_EXPANDTREE:
2792 {
2793 PCNRITEM pci = (PCNRITEM) mp2;
2794
2795 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2796 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2797 struct
2798 {
2799 ULONG serial;
2800 CHAR volumelength;
2801 CHAR volumelabel[CCHMAXPATH];
2802 }
2803 volser;
2804 APIRET rc;
2805
2806 memset(&volser, 0, sizeof(volser));
2807 DosError(FERR_DISABLEHARDERR);
2808 // fixme?
2809 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2810 FSIL_VOLSER, &volser, sizeof(volser));
2811 if (rc) {
2812 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2813 GetPString(IDS_CANTFINDDIRTEXT),
2814 pci->pszFileName);
2815 if (!fErrorBeepOff)
2816 DosBeep(250,100);
2817 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2818 UnFlesh(hwnd, pci);
2819 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2820 }
2821 else {
2822 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2823 !volser.serial ||
2824 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2825 volser.serial)
2826 UnFlesh(hwnd, pci);
2827 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2828 (!volser.serial ||
2829 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2830 volser.serial)) {
2831 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && Flesh(hwnd, pci) &&
2832 !dcd->suspendview && fTopDir ) {
2833 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2834 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
2835 }
2836 }
2837 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2838 }
2839 }
2840 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2841 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir) {
2842 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2843 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
2844 }
2845 }
2846 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2847 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2848
2849 }
2850 }
2851 break;
2852
2853 case CN_CONTEXTMENU:
2854 {
2855 PCNRITEM pci = (PCNRITEM) mp2;
2856
2857 if (pci) {
2858 WinSendMsg(hwnd,
2859 CM_SETRECORDEMPHASIS,
2860 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2861 MarkAll(hwnd, FALSE, FALSE, TRUE);
2862 if (pci->attrFile & FILE_DIRECTORY)
2863 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2864 else
2865 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2866 }
2867 else {
2868 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2869 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2870 WinSendMsg(hwnd,
2871 CM_SETRECORDEMPHASIS,
2872 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2873 dcd->cnremphasized = TRUE;
2874 }
2875 }
2876 if (dcd->hwndLastMenu) {
2877 if (dcd->hwndLastMenu == DirCnrMenu) {
2878 if (dcd->flWindowAttr & CV_MINI)
2879 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2880 }
2881 if (dcd->hwndLastMenu == DirMenu)
2882 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2883 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2884 if (dcd->cnremphasized) {
2885 WinSendMsg(hwnd,
2886 CM_SETRECORDEMPHASIS,
2887 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2888 dcd->cnremphasized = TRUE;
2889 }
2890 MarkAll(hwnd, TRUE, FALSE, TRUE);
2891 }
2892 }
2893 }
2894 break;
2895
2896 case CN_DROPHELP:
2897 if (mp2) {
2898
2899 PDRAGINFO pDInfo;
2900 PCNRITEM pci;
2901 ULONG numitems;
2902 USHORT usOperation;
2903
2904 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2905 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2906 if (!DrgAccessDraginfo(pDInfo)) {
2907 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2908 GetPString(IDS_DROPERRORTEXT));
2909 }
2910 else {
2911 numitems = DrgQueryDragitemCount(pDInfo);
2912 usOperation = pDInfo->usOperation;
2913 if (usOperation == DO_DEFAULT)
2914 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
2915 FreeDragInfoData(hwnd, pDInfo);
2916 saymsg(MB_ENTER | MB_ICONASTERISK,
2917 hwnd,
2918 GetPString(IDS_DROPHELPHDRTEXT),
2919 GetPString(IDS_DROPHELPTEXT),
2920 numitems,
2921 &"s"[numitems == 1L],
2922 pci ? NullStr : GetPString(IDS_NOTEXT),
2923 pci ? NullStr : " ",
2924 pci ? pci->pszFileName : NullStr,
2925 pci ? " " : NullStr,
2926 GetPString((usOperation == DO_MOVE) ?
2927 IDS_MOVETEXT :
2928 (usOperation == DO_LINK) ?
2929 IDS_LINKTEXT : IDS_COPYTEXT));
2930 }
2931 }
2932 return 0;
2933
2934 case CN_DRAGLEAVE:
2935 return 0;
2936
2937 case CN_DRAGAFTER:
2938 case CN_DRAGOVER:
2939 if (mp2) {
2940
2941 PDRAGITEM pDItem; // Pointer to DRAGITEM
2942 PDRAGINFO pDInfo; // Pointer to DRAGINFO
2943 PCNRITEM pci;
2944 USHORT uso;
2945
2946 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2947 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2948 if (!DrgAccessDraginfo(pDInfo)) {
2949 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2950 PCSZ_DRGACCESSDRAGINFO);
2951 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2952 }
2953 if (*dcd->directory &&
2954 (driveflags[toupper(*dcd->directory) - 'A'] &
2955 DRIVE_NOTWRITEABLE)) {
2956 DrgFreeDraginfo(pDInfo);
2957 return MRFROM2SHORT(DOR_DROP, // Return okay to link
2958 DO_LINK); // (compare) only
2959 }
2960 if (pci) {
2961 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2962 DrgFreeDraginfo(pDInfo);
2963 return (MRFROM2SHORT(DOR_NODROP, 0));
2964 }
2965 uso = pDInfo->usOperation;
2966 if (uso == DO_DEFAULT)
2967 uso = fCopyDefault ? DO_COPY : DO_MOVE;
2968 if (!(pci->attrFile & FILE_DIRECTORY)) {
2969 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2970 DrgFreeDraginfo(pDInfo);
2971 return MRFROM2SHORT(DOR_NODROP, 0);
2972 }
2973 if (uso != DO_LINK &&
2974 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2975 DRIVE_NOTWRITEABLE)) {
2976
2977 ARC_TYPE *info = NULL;
2978
2979 if (!fQuickArcFind &&
2980 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2981 DRIVE_SLOW))
2982 info = find_type(pci->pszFileName, NULL);
2983 else
2984 info = quick_find_type(pci->pszFileName, NULL);
2985 if (!info || ((uso == DO_MOVE && !info->move) ||
2986 (uso == DO_COPY && !info->create))) {
2987 DrgFreeDraginfo(pDInfo);
2988 return MRFROM2SHORT(DOR_NODROP, 0);
2989 }
2990 }
2991 }
2992 }
2993
2994 /**
2995 * Access DRAGITEM index to DRAGITEM
2996 * Check valid rendering mechanisms and data
2997 */
2998 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2999 if (DrgVerifyRMF(pDItem, (CHAR *) DRM_OS2FILE, NULL) ||
3000 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
3001 DrgVerifyRMF(pDItem, (CHAR *) DRM_FM2ARCMEMBER, (CHAR *) DRF_FM2ARCHIVE))) {
3002 DrgFreeDraginfo(pDInfo);
3003 if (driveflags[toupper(*dcd->directory) - 'A'] &
3004 DRIVE_NOTWRITEABLE)
3005 return MRFROM2SHORT(DOR_DROP, DO_LINK);
3006 if (toupper(*dcd->directory) < 'C')
3007 return MRFROM2SHORT(DOR_DROP, DO_COPY);
3008 return MRFROM2SHORT(DOR_DROP, // Return okay to drop
3009 ((fCopyDefault) ? DO_COPY : DO_MOVE));
3010 }
3011 DrgFreeDraginfo(pDInfo); // Free DRAGINFO
3012 }
3013 return MRFROM2SHORT(DOR_NODROP, 0); // Drop not valid
3014
3015 case CN_INITDRAG:
3016 {
3017 BOOL wasemphasized = FALSE;
3018 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
3019 PCNRITEM pci;
3020
3021 if (pcd) {
3022 pci = (PCNRITEM) pcd->pRecord;
3023 if (pci) {
3024 if ((INT) pci == -1)
3025 pci = NULL;
3026 else if (pci->rc.flRecordAttr & CRA_SELECTED)
3027 wasemphasized = TRUE;
3028 }
3029 else if (!*dcd->directory) {
3030 Runtime_Error(pszSrcFile, __LINE__, NULL);
3031 break;
3032 }
3033 else if (IsRoot(dcd->directory)) {
3034 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
3035 GetPString(IDS_CANTDRAGROOTDIR));
3036 break;
3037 }
3038 if (hwndStatus2) {
3039 if (pci)
3040 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_DRAGFILEOBJTEXT));
3041 else
3042 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_DRAGDIRTEXT));
3043 }
3044 if (DoFileDrag(hwnd,
3045 dcd->hwndObject,
3046 mp2,
3047 NULL,
3048 pci ? NULL : dcd->directory,
3049 pci ? TRUE : FALSE)) {
3050 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
3051 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
3052 }
3053 }
3054 if (hwndStatus2) {
3055 WinSetFocus(HWND_DESKTOP, hwnd);
3056 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3057 }
3058 }
3059 }
3060 return 0;
3061
3062 case CN_DROP:
3063 if (mp2) {
3064
3065 LISTINFO *li;
3066 ULONG action = UM_ACTION;
3067
3068 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
3069 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
3070 if (li) {
3071 if (li->list && li->list[0] && IsRoot(li->list[0]))
3072 li->type = DO_LINK;
3073 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
3074
3075 CHECKLIST cl;
3076
3077 memset(&cl, 0, sizeof(cl));
3078 cl.size = sizeof(cl);
3079 cl.flags = li->type;
3080 cl.list = li->list;
3081 cl.cmd = li->type;
3082 cl.prompt = li->targetpath;
3083 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
3084 DropListProc, FM3ModHandle,
3085 DND_FRAME, MPFROMP(&cl));
3086 if (li->type == DID_ERROR)
3087 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
3088 GetPString(IDS_DRAGDROPDIALOGTEXT));
3089 if (!li->type) {
3090 FreeListInfo(li);
3091 return 0;
3092 }
3093 li->list = cl.list;
3094 if (!li->list || !li->list[0]) {
3095 FreeListInfo(li);
3096 return 0;
3097 }
3098 }
3099 switch (li->type) {
3100 case DND_LAUNCH:
3101 strcat(li->targetpath, " %a");
3102 ExecOnList(dcd->hwndParent, li->targetpath,
3103 PROMPT | WINDOWED, NULL, NULL, li->list, NULL,
3104 pszSrcFile, __LINE__);
3105 FreeList(li->list);
3106 li->list = NULL;
3107 break;
3108 case DO_LINK:
3109 if (fLinkSetsIcon) {
3110 li->type = IDM_SETICON;
3111 action = UM_MASSACTION;
3112 }
3113 else
3114 li->type = IDM_COMPARE;
3115 break;
3116 case DND_EXTRACT:
3117 if (*li->targetpath && !IsFile(li->targetpath))
3118 li->type = IDM_EXTRACT;
3119 break;
3120 case DND_MOVE:
3121 li->type = IDM_MOVE;
3122 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3123 action = UM_MASSACTION;
3124 li->type = IDM_ARCHIVEM;
3125 }
3126 break;
3127 case DND_WILDMOVE:
3128 li->type = IDM_WILDMOVE;
3129 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3130 action = UM_MASSACTION;
3131 li->type = IDM_ARCHIVEM;
3132 }
3133 break;
3134 case DND_OBJECT:
3135 li->type = IDM_OBJECT;
3136 action = UM_MASSACTION;
3137 break;
3138 case DND_SHADOW:
3139 li->type = IDM_SHADOW;
3140 action = UM_MASSACTION;
3141 break;
3142 case DND_COMPARE:
3143 li->type = IDM_COMPARE;
3144 break;
3145 case DND_SETICON:
3146 action = UM_MASSACTION;
3147 li->type = IDM_SETICON;
3148 break;
3149 case DND_COPY:
3150 li->type = IDM_COPY;
3151 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3152 action = UM_MASSACTION;
3153 li->type = IDM_ARCHIVE;
3154 }
3155 break;
3156 case DND_WILDCOPY:
3157 li->type = IDM_WILDCOPY;
3158 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3159 action = UM_MASSACTION;
3160 li->type = IDM_ARCHIVE;
3161 }
3162 break;
3163 default:
3164 if (*li->arcname && li->info) {
3165 action = UM_MASSACTION;
3166 li->type =
3167 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3168 }
3169 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
3170 action = UM_MASSACTION;
3171 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3172 }
3173 else
3174 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3175 break;
3176 }
3177 if (!li->list || !li->list[0])
3178 FreeListInfo(li);
3179 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
3180 FreeListInfo(li);
3181 else {
3182
3183 USHORT usop = 0;
3184
3185 switch (li->type) {
3186 case IDM_COPY:
3187 case IDM_WILDCOPY:
3188 usop = DO_COPY;
3189 break;
3190 case IDM_MOVE:
3191 case IDM_WILDMOVE:
3192 case IDM_ARCHIVEM:
3193 usop = DO_MOVE;
3194 break;
3195 }
3196 if (usop)
3197 return MRFROM2SHORT(DOR_DROP, usop);
3198 }
3199 }
3200 }
3201 return 0;
3202
3203 case CN_ENDEDIT:
3204 case CN_BEGINEDIT:
3205 {
3206 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3207 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3208
3209 if (pfi || pci) {
3210
3211 MRESULT mre;
3212
3213 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3214 if (mre != (MRESULT) - 1)
3215 return mre;
3216 }
3217 else if (!pfi && !pci)
3218 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3219 }
3220 return 0;
3221
3222 case CN_REALLOCPSZ:
3223 {
3224 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3225 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3226 HWND hwndMLE;
3227 CHAR testname[CCHMAXPATH];
3228
3229 if (!pci && !pfi) {
3230 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3231 WinQueryWindowText(hwndMLE, sizeof(s), s);
3232 chop_at_crnl(s);
3233 bstrip(s);
3234 if (*s) {
3235 if (!DosQueryPathInfo(s,
3236 FIL_QUERYFULLNAME,
3237 testname, sizeof(testname))) {
3238 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3239 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3240 }
3241 }
3242 }
3243 }
3244 else {
3245
3246 MRESULT mre;
3247
3248 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3249 if (mre != (MRESULT) - 1)
3250 return mre;
3251 }
3252 }
3253 return 0;
3254
3255 case CN_EMPHASIS:
3256 if (!mp2)
3257 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3258 else {
3259 PNOTIFYRECORDEMPHASIS pre = mp2;
3260 PCNRITEM pci;
3261 CHAR s[CCHMAXPATHCOMP + 91];
3262
3263 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3264 if (!pci) {
3265 if (hwndStatus2)
3266 WinSetWindowText(hwndStatus2, NullStr);
3267 if (fMoreButtons) {
3268 WinSetWindowText(hwndName, NullStr);
3269 WinSetWindowText(hwndDate, NullStr);
3270 WinSetWindowText(hwndAttr, NullStr);
3271 }
3272 if (hwndMain)
3273 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3274 break;
3275 }
3276 if (pre->fEmphasisMask & CRA_SELECTED) {
3277 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3278 dcd->selectedbytes += (pci->cbFile + pci->easize);
3279 dcd->selectedfiles++;
3280 }
3281 else if (dcd->selectedfiles) {
3282 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3283 dcd->selectedfiles--;
3284 }
3285 if (!dcd->suspendview) {
3286 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3287 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3288 sprintf(s, "%s / %s", tf, tb);
3289 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3290 }
3291 }
3292 if (!dcd->suspendview && hwndMain &&
3293 (pre->fEmphasisMask & CRA_CURSORED) &&
3294 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3295 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3296 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3297 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3298 else
3299 WinSendMsg(hwndMain,
3300 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3301 }
3302 if (!dcd->suspendview &&
3303 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3304 if (pre->fEmphasisMask & CRA_CURSORED) {
3305 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3306 if (fSplitStatus && hwndStatus2) {
3307 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3308 if (!fMoreButtons) {
3309 CHAR date[11];
3310
3311 DateFormat(date, pci->date);
3312 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
3313 tb, date, pci->time.hours, TimeSeparator,
3314 pci->time.minutes, TimeSeparator, pci->time.seconds,
3315 pci->pszDispAttr, pci->pszFileName);
3316 }
3317 else {
3318 *tf = 0;
3319 if (pci->cbFile + pci->easize > 1024) {
3320 CommaFmtULL(tf, sizeof(tf),
3321 pci->cbFile + pci->easize, 'K');
3322 }
3323 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3324 tb,
3325 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3326 }
3327 WinSetWindowText(hwndStatus2, s);
3328 }
3329 if (fMoreButtons) {
3330 CHAR szDate[DATE_BUF_BYTES];
3331
3332 WinSetWindowText(hwndName, pci->pszFileName);
3333 DateFormat(szDate, pci->date);
3334 sprintf(s, "%s %02u%s%02u%s%02u",
3335 szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
3336 TimeSeparator, pci->time.seconds);
3337 WinSetWindowText(hwndDate, s);
3338 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3339 }
3340 }
3341 }
3342 }
3343 }
3344 break;
3345
3346 case CN_ENTER:
3347 if (mp2) {
3348
3349 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3350 FILEFINDBUF3 ffb;
3351 HDIR hDir = HDIR_CREATE;
3352 ULONG nm = 1;
3353 APIRET status = 0;
3354
3355 SetShiftState();
3356 if (pci) {
3357 if (pci->rc.flRecordAttr & CRA_INUSE)
3358 break;
3359 DosError(FERR_DISABLEHARDERR);
3360 status = DosFindFirst(pci->pszFileName,
3361 &hDir,
3362 FILE_NORMAL | FILE_DIRECTORY |
3363 FILE_ARCHIVED | FILE_READONLY |
3364 FILE_HIDDEN | FILE_SYSTEM,
3365 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3366 priority_bumped();
3367 if (!status) {
3368 DosFindClose(hDir);
3369 if (ffb.attrFile & FILE_DIRECTORY) {
3370 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3371 PostMsg(hwnd,
3372 WM_COMMAND,
3373 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3374 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3375 (KC_CTRL | KC_SHIFT))
3376 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3377 else if (shiftstate & KC_CTRL)
3378 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3379 else if (shiftstate & KC_SHIFT) {
3380
3381 HWND hwndDir;
3382
3383 hwndDir = OpenDirCnr((HWND) 0,
3384 dcd->hwndParent,
3385 dcd->hwndFrame,
3386 FALSE, pci->pszFileName);
3387 if (hwndDir) {
3388 if (fMinOnOpen)
3389 WinSetWindowPos(dcd->hwndFrame,
3390 HWND_BOTTOM,
3391 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3392 if (fAutoTile)
3393 TileChildren(dcd->hwndParent, TRUE);
3394 WinSetWindowPos(hwndDir,
3395 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3396 }
3397 }
3398 else {
3399 strcpy(dcd->previous, dcd->directory);
3400 strcpy(dcd->directory, pci->pszFileName);
3401 dcd->stopflag++;
3402 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
3403 if (!PostMsg(dcd->hwndObject,
3404 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3405 dcd->stopflag--;
3406 }
3407 else if (*dcd->directory) {
3408 if (hwndMain)
3409 WinSendMsg(hwndMain,
3410 UM_SETUSERLISTNAME,
3411 MPFROMP(dcd->directory), MPVOID);
3412 else
3413 add_udir(FALSE, dcd->directory);
3414 }
3415 }
3416 }
3417 else {
3418
3419 SWP swp;
3420
3421 WinQueryWindowPos(dcd->hwndFrame, &swp);
3422 WinSendMsg(hwnd,
3423 CM_SETRECORDEMPHASIS,
3424 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3425 DefaultViewKeys(hwnd,
3426 dcd->hwndFrame,
3427 dcd->hwndParent, &swp, pci->pszFileName);
3428 WinSendMsg(hwnd,
3429 CM_SETRECORDEMPHASIS,
3430 MPFROMP(pci),
3431 MPFROM2SHORT(FALSE,
3432 CRA_INUSE |
3433 ((fUnHilite) ? CRA_SELECTED : 0)));
3434 }
3435 }
3436 else {
3437 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3438 NotifyError(pci->pszFileName, status);
3439 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3440 if (hwndStatus)
3441 WinSetWindowText(hwndStatus,
3442 (CHAR *) GetPString(IDS_RESCANSUGGESTEDTEXT));
3443 }
3444 else {
3445 dcd->stopflag++;
3446 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
3447 if (!PostMsg(dcd->hwndObject,
3448 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3449 dcd->stopflag--;
3450 }
3451 else if (*dcd->directory) {
3452 if (hwndMain)
3453 WinSendMsg(hwndMain,
3454 UM_SETUSERLISTNAME,
3455 MPFROMP(dcd->directory), MPVOID);
3456 else
3457 add_udir(FALSE, dcd->directory);
3458 }
3459 }
3460 }
3461 }
3462 else if (*dcd->directory)
3463 OpenObject(dcd->directory, Default, hwnd);
3464 } // CN_ENTER
3465 break;
3466 } // switch mp1
3467 break;
3468 } // if dcd
3469 return 0;
3470
3471 case UM_LOADFILE:
3472 if (dcd && mp2) {
3473
3474 HWND hwnd;
3475
3476 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
3477 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
3478 (CHAR *)mp2, dcd->hwndFrame);
3479 else
3480 hwnd = StartMLEEditor(dcd->hwndParent,
3481 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3482 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
3483 return MRFROMLONG(hwnd);
3484 }
3485 return 0;
3486
3487 case WM_SAVEAPPLICATION:
3488 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3489
3490 SWP swp;
3491
3492 WinQueryWindowPos(dcd->hwndFrame, &swp);
3493 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3494 PrfWriteProfileData(fmprof, appname, "VDirSizePos", &swp, sizeof(swp));
3495 }
3496 break;
3497
3498 case WM_CLOSE:
3499 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3500 if (LastDir == hwnd)
3501 LastDir = (HWND) 0;
3502 if (dcd) {
3503 dcd->stopflag++;
3504 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3505 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3506 if (dcd->hwndObject) {
3507 // Ensure object window destroy does not attempt duplicate clean up
3508 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3509 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3510 Win_Error(dcd->hwndObject, hwnd, pszSrcFile, __LINE__, "hwndObject WinPostMsg failed");
3511 }
3512 if (dcd->hwndRestore)
3513 WinSetWindowPos(dcd->hwndRestore,
3514 HWND_TOP,
3515 0,
3516 0,
3517 0,
3518 0,
3519 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3520 FreeList(dcd->lastselection);
3521 free(dcd);
3522 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3523 DosPostEventSem(CompactSem);
3524 }
3525 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3526 QW_PARENT));
3527 return 0;
3528
3529 case WM_DESTROY:
3530# ifdef FORTIFY
3531 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
3532# endif
3533 if (DirMenu)
3534 WinDestroyWindow(DirMenu);
3535 if (DirCnrMenu)
3536 WinDestroyWindow(DirCnrMenu);
3537 if (FileMenu)
3538 WinDestroyWindow(FileMenu);
3539 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3540 EmptyCnr(hwnd);
3541# ifdef FORTIFY
3542 Fortify_LeaveScope();
3543# endif
3544 break;
3545 } // switch
3546
3547 if (dcd && dcd->oldproc) {
3548# ifdef FORTIFY // 11 May 08 SHL fixme debug fortify
3549 if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
3550 DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x",
3551 msg, mp1, mp2);
3552# endif
3553 return dcd->oldproc(hwnd, msg, mp1, mp2);
3554 }
3555 else
3556 return PFNWPCnr(hwnd, msg, mp1, mp2);
3557}
3558
3559/**
3560 * Search container for matching text
3561 * @return TRUE if key completely handled here
3562 */
3563
3564MRESULT EXPENTRY SearchContainer(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3565{
3566 DIRCNRDATA *dcd = INSTDATA(hwnd);
3567 ULONG thistime;
3568 UINT len;
3569 SEARCHSTRING srch;
3570 PCNRITEM pci;
3571 USHORT key;
3572
3573 if (!dcd)
3574 return FALSE;
3575
3576 // Just to be safe, caller has probably already checked
3577 if (SHORT1FROMMP(mp1) & KC_KEYUP)
3578 return FALSE; // Let PM process key
3579
3580 // Just to be safe, caller has probably already cached
3581 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
3582
3583 // If not plain character or suppressed
3584 // Shift toggles configured setting
3585 if (shiftstate & (KC_ALT | KC_CTRL) || (shiftstate & KC_SHIFT ? !fNoSearch : fNoSearch))
3586 return FALSE; // Let PM process key
3587
3588 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
3589 key = SHORT2FROMMP(mp2);
3590 if (key == VK_BACKSPACE)
3591 key = '\x8';
3592 else if (key == VK_ESC)
3593 key = '\x1b';
3594 else
3595 return FALSE; // Let PM process key
3596 }
3597 else if (SHORT1FROMMP(mp1) & KC_CHAR)
3598 key = SHORT1FROMMP(mp2);
3599 else
3600 return FALSE;
3601
3602 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
3603 if (thistime > dcd->lasttime + 3000)
3604 *dcd->szCommonName = 0; // 3 seconds since last character
3605 dcd->lasttime = thistime;
3606
3607 switch (key) {
3608 case '\x1b': // Esc
3609 *dcd->szCommonName = 0;
3610 break;
3611 default:
3612 if (key == ' ' && !*dcd->szCommonName)
3613 break; // Let PM process space to allow select toggle
3614 len = strlen(dcd->szCommonName);
3615 if (key == '\x8') {
3616 // Backspace
3617 if (len) {
3618 len--;
3619 dcd->szCommonName[len] = 0; // Chop
3620 }
3621 }
3622 else {
3623 if (len >= CCHMAXPATH - 1) {
3624 if (!fErrorBeepOff)
3625 DosBeep(250,100);
3626 // WinAlarm(hwnd,WA_WARNING);
3627 }
3628 else {
3629 dcd->szCommonName[len] = toupper(key);
3630 dcd->szCommonName[len + 1] = 0;
3631 }
3632 }
3633 // Case insensitive search
3634 memset(&srch, 0, sizeof(SEARCHSTRING));
3635 srch.cb = (ULONG) sizeof(SEARCHSTRING);
3636 srch.pszSearch = (PSZ) dcd->szCommonName;
3637 srch.fsPrefix = TRUE;
3638 srch.fsCaseSensitive = FALSE;
3639 srch.usView = CV_ICON;
3640 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
3641 MPFROMLONG(CMA_FIRST));
3642 if (pci && (INT) pci != -1) {
3643 // Got match make found item current item
3644 USHORT attrib = CRA_CURSORED;
3645 // 29 Mar 09 SHL fixme to clear other object select if not extended select
3646 if (!stricmp(pci->pszDisplayName, dcd->szCommonName))
3647 attrib |= CRA_SELECTED;
3648 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
3649 MPFROM2SHORT(TRUE, attrib));
3650 // make sure that record shows in viewport
3651 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
3652 return (MRESULT)TRUE;
3653 }
3654 else {
3655 if (key == ' ')
3656 return FALSE; // Let PM process space to toggle select
3657 // No match
3658 // Erase non-matching last character, len is not yet incremented
3659 dcd->szCommonName[len] = 0;
3660 if (len == 0 && key != '\\') {
3661 // Let's see if user forgot leading backslash
3662 // key = SHORT1FROMMP(mp2);
3663 if (SearchContainer(hwnd, msg, mp1, MPFROM2SHORT('\\', 0))) {
3664 if (SearchContainer(hwnd, msg, mp1, mp2))
3665 return (MRESULT)TRUE; // Grab key from PM
3666 }
3667 }
3668 if (*dcd->szCommonName)
3669 return (MRESULT)TRUE; // Have partial match, grab key from PM
3670#if 0 // 15 Mar 09 SHL fixme to not hang
3671 if (!fErrorBeepOff)
3672 DosBeep(250,100);
3673 // WinAlarm(hwnd,WA_WARNING);
3674#endif
3675 }
3676 } // switch
3677
3678 return FALSE; // Let PM process key
3679}
3680
3681HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3682 ULONG flags)
3683{
3684 /**
3685 * bitmapped flags:
3686 * 0x00000001 = don't close app when window closes
3687 * 0x00000002 = no frame controls
3688 */
3689
3690 HWND hwndFrame = (HWND) 0, hwndClient;
3691 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3692 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3693 USHORT id;
3694 static USHORT idinc = 0;
3695 DIRCNRDATA *dcd;
3696 static BOOL first = FALSE;
3697
3698 if (flags & 2)
3699 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3700 FCF_MINMAX | FCF_ICON));
3701 if (!idinc)
3702 idinc = (rand() % 100);
3703 if (!hwndParent)
3704 hwndParent = HWND_DESKTOP;
3705 if (ParentIsDesktop(hwndParent, hwndParent))
3706 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3707 if (!hwndMain && !first) {
3708 if (DirCnrMenu) {
3709 MENUITEM mi;
3710 memset(&mi, 0, sizeof(mi));
3711 WinSendMsg(DirCnrMenu,
3712 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3713 mi.iPosition = MIT_END;
3714 mi.afStyle = MIS_TEXT;
3715 mi.id = IDM_DRIVESMENU;
3716 WinSendMsg(DirCnrMenu,
3717 MM_INSERTITEM,
3718 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3719 }
3720 first = TRUE;
3721 }
3722 if (directory) {
3723 hwndFrame = WinCreateStdWindow(hwndParent,
3724 WS_VISIBLE,
3725 &FrameFlags,
3726 (CHAR *) WC_DIRCONTAINER,
3727 NULL,
3728 WS_VISIBLE | fwsAnimate,
3729 FM3ModHandle, DIR_FRAME, &hwndClient);
3730 if (hwndFrame && hwndClient) {
3731 id = DIR_FRAME + idinc++;
3732 if (idinc > 99)
3733 idinc = 0;
3734 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3735# ifdef FORTIFY
3736 Fortify_EnterScope();
3737# endif
3738 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3739 if (!dcd) {
3740 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3741 hwndFrame = (HWND) 0;
3742 }
3743 else {
3744 dcd->size = sizeof(DIRCNRDATA);
3745 dcd->id = id;
3746 dcd->type = DIR_FRAME;
3747 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3748 dcd->hwndFrame = hwndFrame;
3749 dcd->hwndClient = hwndClient;
3750 dcd->hwndRestore = hwndRestore;
3751 dcd->dontclose = ((flags & 1) != 0);
3752 dcd->ds.detailslongname = dsDirCnrDefault.detailslongname;
3753 dcd->ds.detailssubject = dsDirCnrDefault.detailssubject;
3754 dcd->ds.detailsea = dsDirCnrDefault.detailsea;
3755 dcd->ds.detailssize = dsDirCnrDefault.detailssize;
3756 dcd->ds.detailsicon = dsDirCnrDefault.detailsicon;
3757 dcd->ds.detailsattr = dsDirCnrDefault.detailsattr;
3758 dcd->ds.detailscrdate = dsDirCnrDefault.detailscrdate;
3759 dcd->ds.detailscrtime = dsDirCnrDefault.detailscrtime;
3760 dcd->ds.detailslwdate = dsDirCnrDefault.detailslwdate;
3761 dcd->ds.detailslwtime = dsDirCnrDefault.detailslwtime;
3762 dcd->ds.detailsladate = dsDirCnrDefault.detailsladate;
3763 dcd->ds.detailslatime = dsDirCnrDefault.detailslatime;
3764 strcpy(dcd->directory, directory);
3765 add_udir(FALSE, directory);
3766 {
3767 PFNWP oldproc;
3768
3769 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3770 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3771 }
3772 dcd->hwndCnr = WinCreateWindow(hwndClient,
3773 WC_CONTAINER,
3774 NULL,
3775 CCS_AUTOPOSITION | CCS_MINIICONS |
3776 CCS_MINIRECORDCORE | ulCnrType, // |
3777 //WS_VISIBLE,
3778 0,
3779 0,
3780 0,
3781 0,
3782 hwndClient,
3783 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3784 if (!dcd->hwndCnr) {
3785 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3786 PCSZ_WINCREATEWINDOW);
3787 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3788 free(dcd);
3789 hwndFrame = (HWND) 0;
3790 }
3791 else {
3792# ifdef FORTIFY
3793 Fortify_ChangeScope(dcd, -1);
3794# endif
3795 RestorePresParams(dcd->hwndCnr, PCSZ_DIRCNR);
3796 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3797 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3798 (PFNWP) DirCnrWndProc);
3799 {
3800 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3801 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3802 };
3803
3804 if (!(flags & 2))
3805 ids[6] = 0;
3806 CommonCreateTextChildren(dcd->hwndClient,
3807 WC_DIRSTATUS, ids);
3808 }
3809 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3810 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3811 if (FrameFlags & FCF_TASKLIST) {
3812
3813 SWP swp, swpD;
3814 ULONG size = sizeof(swp);
3815 LONG cxScreen, cyScreen;
3816
3817 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3818 if (PrfQueryProfileData(fmprof, appname, "VDirSizePos", &swpD, &size)) {
3819 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3820 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3821 if (swp.x + swpD.cx > cxScreen)
3822 swp.x = cxScreen - swpD.cx;
3823 if (swp.y + swpD.cy > cyScreen)
3824 swp.y = cyScreen - swpD.cy;
3825 swp.cx = swpD.cx;
3826 swp.cy = swpD.cy;
3827 }
3828 WinSetWindowPos(hwndFrame,
3829 HWND_TOP,
3830 swp.x,
3831 swp.y,
3832 swp.cx,
3833 swp.cy,
3834 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3835 SWP_ACTIVATE);
3836 }
3837 WinShowWindow(dcd->hwndCnr, TRUE);
3838 }
3839 }
3840# ifdef FORTIFY
3841 Fortify_LeaveScope();
3842# endif
3843 }
3844 }
3845 return hwndFrame;
3846}
3847
3848#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3849#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3850#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.