source: trunk/dll/dircnrs.c@ 1878

Last change on this file since 1878 was 1878, checked in by Gregg Young, 10 years ago

Remove some dead code and comments source files starting with A-D

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