source: trunk/dll/dircnrs.c@ 1793

Last change on this file since 1793 was 1793, checked in by Gregg Young, 11 years ago

Corrected fix for filter trap on close during initial scan. I had failed to account for the fact that directory containers get closed other than at shutdown.

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