source: trunk/dll/dircnrs.c@ 1553

Last change on this file since 1553 was 1553, checked in by Gregg Young, 15 years ago

Rework scanning code to remove redundant scans, prevent double directory entries in the tree container, fix related semaphore performance using combination of event and mutex semaphores

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