source: trunk/dll/dircnrs.c@ 1570

Last change on this file since 1570 was 1570, checked in by Gregg Young, 14 years ago

Added IdleIfNeeded to place load and free loops to idle priority when dealing with large numbers of items. Used SleepIfNeeded more places for a similar purpose.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 105.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 1570 2011-06-12 22:09:19Z 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 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
1416 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
1417 strcpy(dcd->directory, dcd->previous);
1418 //DosEnterCritSec(); //GKY 11-27-08
1419 dcd->stopflag--;
1420 //DosExitCritSec();
1421 }
1422 else if (*dcd->directory) {
1423 if (hwndMain)
1424 WinSendMsg(hwndMain,
1425 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1426 else
1427 add_udir(FALSE, dcd->directory);
1428 }
1429 }
1430 }
1431 }
1432 break;
1433
1434 case WM_TIMER:
1435 // Started/stopped by DirObjWndPro
1436 // dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1437 if (dcd) {
1438 commafmt(tb, sizeof(tb), dcd->totalfiles);
1439 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
1440 sprintf(s, "%s / %s", tb, tf);
1441 // DbgMsg(pszSrcFile, __LINE__, "WM_TIMER %s", s); // 15 Sep 09 SHL fixme debug
1442 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1443 }
1444 break; // WM_TIMER
1445
1446 case UM_RESCAN:
1447 if (dcd) {
1448
1449 CNRINFO cnri;
1450 CHAR szDate[DATE_BUF_BYTES];
1451 PCNRITEM pci;
1452
1453 memset(&cnri, 0, sizeof(CNRINFO));
1454 cnri.cb = sizeof(CNRINFO);
1455 WinSendMsg(hwnd,
1456 CM_QUERYCNRINFO,
1457 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1458 cnri.pszCnrTitle = dcd->directory;
1459 WinSendMsg(hwnd,
1460 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
1461 dcd->totalfiles = cnri.cRecords;
1462 commafmt(tb, sizeof(tb), dcd->totalfiles);
1463 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
1464 sprintf(s, "%s / %s", tb, tf);
1465 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1466 commafmt(tb, sizeof(tb), dcd->selectedfiles);
1467 CommaFmtULL(tf, sizeof(tf), dcd->selectedbytes, 'K');
1468 sprintf(s, "%s / %s", tb, tf);
1469 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1470 if (hwndStatus &&
1471 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1472 PostMsg(dcd->hwndObject, UM_RESCAN2, MPVOID, MPVOID);
1473 if ((fSplitStatus && hwndStatus2) || fMoreButtons) {
1474 pci = WinSendMsg(hwnd,
1475 CM_QUERYRECORDEMPHASIS,
1476 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1477 if (pci && (INT) pci != -1) {
1478 if (fSplitStatus && hwndStatus2) {
1479 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1480 if (!fMoreButtons) {
1481 DateFormat(szDate, pci->date);
1482 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
1483 tb,
1484 szDate,
1485 pci->time.hours,
1486 TimeSeparator,
1487 pci->time.minutes,
1488 TimeSeparator,
1489 pci->time.seconds,
1490 pci->pszDispAttr, pci->pszFileName);
1491 }
1492 else {
1493 *tf = 0;
1494 if (pci->cbFile + pci->easize > 1024) {
1495 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1496 }
1497 sprintf(s,
1498 GetPString(IDS_STATUSSIZETEXT),
1499 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1500 }
1501 WinSetWindowText(hwndStatus2, s);
1502 }
1503 else
1504 WinSetWindowText(hwndStatus2, NullStr);
1505 if (fMoreButtons) {
1506 WinSetWindowText(hwndName, pci->pszFileName);
1507 DateFormat(szDate, pci->date);
1508 sprintf(s, "%s %02u%s%02u%s%02u",
1509 szDate,
1510 pci->time.hours, TimeSeparator,
1511 pci->time.minutes, TimeSeparator,
1512 pci->time.seconds);
1513 WinSetWindowText(hwndDate, s);
1514 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1515 }
1516 }
1517 else {
1518 WinSetWindowText(hwndStatus2, NullStr);
1519 WinSetWindowText(hwndName, NullStr);
1520 WinSetWindowText(hwndDate, NullStr);
1521 WinSetWindowText(hwndAttr, NullStr);
1522 }
1523 }
1524 }
1525 }
1526 return 0;
1527
1528 case UM_SORTRECORD:
1529 if (dcd) {
1530
1531 CNRINFO cnri;
1532
1533 memset(&cnri, 0, sizeof(CNRINFO));
1534 cnri.cb = sizeof(CNRINFO);
1535 WinSendMsg(hwnd,
1536 CM_QUERYCNRINFO,
1537 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1538 cnri.pSortRecord = (PVOID) SortDirCnr;
1539 WinSendMsg(hwnd,
1540 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PSORTRECORD));
1541 WinSendMsg(hwnd,
1542 CM_SORTRECORD,
1543 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
1544 }
1545 return 0;
1546
1547 case UM_SETUP:
1548 if (dcd) {
1549 if (!dcd->hwndObject) {
1550 /*
1551 * first time through -- set things up
1552 */
1553
1554 CNRINFO cnri;
1555
1556 memset(&cnri, 0, sizeof(CNRINFO));
1557 cnri.cb = sizeof(CNRINFO);
1558 WinSendMsg(hwnd,
1559 CM_QUERYCNRINFO,
1560 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1561 cnri.cyLineSpacing = 0;
1562 cnri.cxTreeIndent = 12L;
1563
1564 cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1565 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
1566 CV_FLOW);
1567 cnri.pSortRecord = (PVOID) SortDirCnr;
1568
1569 {
1570 ULONG size = sizeof(ULONG);
1571
1572 PrfQueryProfileData(fmprof, appname, "DirflWindowAttr",
1573 (PVOID) & cnri.flWindowAttr, &size);
1574 size = sizeof(MASK);
1575 if (!*dcd->mask.szMask &&
1576 !dcd->mask.attrFile && !dcd->mask.antiattr) {
1577 if (PrfQueryProfileSize(fmprof, appname, "DirFilter", &size) && size) {
1578 PrfQueryProfileData(fmprof, appname, "DirFilter", &dcd->mask, &size);
1579 SetMask(dcd->mask.szMask, &dcd->mask);
1580 }
1581 else
1582 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1583 FILE_ARCHIVED | FILE_DIRECTORY |
1584 FILE_HIDDEN | FILE_SYSTEM);
1585 }
1586 *(dcd->mask.prompt) = 0;
1587 }
1588 if (dcd->flWindowAttr)
1589 cnri.flWindowAttr = dcd->flWindowAttr;
1590 else
1591 dcd->flWindowAttr = cnri.flWindowAttr;
1592 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH |
1593 CA_TITLEREADONLY | CA_TITLESEPARATOR));
1594 cnri.flWindowAttr |= CV_FLOW;
1595 dcd->flWindowAttr |= CV_FLOW;
1596 if (WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR))
1597 cnri.flWindowAttr &= (~CA_CONTAINERTITLE);
1598 else
1599 cnri.flWindowAttr |= CA_CONTAINERTITLE;
1600 if (!dcd->sortFlags)
1601 dcd->sortFlags = sortFlags;
1602 WinSendMsg(hwnd,
1603 CM_SETCNRINFO,
1604 MPFROMP(&cnri),
1605 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1606 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1607 SetCnrCols(hwnd, FALSE);
1608 if (xbeginthread(MakeObjWin,
1609 245760,
1610 dcd,
1611 pszSrcFile,
1612 __LINE__) == -1)
1613 {
1614 Runtime_Error(pszSrcFile, __LINE__,
1615 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1616 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1617 return 0;
1618 }
1619 else
1620 DosSleep(32); //05 Aug 07 GKY 64
1621 WinEnableMenuItem(DirCnrMenu, IDM_FINDINTREE, (hwndTree != (HWND) 0));
1622 }
1623 if (!fInitialDriveScan)
1624 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1625 }
1626 else {
1627 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1628 return 0;
1629 }
1630 return 0;
1631
1632 case UM_SETUP2:
1633 if (dcd) {
1634 AdjustCnrColsForPref(hwnd, NULL, &dcd->ds, FALSE);
1635 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1636 DIR_FILTER), &dcd->mask, FALSE);
1637 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1638 DIR_SORT), dcd->sortFlags, FALSE);
1639 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1640 DIR_VIEW), dcd->flWindowAttr);
1641 } else
1642 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1643 return 0;
1644
1645 case WM_MENUEND:
1646 if (dcd) {
1647
1648 HWND hwndMenu = (HWND) mp2;
1649
1650 if (hwndMenu == DirCnrMenu ||
1651 hwndMenu == FileMenu ||
1652 hwndMenu == DirMenu) {
1653 MarkAll(hwnd, TRUE, FALSE, TRUE);
1654 if (dcd->cnremphasized) {
1655 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1656 MPFROM2SHORT(FALSE, CRA_SOURCE));
1657 dcd->cnremphasized = FALSE;
1658 }
1659 }
1660 }
1661 break;
1662
1663 case UM_OPENWINDOWFORME:
1664 if (dcd) {
1665 if (mp1 && !IsFile((CHAR *)mp1)) {
1666 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
1667 }
1668 else if (mp1 && IsFile(mp1) == 1 &&
1669 CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2) {
1670 StartArcCnr(HWND_DESKTOP,
1671 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
1672 }
1673 }
1674 return 0;
1675
1676 case MM_PORTHOLEINIT:
1677 if (dcd) {
1678 switch (SHORT1FROMMP(mp1)) {
1679 case 0:
1680 case 1:
1681 {
1682 ULONG wmsg;
1683
1684 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1685 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
1686 wmsg, MPVOID, MPVOID), mp1, mp2);
1687 }
1688 break;
1689 }
1690 }
1691 break;
1692
1693 case UM_INITMENU:
1694 case WM_INITMENU:
1695 if (dcd) {
1696 switch (SHORT1FROMMP(mp1)) {
1697 case IDM_FILESMENU:
1698 CopyPresParams((HWND) mp2, hwndMainMenu);
1699 if (isalpha(*dcd->directory)) {
1700 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1701 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
1702 WinEnableMenuItem((HWND) mp2, IDM_RENAME, FALSE);
1703 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1704 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, FALSE);
1705 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, FALSE);
1706 WinEnableMenuItem((HWND) mp2, IDM_DELETE, FALSE);
1707 WinEnableMenuItem((HWND) mp2, IDM_EDIT, FALSE);
1708 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, FALSE);
1709 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, FALSE);
1710 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, FALSE);
1711 }
1712 else {
1713 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, TRUE);
1714 WinEnableMenuItem((HWND) mp2, IDM_RENAME, TRUE);
1715 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1716 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, TRUE);
1717 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, TRUE);
1718 WinEnableMenuItem((HWND) mp2, IDM_DELETE, TRUE);
1719 WinEnableMenuItem((HWND) mp2, IDM_EDIT, TRUE);
1720 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
1721 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
1722 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
1723 }
1724 }
1725 break;
1726
1727 case IDM_VIEWSMENU:
1728 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1729 CopyPresParams((HWND) mp2, hwndMainMenu);
1730 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1731 (dcd->lastselection != NULL));
1732 if (isalpha(*dcd->directory)) {
1733 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
1734 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1735 else
1736 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1737 }
1738 WinEnableMenuItem((HWND) mp2,
1739 IDM_SELECTCOMPAREMENU,
1740 (CountDirCnrs(dcd->hwndParent) > 1));
1741 break;
1742
1743 case IDM_DETAILSSETUP:
1744 SetDetailsSwitches((HWND) mp2, &dcd->ds);
1745 break;
1746
1747 case IDM_COMMANDSMENU:
1748 SetupCommandMenu((HWND) mp2, hwnd);
1749 break;
1750
1751 case IDM_SORTSUBMENU:
1752 SetSortChecks((HWND) mp2, dcd->sortFlags);
1753 break;
1754
1755 case IDM_WINDOWSMENU:
1756 SetupWinList((HWND) mp2,
1757 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
1758 break;
1759 }
1760 dcd->hwndLastMenu = (HWND) mp2;
1761 }
1762 if (msg == WM_INITMENU)
1763 break;
1764 return 0;
1765
1766 case UM_FILTER:
1767 if (dcd) {
1768
1769 PCNRITEM pci;
1770
1771 if (mp1) {
1772 //DosEnterCritSec(); // GKY 11-30-08 moved to SetMask
1773 SetMask((CHAR *)mp1, &dcd->mask);
1774 //DosExitCritSec();
1775 }
1776 dcd->suspendview = 1;
1777 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1778 dcd->suspendview = 0;
1779 if (fAutoView && hwndMain) {
1780 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1781 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1782 if (pci && (INT) pci != -1 &&
1783 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1784 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1785 else
1786 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1787 }
1788 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1789 }
1790 return 0;
1791
1792 case UM_COMMAND:
1793 if (mp1) {
1794 if (dcd) {
1795 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1796 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
1797 FreeListInfo((LISTINFO *) mp1);
1798 }
1799 else
1800 return (MRESULT) TRUE;
1801 }
1802 else
1803 FreeListInfo((LISTINFO *) mp1);
1804 }
1805 return 0;
1806
1807 case UM_NOTIFY:
1808 if (mp2)
1809 Notify((CHAR *)mp2);
1810 return 0;
1811
1812 case UM_DRIVECMD:
1813 if (mp1)
1814 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0), mp1);
1815 return 0;
1816
1817 case WM_COMMAND:
1818 DosError(FERR_DISABLEHARDERR);
1819 if (dcd) {
1820 switch (SHORT1FROMMP(mp1)) {
1821 case IDM_SETTARGET:
1822 SetTargetDir(hwnd, FALSE);
1823 break;
1824
1825 case IDM_CREATE:
1826 {
1827 STRINGINPARMS sip;
1828 CHAR filename[CCHMAXPATHCOMP];
1829
1830 memset(&sip, 0, sizeof(sip));
1831 sip.help = GetPString(IDS_CREATETEXT);
1832 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1833 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1834 strcpy(filename, "NEWFILE.TXT");
1835 sip.ret = filename;
1836 sip.title = GetPString(IDS_CREATETITLETEXT);
1837 if (WinDlgBox(HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle,
1838 STR_FRAME, &sip)) {
1839 bstrip(sip.ret);
1840 if (*sip.ret) {
1841 CHAR newfile[CCHMAXPATH];
1842 FILE *fp;
1843 INT test;
1844 PCNRITEM pci;
1845
1846 strcpy(newfile, dcd->directory);
1847 AddBackslashToPath(newfile);
1848 //if (newfile[strlen(newfile) - 1] != '\\')
1849 // strcat(newfile, "\\");
1850 strcat(newfile, sip.ret);
1851 test = IsFile(newfile);
1852 if (test != 1) {
1853 CHAR *modew = "w";
1854
1855 fp = xfopen(newfile, modew, pszSrcFile, __LINE__, TRUE);
1856 }
1857 if (test != 1 && !fp) {
1858 saymsg(MB_ENTER,
1859 hwnd,
1860 GetPString(IDS_ERRORTEXT),
1861 GetPString(IDS_CREATEERRORTEXT), newfile);
1862 }
1863 else {
1864 if (fp) {
1865 WinSendMsg(hwnd, UM_UPDATERECORD, MPFROMP(newfile), MPVOID);
1866 fclose(fp);
1867 }
1868 if (*editor) {
1869
1870 CHAR *dummy[2];
1871
1872 dummy[0] = newfile;
1873 dummy[1] = NULL;
1874 ExecOnList(hwnd,
1875 editor, WINDOWED | SEPARATE, NULL, NULL,
1876 dummy, NULL, pszSrcFile, __LINE__);
1877 }
1878 else
1879 StartMLEEditor(dcd->hwndParent, 4, newfile, dcd->hwndFrame);
1880 pci = FindCnrRecord(hwnd, newfile, NULL, TRUE, FALSE, TRUE);
1881 if (pci && (INT) pci != -1)
1882 /* make sure that record shows in viewport */
1883 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1884 }
1885 }
1886 }
1887 }
1888 break;
1889
1890 case IDM_CONTEXTMENU:
1891 {
1892 PCNRITEM pci;
1893
1894 pci = (PCNRITEM) CurrentRecord(hwnd);
1895 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
1896 MPFROMP(pci));
1897 }
1898 break;
1899
1900 case IDM_MAXIMIZE:
1901 PostMsg(hwndMain, UM_MAXIMIZE, MPFROMLONG(dcd->hwndFrame), MPVOID);
1902 break;
1903
1904 case IDM_SHOWALLFILESCNR:
1905 StartSeeAll(HWND_DESKTOP, FALSE, dcd->directory);
1906 break;
1907
1908 case IDM_SHOWALLFILES:
1909 {
1910 PCNRITEM pci;
1911
1912 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1913 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1914 if (pci && (INT) pci != -1) {
1915
1916 static CHAR dirname[CCHMAXPATH];
1917
1918 strcpy(dirname, pci->pszFileName);
1919 MakeValidDir(dirname);
1920 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1921 }
1922 }
1923 break;
1924
1925 case IDM_FINDINTREE:
1926 if (hwndTree) {
1927 PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__);
1928
1929 if (pszTempDir) {
1930 if (!PostMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir),
1931 MPFROMLONG(1L)))
1932 free(pszTempDir);
1933 }
1934 }
1935 break;
1936
1937 case IDM_BEGINEDIT:
1938 OpenEdit(hwnd);
1939 break;
1940
1941 case IDM_ENDEDIT:
1942 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1943 break;
1944
1945 case IDM_SHOWSELECT:
1946 QuickPopup(hwnd,
1947 dcd,
1948 CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP), IDM_SELECTSUBMENU);
1949 break;
1950
1951 case IDM_SHOWSORT:
1952 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP),
1953 IDM_SORTSUBMENU);
1954 break;
1955
1956 case IDM_VIEWORARC:
1957 {
1958 SWP swp;
1959 PCNRITEM pci;
1960
1961 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1962 MPFROMLONG(CMA_FIRST),
1963 MPFROMSHORT(CRA_CURSORED));
1964 if (pci && (INT) pci != -1) {
1965 WinQueryWindowPos(dcd->hwndFrame, &swp);
1966 DefaultViewKeys(hwnd,
1967 dcd->hwndFrame,
1968 dcd->hwndParent, &swp, pci->pszFileName);
1969 }
1970 }
1971 break;
1972
1973 case IDM_DIRCNRSETTINGS:
1974 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1975 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_DIRCNRSETTINGS), mp2);
1976 else {
1977 WinDlgBox(HWND_DESKTOP,
1978 hwnd,
1979 CfgDlgProc,
1980 FM3ModHandle,
1981 CFG_FRAME,
1982 MPFROMLONG(IDM_DIRCNRSETTINGS));
1983 }
1984 break;
1985
1986 case IDM_QTREE:
1987 case IDM_TREE:
1988 {
1989 CHAR newpath[CCHMAXPATH];
1990 APIRET rc;
1991 PCNRITEM pci;
1992
1993 if (SHORT1FROMMP(mp1) == IDM_TREE) {
1994 pci = (PCNRITEM) CurrentRecord(hwnd);
1995 if (pci && (INT) pci != -1)
1996 strcpy(newpath, pci->pszFileName);
1997 else
1998 strcpy(newpath, dcd->directory);
1999 }
2000 else
2001 strcpy(newpath, dcd->directory);
2002 MakeValidDir(newpath);
2003 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ObjCnrDlgProc,
2004 FM3ModHandle, QTREE_FRAME, MPFROMP(newpath));
2005 if (rc)
2006 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(newpath), MPVOID);
2007 }
2008 break;
2009
2010 case IDM_RESELECT:
2011 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
2012 break;
2013
2014 case IDM_HELP:
2015 if (hwndHelp) {
2016 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2017 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
2018 else
2019 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
2020 }
2021 break;
2022
2023 case IDM_WINDOWDLG:
2024 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
2025 PostMsg(dcd->hwndParent, UM_COMMAND,
2026 MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
2027 break;
2028
2029 case IDM_SORTSMARTNAME:
2030 case IDM_SORTNAME:
2031 case IDM_SORTFILENAME:
2032 case IDM_SORTSIZE:
2033 case IDM_SORTEASIZE:
2034 case IDM_SORTFIRST:
2035 case IDM_SORTLAST:
2036 case IDM_SORTLWDATE:
2037 case IDM_SORTLADATE:
2038 case IDM_SORTCRDATE:
2039 case IDM_SORTSUBJECT:
2040 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
2041 case IDM_SORTDIRSFIRST:
2042 case IDM_SORTDIRSLAST:
2043 case IDM_SORTREVERSE:
2044 switch (SHORT1FROMMP(mp1)) {
2045 case IDM_SORTSUBJECT:
2046 dcd->sortFlags |= SORT_SUBJECT;
2047 break;
2048 case IDM_SORTSMARTNAME:
2049 case IDM_SORTFILENAME:
2050 dcd->sortFlags |= SORT_FILENAME;
2051 break;
2052 case IDM_SORTSIZE:
2053 dcd->sortFlags |= SORT_SIZE;
2054 break;
2055 case IDM_SORTEASIZE:
2056 dcd->sortFlags |= SORT_EASIZE;
2057 break;
2058 case IDM_SORTFIRST:
2059 dcd->sortFlags |= SORT_FIRSTEXTENSION;
2060 break;
2061 case IDM_SORTLAST:
2062 dcd->sortFlags |= SORT_LASTEXTENSION;
2063 break;
2064 case IDM_SORTLWDATE:
2065 dcd->sortFlags |= SORT_LWDATE;
2066 break;
2067 case IDM_SORTLADATE:
2068 dcd->sortFlags |= SORT_LADATE;
2069 break;
2070 case IDM_SORTCRDATE:
2071 dcd->sortFlags |= SORT_CRDATE;
2072 break;
2073 case IDM_SORTDIRSFIRST:
2074 if (dcd->sortFlags & SORT_DIRSFIRST)
2075 dcd->sortFlags &= (~SORT_DIRSFIRST);
2076 else {
2077 dcd->sortFlags |= SORT_DIRSFIRST;
2078 dcd->sortFlags &= (~SORT_DIRSLAST);
2079 }
2080 break;
2081 case IDM_SORTDIRSLAST:
2082 if (dcd->sortFlags & SORT_DIRSLAST)
2083 dcd->sortFlags &= (~SORT_DIRSLAST);
2084 else {
2085 dcd->sortFlags |= SORT_DIRSLAST;
2086 dcd->sortFlags &= (~SORT_DIRSFIRST);
2087 }
2088 break;
2089 case IDM_SORTREVERSE:
2090 if (dcd->sortFlags & SORT_REVERSE)
2091 dcd->sortFlags &= (~SORT_REVERSE);
2092 else
2093 dcd->sortFlags |= SORT_REVERSE;
2094 break;
2095 }
2096 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
2097 MPFROMLONG(dcd->sortFlags));
2098 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2099 DIR_SORT), dcd->sortFlags, FALSE);
2100 break;
2101
2102 case IDM_COLLECT:
2103 case IDM_GREP:
2104 if (!Collector) {
2105
2106 HWND hwndC;
2107 SWP swp;
2108
2109 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2110 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2111 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2112 hwndC = StartCollector((fExternalCollector ||
2113 strcmp(realappname, FM3Str)) ?
2114 HWND_DESKTOP : dcd->hwndParent, 4);
2115 if (hwndC) {
2116 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2117 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2118 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2119 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2120 SWP_SHOW | SWP_ZORDER);
2121 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) && fAutoTile &&
2122 !strcmp(realappname, FM3Str))
2123 TileChildren(dcd->hwndParent, TRUE);
2124 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
2125 DosSleep(100); //05 Aug 07 GKY 250
2126 }
2127 }
2128 else
2129 StartCollector(dcd->hwndParent, 4);
2130 if (SHORT1FROMMP(mp1) == IDM_GREP) {
2131 PCNRITEM pci = NULL;
2132
2133 pci = WinSendMsg(hwnd,
2134 CM_QUERYRECORDEMPHASIS,
2135 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
2136 if (pci && (INT) pci != -1)
2137 PostMsg(Collector, WM_COMMAND,
2138 MPFROM2SHORT(IDM_GREP, 0), MPFROMP(pci->pszFileName));
2139 else
2140 PostMsg(Collector, WM_COMMAND,
2141 MPFROM2SHORT(IDM_GREP, 0), MPVOID);
2142 }
2143 else
2144 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2145 break;
2146
2147 case IDM_COLLECTOR:
2148 DosSleep(32); //05 Aug 07 GKY 64
2149 {
2150 CHAR **list;
2151
2152 list = BuildList(hwnd);
2153 if (list) {
2154 if (Collector) {
2155 if (!PostMsg(Collector,
2156 WM_COMMAND,
2157 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2158 FreeList(list);
2159 else if (fUnHilite)
2160 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2161 }
2162 else
2163 FreeList(list);
2164 }
2165 }
2166 break;
2167
2168 case IDM_UNDELETE:
2169 {
2170 PCNRITEM pci;
2171 CHAR path[CCHMAXPATH];
2172 HOBJECT hObject;
2173 HWND hwndDesktop;
2174
2175 hObject = WinQueryObject("<XWP_TRASHCAN>");
2176 if (hObject != NULLHANDLE && fTrashCan) {
2177 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2178 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2179 WinOpenObject(hObject, 0, TRUE);
2180 }
2181 else {
2182 pci = (PCNRITEM) CurrentRecord(hwnd);
2183 if (pci && (INT) pci != -1) {
2184 strcpy(path, pci->pszFileName);
2185 MakeValidDir(path);
2186 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2187 UNDEL_FRAME, MPFROMP(path));
2188 }
2189 }
2190 }
2191 break;
2192
2193 case IDM_UNDELETESPEC:
2194 {
2195 HOBJECT hObject;
2196 HWND hwndDesktop;
2197
2198 hObject = WinQueryObject("<XWP_TRASHCAN>");
2199 if (hObject != NULLHANDLE && fTrashCan) {
2200 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
2201 WinSetFocus(HWND_DESKTOP, hwndDesktop);
2202 WinOpenObject(hObject, 0, TRUE);
2203 }
2204 else
2205 WinDlgBox(HWND_DESKTOP,
2206 hwnd,
2207 UndeleteDlgProc,
2208 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2209 }
2210 break;
2211
2212 case IDM_RESORT:
2213// WinSendMsg(hwnd,
2214// CM_SORTRECORD,
2215// MPFROMP(SortDirCnr),
2216// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
2217 WinSendMsg(hwnd,
2218 CM_SORTRECORD,
2219 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2220 break;
2221
2222 case IDM_FILTER:
2223 {
2224 BOOL empty = FALSE;
2225 PCNRITEM pci;
2226 CHAR *p;
2227
2228 if (!*dcd->mask.szMask) {
2229 empty = TRUE;
2230 pci = (PCNRITEM) CurrentRecord(hwnd);
2231 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
2232 p = strrchr(pci->pszFileName, '\\');
2233 if (p) {
2234 p++;
2235 strcpy(dcd->mask.szMask, p);
2236 }
2237 }
2238 }
2239 *(dcd->mask.prompt) = 0;
2240
2241 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2242 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2243 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2244 else if (empty)
2245 *dcd->mask.szMask = 0;
2246 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2247 DIR_FILTER), &dcd->mask, FALSE);
2248 }
2249 break;
2250
2251 case IDM_UNHIDEALL:
2252 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2253 break;
2254
2255 case IDM_HIDEALL:
2256 if (fAutoView && hwndMain)
2257 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2258 dcd->suspendview = 1;
2259 HideAll(hwnd);
2260 dcd->suspendview = 0;
2261 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2262 break;
2263
2264 case IDM_SELECTBOTH:
2265 case IDM_SELECTONE:
2266 case IDM_SELECTMORE:
2267 case IDM_SELECTNEWER:
2268 case IDM_SELECTOLDER:
2269 case IDM_SELECTBIGGER:
2270 case IDM_SELECTSMALLER:
2271 case IDM_DESELECTBOTH:
2272 case IDM_DESELECTONE:
2273 case IDM_DESELECTMORE:
2274 case IDM_DESELECTNEWER:
2275 case IDM_DESELECTOLDER:
2276 case IDM_DESELECTBIGGER:
2277 case IDM_DESELECTSMALLER:
2278 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2279 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2280 break;
2281 }
2282 case IDM_SELECTLIST:
2283 case IDM_SELECTALL:
2284 case IDM_DESELECTALL:
2285 case IDM_SELECTALLFILES:
2286 case IDM_DESELECTALLFILES:
2287 case IDM_SELECTALLDIRS:
2288 case IDM_DESELECTALLDIRS:
2289 case IDM_SELECTMASK:
2290 case IDM_DESELECTMASK:
2291 case IDM_INVERT:
2292 case IDM_SELECTCLIP:
2293 case IDM_DESELECTCLIP:
2294 {
2295 PCNRITEM pci;
2296
2297 pci = (PCNRITEM) CurrentRecord(hwnd);
2298 if ((INT) pci == -1)
2299 pci = NULL;
2300 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2301 if (pci) {
2302 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2303 pci->rc.flRecordAttr |= CRA_FILTERED;
2304 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2305 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2306 break;
2307 }
2308 }
2309 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2310 }
2311 break;
2312
2313 case IDM_RESCAN:
2314 //DosEnterCritSec(); //GKY 11-27-08
2315 dcd->stopflag++;
2316 //DosExitCritSec();
2317 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2318 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2319 //DosEnterCritSec(); //GKY 11-27-08
2320 dcd->stopflag--;
2321 //DosExitCritSec();
2322 }
2323 break;
2324
2325 case IDM_SHOWLNAMES:
2326 case IDM_SHOWSUBJECT:
2327 case IDM_SHOWEAS:
2328 case IDM_SHOWSIZE:
2329 case IDM_SHOWICON:
2330 case IDM_SHOWLWDATE:
2331 case IDM_SHOWLWTIME:
2332 case IDM_SHOWLADATE:
2333 case IDM_SHOWLATIME:
2334 case IDM_SHOWCRDATE:
2335 case IDM_SHOWCRTIME:
2336 case IDM_SHOWATTR:
2337 AdjustDetailsSwitches(hwnd,
2338 dcd->hwndLastMenu,
2339 SHORT1FROMMP(mp1),
2340 dcd->directory, NULL, &dcd->ds, FALSE);
2341 break;
2342
2343 case IDM_TREEVIEW:
2344 case IDM_ICON:
2345 case IDM_TEXT:
2346 case IDM_DETAILS:
2347 case IDM_NAME:
2348 case IDM_MINIICONS:
2349 case IDM_DETAILSTITLES:
2350 {
2351 CNRINFO cnri;
2352
2353 memset(&cnri, 0, sizeof(CNRINFO));
2354 cnri.cb = sizeof(CNRINFO);
2355 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2356 MPFROMLONG(sizeof(CNRINFO)));
2357 switch (SHORT1FROMMP(mp1)) {
2358 case IDM_TREEVIEW:
2359 if (!(cnri.flWindowAttr & CV_TREE))
2360 dcd->lastattr = cnri.flWindowAttr;
2361 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2362 CV_DETAIL | CV_NAME | CA_TREELINE));
2363 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2364 if (!dcd->firsttree)
2365 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2366 break;
2367 case IDM_ICON:
2368 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2369 CV_DETAIL | CV_NAME | CA_TREELINE));
2370 cnri.flWindowAttr |= CV_ICON;
2371 break;
2372 case IDM_NAME:
2373 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2374 CV_DETAIL | CV_NAME | CA_TREELINE));
2375 cnri.flWindowAttr |= CV_NAME;
2376 break;
2377 case IDM_TEXT:
2378 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2379 CV_DETAIL | CV_NAME | CA_TREELINE));
2380 cnri.flWindowAttr |= CV_TEXT;
2381 break;
2382 case IDM_DETAILS:
2383 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2384 CV_DETAIL | CV_NAME | CA_TREELINE));
2385 cnri.flWindowAttr |= CV_DETAIL;
2386 break;
2387 case IDM_MINIICONS:
2388 if (cnri.flWindowAttr & CV_MINI)
2389 cnri.flWindowAttr &= (~CV_MINI);
2390 else
2391 cnri.flWindowAttr |= CV_MINI;
2392 break;
2393 case IDM_DETAILSTITLES:
2394 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2395 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2396 else
2397 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2398 break;
2399 }
2400 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2401 cnri.flWindowAttr |= CV_FLOW;
2402 dcd->flWindowAttr = cnri.flWindowAttr;
2403 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2404 MPFROMLONG(CMA_FLWINDOWATTR));
2405 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2406 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2407 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2408 DIR_VIEW), dcd->flWindowAttr);
2409 }
2410 break;
2411
2412 case IDM_SAVETOLIST:
2413 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2414 SAV_FRAME, MPFROMP(&hwnd));
2415 break;
2416
2417 case IDM_SIZES:
2418 {
2419 PCNRITEM pci;
2420 CHAR path[CCHMAXPATH];
2421
2422 pci = (PCNRITEM) CurrentRecord(hwnd);
2423 if (pci && (INT) pci != -1)
2424 strcpy(path, pci->pszFileName);
2425 else
2426 strcpy(path, dcd->directory);
2427 MakeValidDir(path);
2428 WinDlgBox(HWND_DESKTOP,
2429 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2430 }
2431 break;
2432
2433 case IDM_MKDIR:
2434 {
2435 PCNRITEM pci;
2436 BOOL saved;
2437
2438 saved = fSelectedAlways;
2439 fSelectedAlways = FALSE;
2440 pci = (PCNRITEM)CurrentRecord(hwnd);
2441 // 01 Oct 07 SHL Make below selected directory or in current directory
2442 PMMkDir(dcd->hwndParent,
2443 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2444 FALSE);
2445 fSelectedAlways = saved;
2446 }
2447 break;
2448
2449 case IDM_SWITCH:
2450 if (mp2) {
2451 strcpy(dcd->previous, dcd->directory);
2452 strcpy(dcd->directory, (CHAR *)mp2);
2453 //DosEnterCritSec(); // GKY 11-27-08
2454 dcd->stopflag++;
2455 //DosExitCritSec();
2456 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2457 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2458 strcpy(dcd->directory, dcd->previous);
2459 //DosEnterCritSec(); // GKY 11-27-08
2460 dcd->stopflag--;
2461 //DosExitCritSec();
2462 }
2463 else if (*dcd->directory) {
2464 if (hwndMain)
2465 WinSendMsg(hwndMain,
2466 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2467 else
2468 add_udir(FALSE, dcd->directory);
2469 }
2470 }
2471 break;
2472
2473 case IDM_PARENT:
2474 {
2475 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
2476
2477 strcpy(tempname1, dcd->directory);
2478 AddBackslashToPath(tempname1);
2479 strcat(tempname1, "..");
2480 DosError(FERR_DISABLEHARDERR);
2481 if (!DosQueryPathInfo(tempname1,
2482 FIL_QUERYFULLNAME,
2483 tempname2, sizeof(tempname2))) {
2484 if (stricmp(dcd->directory, tempname2)) {
2485 strcpy(dcd->previous, dcd->directory);
2486 strcpy(dcd->directory, tempname2);
2487 dcd->stopflag++;
2488 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2489 if (!PostMsg(dcd->hwndObject,
2490 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2491 strcpy(dcd->directory, dcd->previous);
2492 dcd->stopflag--;
2493 }
2494 else if (*dcd->directory) {
2495 if (hwndMain)
2496 WinSendMsg(hwndMain,
2497 UM_SETUSERLISTNAME,
2498 MPFROMP(dcd->directory), MPVOID);
2499 else
2500 add_udir(FALSE, dcd->directory);
2501 }
2502 }
2503 }
2504 }
2505 break;
2506
2507 case IDM_PREVIOUS:
2508 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
2509
2510 CHAR tempname[CCHMAXPATH];
2511
2512 if (IsValidDir(dcd->previous)) {
2513 strcpy(tempname, dcd->directory);
2514 strcpy(dcd->directory, dcd->previous);
2515 strcpy(dcd->previous, tempname);
2516 dcd->stopflag++; ;
2517 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2518 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2519 strcpy(dcd->directory, dcd->previous);
2520 dcd->stopflag--;
2521 }
2522 else if (*dcd->directory) {
2523 if (hwndMain)
2524 WinSendMsg(hwndMain,
2525 UM_SETUSERLISTNAME,
2526 MPFROMP(dcd->directory), MPVOID);
2527 else
2528 add_udir(FALSE, dcd->directory);
2529 }
2530 }
2531 else
2532 *dcd->previous = 0;
2533 }
2534 break;
2535
2536 case IDM_WALKDIR:
2537 {
2538 CHAR newdir[CCHMAXPATH];
2539
2540 strcpy(newdir, dcd->directory);
2541 if (!WinDlgBox(HWND_DESKTOP,
2542 dcd->hwndParent,
2543 WalkAllDlgProc,
2544 FM3ModHandle,
2545 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2546 break;
2547 if (stricmp(newdir, dcd->directory)) {
2548 strcpy(dcd->previous, dcd->directory);
2549 strcpy(dcd->directory, newdir);
2550 dcd->stopflag++;
2551 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2552 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2553 strcpy(dcd->directory, dcd->previous);
2554 dcd->stopflag--;
2555 }
2556 else if (*dcd->directory) {
2557 if (hwndMain)
2558 WinSendMsg(hwndMain,
2559 UM_SETUSERLISTNAME,
2560 MPFROMP(dcd->directory), MPVOID);
2561 else
2562 add_udir(FALSE, dcd->directory);
2563 }
2564 }
2565 }
2566 break;
2567
2568 case IDM_OPENICONME:
2569 OpenObject(dcd->directory, PCSZ_ICON, dcd->hwndFrame);
2570 break;
2571 case IDM_OPENDETAILSME:
2572 OpenObject(dcd->directory, Details, dcd->hwndFrame);
2573 break;
2574 case IDM_OPENTREEME:
2575 OpenObject(dcd->directory, PCSZ_TREE, dcd->hwndFrame);
2576 break;
2577 case IDM_OPENSETTINGSME:
2578 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2579 break;
2580
2581 case IDM_DOITYOURSELF:
2582 case IDM_UPDATE:
2583 case IDM_OPENWINDOW:
2584 case IDM_OPENSETTINGS:
2585 case IDM_OPENDEFAULT:
2586 case IDM_OPENICON:
2587 case IDM_OPENDETAILS:
2588 case IDM_OPENTREE:
2589 case IDM_OBJECT:
2590 case IDM_SHADOW:
2591 case IDM_SHADOW2:
2592 case IDM_DELETE:
2593 case IDM_PERMDELETE:
2594 case IDM_PRINT:
2595 case IDM_ATTRS:
2596 case IDM_INFO:
2597 case IDM_COPY:
2598 case IDM_MOVE:
2599 case IDM_WPSMOVE:
2600 case IDM_WPSCOPY:
2601 case IDM_WILDCOPY:
2602 case IDM_WILDMOVE:
2603 case IDM_RENAME:
2604 case IDM_COMPARE:
2605 case IDM_EAS:
2606 case IDM_SUBJECT:
2607 case IDM_VIEW:
2608 case IDM_VIEWTEXT:
2609 case IDM_VIEWBINARY:
2610 case IDM_VIEWARCHIVE:
2611 case IDM_EDIT:
2612 case IDM_EDITTEXT:
2613 case IDM_EDITBINARY:
2614 case IDM_SAVETOCLIP:
2615 case IDM_SAVETOCLIPFILENAME:
2616 case IDM_APPENDTOCLIP:
2617 case IDM_APPENDTOCLIPFILENAME:
2618 case IDM_ARCHIVE:
2619 case IDM_ARCHIVEM:
2620 case IDM_EXTRACT:
2621 case IDM_MCIPLAY:
2622 case IDM_COLLECTFROMFILE:
2623 case IDM_UUDECODE:
2624 case IDM_MERGE:
2625 {
2626 LISTINFO *li;
2627 ULONG action = UM_ACTION;
2628 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2629 if (li) {
2630 li->type = SHORT1FROMMP(mp1);
2631 li->hwnd = hwnd;
2632 li->list = BuildList(hwnd);
2633 switch (SHORT1FROMMP(mp1)) {
2634 case IDM_WILDMOVE:
2635 case IDM_WILDCOPY:
2636 case IDM_MOVE:
2637 case IDM_COPY:
2638 case IDM_WPSMOVE:
2639 case IDM_WPSCOPY:
2640 break;
2641 default:
2642 strcpy(li->targetpath, dcd->directory);
2643 break;
2644 }
2645 if (li->list) {
2646 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2647 if (!Collector) {
2648
2649 HWND hwndC;
2650 SWP swp;
2651
2652 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2653 !fAutoTile &&
2654 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2655 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2656 hwndC = StartCollector((fExternalCollector ||
2657 strcmp(realappname, FM3Str)) ?
2658 HWND_DESKTOP : dcd->hwndParent, 4);
2659 if (hwndC) {
2660 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2661 !fAutoTile && (!fExternalCollector &&
2662 !strcmp(realappname, FM3Str)))
2663 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2664 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2665 SWP_SHOW | SWP_ZORDER);
2666 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2667 fAutoTile && !strcmp(realappname, FM3Str))
2668 TileChildren(dcd->hwndParent, TRUE);
2669 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2670 SWP_ACTIVATE);
2671 DosSleep(100); //05 Aug 07 GKY 250
2672 }
2673 }
2674 else
2675 StartCollector(dcd->hwndParent, 4);
2676 }
2677 switch (SHORT1FROMMP(mp1)) {
2678 case IDM_APPENDTOCLIP:
2679 case IDM_APPENDTOCLIPFILENAME:
2680 case IDM_SAVETOCLIP:
2681 case IDM_SAVETOCLIPFILENAME:
2682 case IDM_ARCHIVE:
2683 case IDM_ARCHIVEM:
2684 case IDM_DELETE:
2685 case IDM_PERMDELETE:
2686 case IDM_ATTRS:
2687 case IDM_PRINT:
2688 case IDM_SHADOW:
2689 case IDM_SHADOW2:
2690 case IDM_OBJECT:
2691 case IDM_VIEW:
2692 case IDM_VIEWTEXT:
2693 case IDM_VIEWBINARY:
2694 case IDM_EDIT:
2695 case IDM_EDITTEXT:
2696 case IDM_EDITBINARY:
2697 case IDM_MCIPLAY:
2698 case IDM_UPDATE:
2699 case IDM_DOITYOURSELF:
2700 case IDM_INFO:
2701 case IDM_EAS:
2702 action = UM_MASSACTION;
2703 break;
2704 }
2705 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2706 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2707 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2708 *li->targetpath = 0;
2709 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2710 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2711 FreeListInfo(li);
2712 }
2713 else if (fUnHilite)
2714 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2715 }
2716 else
2717 free(li);
2718 }
2719 }
2720 break;
2721
2722 case IDM_DRIVESMENU:
2723 if (!hwndMain)
2724 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2725 break;
2726
2727 default:
2728 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2729 return 0;
2730 else {
2731 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2732 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2733
2734 register INT x;
2735
2736 if (!cmdloaded)
2737 load_commands();
2738 x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
2739 if (x >= 0) {
2740 //x++;
2741 RunCommand(hwnd, x);
2742 if (fUnHilite)
2743 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2744 }
2745 }
2746 }
2747 break;
2748 }
2749 }
2750 return 0;
2751
2752 case UM_FIXCNRMLE:
2753 case UM_FIXEDITNAME:
2754 return CommonCnrProc(hwnd, msg, mp1, mp2);
2755
2756 case UM_FILESMENU:
2757 {
2758 PCNRITEM pci;
2759 HWND menuHwnd = (HWND) 0;
2760
2761 pci = (PCNRITEM) CurrentRecord(hwnd);
2762 if (pci && (INT) pci != -1) {
2763 if (pci->attrFile & FILE_DIRECTORY) {
2764 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2765// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2766 }
2767 else
2768 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2769 }
2770 return MRFROMLONG(menuHwnd);
2771 }
2772
2773 case WM_CONTROL:
2774 DosError(FERR_DISABLEHARDERR);
2775 if (dcd) {
2776 switch (SHORT2FROMMP(mp1)) {
2777 case CN_COLLAPSETREE:
2778 case CN_EXPANDTREE:
2779 {
2780 PCNRITEM pci = (PCNRITEM) mp2;
2781
2782 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2783 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2784 struct
2785 {
2786 ULONG serial;
2787 CHAR volumelength;
2788 CHAR volumelabel[CCHMAXPATH];
2789 }
2790 volser;
2791 APIRET rc;
2792
2793 memset(&volser, 0, sizeof(volser));
2794 DosError(FERR_DISABLEHARDERR);
2795 // fixme?
2796 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2797 FSIL_VOLSER, &volser, sizeof(volser));
2798 if (rc) {
2799 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2800 GetPString(IDS_CANTFINDDIRTEXT),
2801 pci->pszFileName);
2802 if (!fErrorBeepOff)
2803 DosBeep(250,100);
2804 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2805 UnFlesh(hwnd, pci);
2806 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2807 }
2808 else {
2809 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2810 !volser.serial ||
2811 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2812 volser.serial)
2813 UnFlesh(hwnd, pci);
2814 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2815 (!volser.serial ||
2816 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2817 volser.serial)) {
2818 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && Flesh(hwnd, pci) &&
2819 !dcd->suspendview && fTopDir ) {
2820 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2821 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
2822 }
2823 }
2824 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2825 }
2826 }
2827 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2828 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir) {
2829 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2830 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
2831 }
2832 }
2833 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview) {
2834 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2835 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
2836 }
2837 }
2838 }
2839 break;
2840
2841/*
2842 case CN_PICKUP:
2843 return PickUp(hwnd,dcd->hwndObject,mp2);
2844*/
2845
2846 case CN_CONTEXTMENU:
2847 {
2848 PCNRITEM pci = (PCNRITEM) mp2;
2849
2850 if (pci) {
2851 WinSendMsg(hwnd,
2852 CM_SETRECORDEMPHASIS,
2853 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2854 MarkAll(hwnd, FALSE, FALSE, TRUE);
2855 if (pci->attrFile & FILE_DIRECTORY)
2856 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2857 else
2858 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2859 }
2860 else {
2861 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2862 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2863 WinSendMsg(hwnd,
2864 CM_SETRECORDEMPHASIS,
2865 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2866 dcd->cnremphasized = TRUE;
2867 }
2868 }
2869 if (dcd->hwndLastMenu) {
2870 if (dcd->hwndLastMenu == DirCnrMenu) {
2871 if (dcd->flWindowAttr & CV_MINI)
2872 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2873 }
2874 if (dcd->hwndLastMenu == DirMenu)
2875 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2876 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2877 if (dcd->cnremphasized) {
2878 WinSendMsg(hwnd,
2879 CM_SETRECORDEMPHASIS,
2880 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2881 dcd->cnremphasized = TRUE;
2882 }
2883 MarkAll(hwnd, TRUE, FALSE, TRUE);
2884 }
2885 }
2886 }
2887 break;
2888
2889 case CN_DROPHELP:
2890 if (mp2) {
2891
2892 PDRAGINFO pDInfo;
2893 PCNRITEM pci;
2894 ULONG numitems;
2895 USHORT usOperation;
2896
2897 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2898 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2899 if (!DrgAccessDraginfo(pDInfo)) {
2900 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2901 GetPString(IDS_DROPERRORTEXT));
2902 }
2903 else {
2904 numitems = DrgQueryDragitemCount(pDInfo);
2905 usOperation = pDInfo->usOperation;
2906 if (usOperation == DO_DEFAULT)
2907 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
2908 FreeDragInfoData(hwnd, pDInfo);
2909 saymsg(MB_ENTER | MB_ICONASTERISK,
2910 hwnd,
2911 GetPString(IDS_DROPHELPHDRTEXT),
2912 GetPString(IDS_DROPHELPTEXT),
2913 numitems,
2914 &"s"[numitems == 1L],
2915 pci ? NullStr : GetPString(IDS_NOTEXT),
2916 pci ? NullStr : " ",
2917 pci ? pci->pszFileName : NullStr,
2918 pci ? " " : NullStr,
2919 GetPString((usOperation == DO_MOVE) ?
2920 IDS_MOVETEXT :
2921 (usOperation == DO_LINK) ?
2922 IDS_LINKTEXT : IDS_COPYTEXT));
2923 }
2924 }
2925 return 0;
2926
2927 case CN_DRAGLEAVE:
2928 return 0;
2929
2930 case CN_DRAGAFTER:
2931 case CN_DRAGOVER:
2932 if (mp2) {
2933
2934 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2935 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2936 PCNRITEM pci;
2937 USHORT uso;
2938
2939 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2940 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2941 if (!DrgAccessDraginfo(pDInfo)) {
2942 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2943 PCSZ_DRGACCESSDRAGINFO);
2944 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2945 }
2946 if (*dcd->directory &&
2947 (driveflags[toupper(*dcd->directory) - 'A'] &
2948 DRIVE_NOTWRITEABLE)) {
2949 DrgFreeDraginfo(pDInfo);
2950 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
2951 DO_LINK); /* (compare) only */
2952 }
2953 if (pci) {
2954 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2955 DrgFreeDraginfo(pDInfo);
2956 return (MRFROM2SHORT(DOR_NODROP, 0));
2957 }
2958 uso = pDInfo->usOperation;
2959 if (uso == DO_DEFAULT)
2960 uso = fCopyDefault ? DO_COPY : DO_MOVE;
2961 if (!(pci->attrFile & FILE_DIRECTORY)) {
2962 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2963 DrgFreeDraginfo(pDInfo);
2964 return MRFROM2SHORT(DOR_NODROP, 0);
2965 }
2966 if (uso != DO_LINK &&
2967 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2968 DRIVE_NOTWRITEABLE)) {
2969
2970 ARC_TYPE *info = NULL;
2971
2972 if (!fQuickArcFind &&
2973 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2974 DRIVE_SLOW))
2975 info = find_type(pci->pszFileName, NULL);
2976 else
2977 info = quick_find_type(pci->pszFileName, NULL);
2978 if (!info || ((uso == DO_MOVE && !info->move) ||
2979 (uso == DO_COPY && !info->create))) {
2980 DrgFreeDraginfo(pDInfo);
2981 return MRFROM2SHORT(DOR_NODROP, 0);
2982 }
2983 }
2984 }
2985 }
2986
2987 /* Access DRAGITEM index to DRAGITEM
2988 * Check valid rendering mechanisms and data
2989 */
2990 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2991 if (DrgVerifyRMF(pDItem, (CHAR *) DRM_OS2FILE, NULL) ||
2992 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
2993 DrgVerifyRMF(pDItem, (CHAR *) DRM_FM2ARCMEMBER, (CHAR *) DRF_FM2ARCHIVE))) {
2994 DrgFreeDraginfo(pDInfo);
2995 if (driveflags[toupper(*dcd->directory) - 'A'] &
2996 DRIVE_NOTWRITEABLE)
2997 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2998 if (toupper(*dcd->directory) < 'C')
2999 return MRFROM2SHORT(DOR_DROP, DO_COPY);
3000 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
3001 ((fCopyDefault) ? DO_COPY : DO_MOVE));
3002 }
3003 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
3004 }
3005 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
3006
3007 case CN_INITDRAG:
3008 {
3009 BOOL wasemphasized = FALSE;
3010 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
3011 PCNRITEM pci;
3012
3013 if (pcd) {
3014 pci = (PCNRITEM) pcd->pRecord;
3015 if (pci) {
3016 if ((INT) pci == -1)
3017 pci = NULL;
3018 else if (pci->rc.flRecordAttr & CRA_SELECTED)
3019 wasemphasized = TRUE;
3020 }
3021 else if (!*dcd->directory) {
3022 Runtime_Error(pszSrcFile, __LINE__, NULL);
3023 break;
3024 }
3025 else if (IsRoot(dcd->directory)) {
3026 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
3027 GetPString(IDS_CANTDRAGROOTDIR));
3028 break;
3029 }
3030 if (hwndStatus2) {
3031 if (pci)
3032 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_DRAGFILEOBJTEXT));
3033 else
3034 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_DRAGDIRTEXT));
3035 }
3036 if (DoFileDrag(hwnd,
3037 dcd->hwndObject,
3038 mp2,
3039 NULL,
3040 pci ? NULL : dcd->directory,
3041 pci ? TRUE : FALSE)) {
3042 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
3043 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
3044 }
3045 }
3046 if (hwndStatus2) {
3047 WinSetFocus(HWND_DESKTOP, hwnd);
3048 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3049 }
3050 }
3051 }
3052 return 0;
3053
3054 case CN_DROP:
3055 if (mp2) {
3056
3057 LISTINFO *li;
3058 ULONG action = UM_ACTION;
3059
3060 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
3061 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
3062 if (li) {
3063 if (li->list && li->list[0] && IsRoot(li->list[0]))
3064 li->type = DO_LINK;
3065 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
3066
3067 CHECKLIST cl;
3068
3069 memset(&cl, 0, sizeof(cl));
3070 cl.size = sizeof(cl);
3071 cl.flags = li->type;
3072 cl.list = li->list;
3073 cl.cmd = li->type;
3074 cl.prompt = li->targetpath;
3075 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
3076 DropListProc, FM3ModHandle,
3077 DND_FRAME, MPFROMP(&cl));
3078 if (li->type == DID_ERROR)
3079 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
3080 GetPString(IDS_DRAGDROPDIALOGTEXT));
3081 if (!li->type) {
3082 FreeListInfo(li);
3083 return 0;
3084 }
3085 li->list = cl.list;
3086 if (!li->list || !li->list[0]) {
3087 FreeListInfo(li);
3088 return 0;
3089 }
3090 }
3091 switch (li->type) {
3092 case DND_LAUNCH:
3093 strcat(li->targetpath, " %a");
3094 ExecOnList(dcd->hwndParent, li->targetpath,
3095 PROMPT | WINDOWED, NULL, NULL, li->list, NULL,
3096 pszSrcFile, __LINE__);
3097 FreeList(li->list);
3098 li->list = NULL;
3099 break;
3100 case DO_LINK:
3101 if (fLinkSetsIcon) {
3102 li->type = IDM_SETICON;
3103 action = UM_MASSACTION;
3104 }
3105 else
3106 li->type = IDM_COMPARE;
3107 break;
3108 case DND_EXTRACT:
3109 if (*li->targetpath && !IsFile(li->targetpath))
3110 li->type = IDM_EXTRACT;
3111 break;
3112 case DND_MOVE:
3113 li->type = IDM_MOVE;
3114 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3115 action = UM_MASSACTION;
3116 li->type = IDM_ARCHIVEM;
3117 }
3118 break;
3119 case DND_WILDMOVE:
3120 li->type = IDM_WILDMOVE;
3121 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3122 action = UM_MASSACTION;
3123 li->type = IDM_ARCHIVEM;
3124 }
3125 break;
3126 case DND_OBJECT:
3127 li->type = IDM_OBJECT;
3128 action = UM_MASSACTION;
3129 break;
3130 case DND_SHADOW:
3131 li->type = IDM_SHADOW;
3132 action = UM_MASSACTION;
3133 break;
3134 case DND_COMPARE:
3135 li->type = IDM_COMPARE;
3136 break;
3137 case DND_SETICON:
3138 action = UM_MASSACTION;
3139 li->type = IDM_SETICON;
3140 break;
3141 case DND_COPY:
3142 li->type = IDM_COPY;
3143 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3144 action = UM_MASSACTION;
3145 li->type = IDM_ARCHIVE;
3146 }
3147 break;
3148 case DND_WILDCOPY:
3149 li->type = IDM_WILDCOPY;
3150 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3151 action = UM_MASSACTION;
3152 li->type = IDM_ARCHIVE;
3153 }
3154 break;
3155 default:
3156 if (*li->arcname && li->info) {
3157 action = UM_MASSACTION;
3158 li->type =
3159 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3160 }
3161 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
3162 action = UM_MASSACTION;
3163 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3164 }
3165 else
3166 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3167 break;
3168 }
3169 if (!li->list || !li->list[0])
3170 FreeListInfo(li);
3171 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
3172 FreeListInfo(li);
3173 else {
3174
3175 USHORT usop = 0;
3176
3177 switch (li->type) {
3178 case IDM_COPY:
3179 case IDM_WILDCOPY:
3180 usop = DO_COPY;
3181 break;
3182 case IDM_MOVE:
3183 case IDM_WILDMOVE:
3184 case IDM_ARCHIVEM:
3185 usop = DO_MOVE;
3186 break;
3187 }
3188 if (usop)
3189 return MRFROM2SHORT(DOR_DROP, usop);
3190 }
3191 }
3192 }
3193 return 0;
3194
3195 case CN_ENDEDIT:
3196 case CN_BEGINEDIT:
3197 {
3198 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3199 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3200
3201 if (pfi || pci) {
3202
3203 MRESULT mre;
3204
3205 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3206 if (mre != (MRESULT) - 1)
3207 return mre;
3208 }
3209 else if (!pfi && !pci)
3210 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3211 }
3212 return 0;
3213
3214 case CN_REALLOCPSZ:
3215 {
3216 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3217 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3218 HWND hwndMLE;
3219 CHAR testname[CCHMAXPATH];
3220
3221 if (!pci && !pfi) {
3222 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3223 WinQueryWindowText(hwndMLE, sizeof(s), s);
3224 chop_at_crnl(s);
3225 bstrip(s);
3226 if (*s) {
3227 if (!DosQueryPathInfo(s,
3228 FIL_QUERYFULLNAME,
3229 testname, sizeof(testname))) {
3230 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3231 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3232 }
3233 }
3234 }
3235 }
3236 else {
3237
3238 MRESULT mre;
3239
3240 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3241 if (mre != (MRESULT) - 1)
3242 return mre;
3243 }
3244 }
3245 return 0;
3246
3247 case CN_EMPHASIS:
3248 if (!mp2)
3249 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3250 else {
3251 PNOTIFYRECORDEMPHASIS pre = mp2;
3252 PCNRITEM pci;
3253 CHAR s[CCHMAXPATHCOMP + 91];
3254
3255 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3256 if (!pci) {
3257 if (hwndStatus2)
3258 WinSetWindowText(hwndStatus2, NullStr);
3259 if (fMoreButtons) {
3260 WinSetWindowText(hwndName, NullStr);
3261 WinSetWindowText(hwndDate, NullStr);
3262 WinSetWindowText(hwndAttr, NullStr);
3263 }
3264 if (hwndMain)
3265 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3266 break;
3267 }
3268 if (pre->fEmphasisMask & CRA_SELECTED) {
3269 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3270 dcd->selectedbytes += (pci->cbFile + pci->easize);
3271 dcd->selectedfiles++;
3272 }
3273 else if (dcd->selectedfiles) {
3274 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3275 dcd->selectedfiles--;
3276 }
3277 if (!dcd->suspendview) {
3278 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3279 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3280 sprintf(s, "%s / %s", tf, tb);
3281 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3282 }
3283 }
3284 if (!dcd->suspendview && hwndMain &&
3285 (pre->fEmphasisMask & CRA_CURSORED) &&
3286 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3287 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3288 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3289 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3290 else
3291 WinSendMsg(hwndMain,
3292 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3293 }
3294 if (!dcd->suspendview &&
3295 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3296 if (pre->fEmphasisMask & CRA_CURSORED) {
3297 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3298 if (fSplitStatus && hwndStatus2) {
3299 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3300 if (!fMoreButtons) {
3301 CHAR date[11];
3302
3303 DateFormat(date, pci->date);
3304 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
3305 tb, date, pci->time.hours, TimeSeparator,
3306 pci->time.minutes, TimeSeparator, pci->time.seconds,
3307 pci->pszDispAttr, pci->pszFileName);
3308 }
3309 else {
3310 *tf = 0;
3311 if (pci->cbFile + pci->easize > 1024) {
3312 CommaFmtULL(tf, sizeof(tf),
3313 pci->cbFile + pci->easize, 'K');
3314 }
3315 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3316 tb,
3317 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3318 }
3319 WinSetWindowText(hwndStatus2, s);
3320 }
3321 if (fMoreButtons) {
3322 CHAR szDate[DATE_BUF_BYTES];
3323
3324 WinSetWindowText(hwndName, pci->pszFileName);
3325 DateFormat(szDate, pci->date);
3326 sprintf(s, "%s %02u%s%02u%s%02u",
3327 szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
3328 TimeSeparator, pci->time.seconds);
3329 WinSetWindowText(hwndDate, s);
3330 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3331 }
3332 }
3333 }
3334 }
3335 }
3336 break;
3337
3338 case CN_ENTER:
3339 if (mp2) {
3340
3341 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3342 FILEFINDBUF3 ffb;
3343 HDIR hDir = HDIR_CREATE;
3344 ULONG nm = 1;
3345 APIRET status = 0;
3346
3347 SetShiftState();
3348 if (pci) {
3349 if (pci->rc.flRecordAttr & CRA_INUSE)
3350 break;
3351 DosError(FERR_DISABLEHARDERR);
3352 status = DosFindFirst(pci->pszFileName,
3353 &hDir,
3354 FILE_NORMAL | FILE_DIRECTORY |
3355 FILE_ARCHIVED | FILE_READONLY |
3356 FILE_HIDDEN | FILE_SYSTEM,
3357 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3358 priority_bumped();
3359 if (!status) {
3360 DosFindClose(hDir);
3361 if (ffb.attrFile & FILE_DIRECTORY) {
3362 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3363 PostMsg(hwnd,
3364 WM_COMMAND,
3365 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3366 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3367 (KC_CTRL | KC_SHIFT))
3368 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3369 else if (shiftstate & KC_CTRL)
3370 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3371 else if (shiftstate & KC_SHIFT) {
3372
3373 HWND hwndDir;
3374
3375 hwndDir = OpenDirCnr((HWND) 0,
3376 dcd->hwndParent,
3377 dcd->hwndFrame,
3378 FALSE, pci->pszFileName);
3379 if (hwndDir) {
3380 if (fMinOnOpen)
3381 WinSetWindowPos(dcd->hwndFrame,
3382 HWND_BOTTOM,
3383 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3384 if (fAutoTile)
3385 TileChildren(dcd->hwndParent, TRUE);
3386 WinSetWindowPos(hwndDir,
3387 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3388 }
3389 }
3390 else {
3391 strcpy(dcd->previous, dcd->directory);
3392 strcpy(dcd->directory, pci->pszFileName);
3393 dcd->stopflag++;
3394 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
3395 if (!PostMsg(dcd->hwndObject,
3396 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3397 dcd->stopflag--;
3398 }
3399 else if (*dcd->directory) {
3400 if (hwndMain)
3401 WinSendMsg(hwndMain,
3402 UM_SETUSERLISTNAME,
3403 MPFROMP(dcd->directory), MPVOID);
3404 else
3405 add_udir(FALSE, dcd->directory);
3406 }
3407 }
3408 }
3409 else {
3410
3411 SWP swp;
3412
3413 WinQueryWindowPos(dcd->hwndFrame, &swp);
3414 WinSendMsg(hwnd,
3415 CM_SETRECORDEMPHASIS,
3416 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3417 DefaultViewKeys(hwnd,
3418 dcd->hwndFrame,
3419 dcd->hwndParent, &swp, pci->pszFileName);
3420 WinSendMsg(hwnd,
3421 CM_SETRECORDEMPHASIS,
3422 MPFROMP(pci),
3423 MPFROM2SHORT(FALSE,
3424 CRA_INUSE |
3425 ((fUnHilite) ? CRA_SELECTED : 0)));
3426 }
3427 }
3428 else {
3429 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3430 NotifyError(pci->pszFileName, status);
3431 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3432 if (hwndStatus)
3433 WinSetWindowText(hwndStatus,
3434 (CHAR *) GetPString(IDS_RESCANSUGGESTEDTEXT));
3435 }
3436 else {
3437 dcd->stopflag++;
3438 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
3439 if (!PostMsg(dcd->hwndObject,
3440 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3441 dcd->stopflag--;
3442 }
3443 else if (*dcd->directory) {
3444 if (hwndMain)
3445 WinSendMsg(hwndMain,
3446 UM_SETUSERLISTNAME,
3447 MPFROMP(dcd->directory), MPVOID);
3448 else
3449 add_udir(FALSE, dcd->directory);
3450 }
3451 }
3452 }
3453 }
3454 else if (*dcd->directory)
3455 OpenObject(dcd->directory, Default, hwnd);
3456 } // CN_ENTER
3457 break;
3458 } // switch mp1
3459 break;
3460 } // if dcd
3461 return 0;
3462
3463 case UM_LOADFILE:
3464 if (dcd && mp2) {
3465
3466 HWND hwnd;
3467
3468 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
3469 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
3470 (CHAR *)mp2, dcd->hwndFrame);
3471 else
3472 hwnd = StartMLEEditor(dcd->hwndParent,
3473 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3474 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
3475 return MRFROMLONG(hwnd);
3476 }
3477 return 0;
3478
3479 case WM_SAVEAPPLICATION:
3480 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3481
3482 SWP swp;
3483
3484 WinQueryWindowPos(dcd->hwndFrame, &swp);
3485 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3486 PrfWriteProfileData(fmprof, appname, "VDirSizePos", &swp, sizeof(swp));
3487 }
3488 break;
3489
3490 case WM_CLOSE:
3491 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3492 if (LastDir == hwnd)
3493 LastDir = (HWND) 0;
3494 if (dcd) {
3495 dcd->stopflag++;
3496 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3497 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3498 if (dcd->hwndObject) {
3499 // Ensure object window destroy does not attempt duplicate clean up
3500 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3501 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3502 Win_Error(dcd->hwndObject, hwnd, pszSrcFile, __LINE__, "hwndObject WinPostMsg failed");
3503 }
3504 if (dcd->hwndRestore)
3505 WinSetWindowPos(dcd->hwndRestore,
3506 HWND_TOP,
3507 0,
3508 0,
3509 0,
3510 0,
3511 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3512 FreeList(dcd->lastselection);
3513 free(dcd);
3514 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3515 DosPostEventSem(CompactSem);
3516 }
3517 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3518 QW_PARENT));
3519 return 0;
3520
3521 case WM_DESTROY:
3522# ifdef FORTIFY
3523 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
3524# endif
3525 if (DirMenu)
3526 WinDestroyWindow(DirMenu);
3527 if (DirCnrMenu)
3528 WinDestroyWindow(DirCnrMenu);
3529 if (FileMenu)
3530 WinDestroyWindow(FileMenu);
3531 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3532 EmptyCnr(hwnd);
3533# ifdef FORTIFY
3534 Fortify_LeaveScope();
3535# endif
3536 break;
3537 } // switch
3538
3539 if (dcd && dcd->oldproc) {
3540# ifdef FORTIFY // 11 May 08 SHL fixme debug fortify
3541 if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
3542 DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x",
3543 msg, mp1, mp2);
3544# endif
3545 return dcd->oldproc(hwnd, msg, mp1, mp2);
3546 }
3547 else
3548 return PFNWPCnr(hwnd, msg, mp1, mp2);
3549}
3550
3551/**
3552 * Search container for matching text
3553 * @return TRUE if key completely handled here
3554 */
3555
3556MRESULT EXPENTRY SearchContainer(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3557{
3558 DIRCNRDATA *dcd = INSTDATA(hwnd);
3559 ULONG thistime;
3560 UINT len;
3561 SEARCHSTRING srch;
3562 PCNRITEM pci;
3563 USHORT key;
3564
3565 if (!dcd)
3566 return FALSE;
3567
3568 // Just to be safe, caller has probably already checked
3569 if (SHORT1FROMMP(mp1) & KC_KEYUP)
3570 return FALSE; // Let PM process key
3571
3572 // Just to be safe, caller has probably already cached
3573 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
3574
3575 // If not plain character or suppressed
3576 // Shift toggles configured setting
3577 if (shiftstate & (KC_ALT | KC_CTRL) || (shiftstate & KC_SHIFT ? !fNoSearch : fNoSearch))
3578 return FALSE; // Let PM process key
3579
3580 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
3581 key = SHORT2FROMMP(mp2);
3582 if (key == VK_BACKSPACE)
3583 key = '\x8';
3584 else if (key == VK_ESC)
3585 key = '\x1b';
3586 else
3587 return FALSE; // Let PM process key
3588 }
3589 else if (SHORT1FROMMP(mp1) & KC_CHAR)
3590 key = SHORT1FROMMP(mp2);
3591 else
3592 return FALSE;
3593
3594 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
3595 if (thistime > dcd->lasttime + 3000)
3596 *dcd->szCommonName = 0; // 3 seconds since last character
3597 dcd->lasttime = thistime;
3598
3599 switch (key) {
3600 case '\x1b': // Esc
3601 *dcd->szCommonName = 0;
3602 break;
3603 default:
3604 if (key == ' ' && !*dcd->szCommonName)
3605 break; // Let PM process space to allow select toggle
3606 len = strlen(dcd->szCommonName);
3607 if (key == '\x8') {
3608 // Backspace
3609 if (len) {
3610 len--;
3611 dcd->szCommonName[len] = 0; // Chop
3612 }
3613 }
3614 else {
3615 if (len >= CCHMAXPATH - 1) {
3616 if (!fErrorBeepOff)
3617 DosBeep(250,100);
3618 // WinAlarm(hwnd,WA_WARNING);
3619 }
3620 else {
3621 dcd->szCommonName[len] = toupper(key);
3622 dcd->szCommonName[len + 1] = 0;
3623 }
3624 }
3625 // Case insensitive search
3626 memset(&srch, 0, sizeof(SEARCHSTRING));
3627 srch.cb = (ULONG) sizeof(SEARCHSTRING);
3628 srch.pszSearch = (PSZ) dcd->szCommonName;
3629 srch.fsPrefix = TRUE;
3630 srch.fsCaseSensitive = FALSE;
3631 srch.usView = CV_ICON;
3632 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
3633 MPFROMLONG(CMA_FIRST));
3634 if (pci && (INT) pci != -1) {
3635 /* Got match make found item current item */
3636 USHORT attrib = CRA_CURSORED;
3637 // 29 Mar 09 SHL fixme to clear other object select if not extended select
3638 if (!stricmp(pci->pszDisplayName, dcd->szCommonName))
3639 attrib |= CRA_SELECTED;
3640 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
3641 MPFROM2SHORT(TRUE, attrib));
3642 /* make sure that record shows in viewport */
3643 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
3644 return (MRESULT)TRUE;
3645 }
3646 else {
3647 if (key == ' ')
3648 return FALSE; // Let PM process space to toggle select
3649 // No match
3650 // Erase non-matching last character, len is not yet incremented
3651 dcd->szCommonName[len] = 0;
3652 if (len == 0 && key != '\\') {
3653 // Let's see if user forgot leading backslash
3654 // key = SHORT1FROMMP(mp2);
3655 if (SearchContainer(hwnd, msg, mp1, MPFROM2SHORT('\\', 0))) {
3656 if (SearchContainer(hwnd, msg, mp1, mp2))
3657 return (MRESULT)TRUE; // Grab key from PM
3658 }
3659 }
3660 if (*dcd->szCommonName)
3661 return (MRESULT)TRUE; // Have partial match, grab key from PM
3662#if 0 // 15 Mar 09 SHL fixme to not hang
3663 if (!fErrorBeepOff)
3664 DosBeep(250,100);
3665 // WinAlarm(hwnd,WA_WARNING);
3666#endif
3667 }
3668 } // switch
3669
3670 return FALSE; // Let PM process key
3671}
3672
3673HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3674 ULONG flags)
3675{
3676 /* bitmapped flags:
3677 * 0x00000001 = don't close app when window closes
3678 * 0x00000002 = no frame controls
3679 */
3680
3681 HWND hwndFrame = (HWND) 0, hwndClient;
3682 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3683 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3684 USHORT id;
3685 static USHORT idinc = 0;
3686 DIRCNRDATA *dcd;
3687 static BOOL first = FALSE;
3688
3689 if (flags & 2)
3690 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3691 FCF_MINMAX | FCF_ICON));
3692 if (!idinc)
3693 idinc = (rand() % 100);
3694 if (!hwndParent)
3695 hwndParent = HWND_DESKTOP;
3696 if (ParentIsDesktop(hwndParent, hwndParent))
3697 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3698 if (!hwndMain && !first) {
3699 if (DirCnrMenu) {
3700 MENUITEM mi;
3701 memset(&mi, 0, sizeof(mi));
3702 WinSendMsg(DirCnrMenu,
3703 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3704 mi.iPosition = MIT_END;
3705 mi.afStyle = MIS_TEXT;
3706 mi.id = IDM_DRIVESMENU;
3707 WinSendMsg(DirCnrMenu,
3708 MM_INSERTITEM,
3709 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3710 }
3711 first = TRUE;
3712 }
3713 if (directory) {
3714 hwndFrame = WinCreateStdWindow(hwndParent,
3715 WS_VISIBLE,
3716 &FrameFlags,
3717 (CHAR *) WC_DIRCONTAINER,
3718 NULL,
3719 WS_VISIBLE | fwsAnimate,
3720 FM3ModHandle, DIR_FRAME, &hwndClient);
3721 if (hwndFrame && hwndClient) {
3722 id = DIR_FRAME + idinc++;
3723 if (idinc > 99)
3724 idinc = 0;
3725 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3726# ifdef FORTIFY
3727 Fortify_EnterScope();
3728# endif
3729 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3730 if (!dcd) {
3731 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3732 hwndFrame = (HWND) 0;
3733 }
3734 else {
3735 dcd->size = sizeof(DIRCNRDATA);
3736 dcd->id = id;
3737 dcd->type = DIR_FRAME;
3738 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3739 dcd->hwndFrame = hwndFrame;
3740 dcd->hwndClient = hwndClient;
3741 dcd->hwndRestore = hwndRestore;
3742 dcd->dontclose = ((flags & 1) != 0);
3743 dcd->ds.detailslongname = dsDirCnrDefault.detailslongname;
3744 dcd->ds.detailssubject = dsDirCnrDefault.detailssubject;
3745 dcd->ds.detailsea = dsDirCnrDefault.detailsea;
3746 dcd->ds.detailssize = dsDirCnrDefault.detailssize;
3747 dcd->ds.detailsicon = dsDirCnrDefault.detailsicon;
3748 dcd->ds.detailsattr = dsDirCnrDefault.detailsattr;
3749 dcd->ds.detailscrdate = dsDirCnrDefault.detailscrdate;
3750 dcd->ds.detailscrtime = dsDirCnrDefault.detailscrtime;
3751 dcd->ds.detailslwdate = dsDirCnrDefault.detailslwdate;
3752 dcd->ds.detailslwtime = dsDirCnrDefault.detailslwtime;
3753 dcd->ds.detailsladate = dsDirCnrDefault.detailsladate;
3754 dcd->ds.detailslatime = dsDirCnrDefault.detailslatime;
3755 strcpy(dcd->directory, directory);
3756 add_udir(FALSE, directory);
3757 {
3758 PFNWP oldproc;
3759
3760 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3761 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3762 }
3763 dcd->hwndCnr = WinCreateWindow(hwndClient,
3764 WC_CONTAINER,
3765 NULL,
3766 CCS_AUTOPOSITION | CCS_MINIICONS |
3767 CCS_MINIRECORDCORE | ulCnrType, // |
3768 //WS_VISIBLE,
3769 0,
3770 0,
3771 0,
3772 0,
3773 hwndClient,
3774 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3775 if (!dcd->hwndCnr) {
3776 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3777 PCSZ_WINCREATEWINDOW);
3778 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3779 free(dcd);
3780 hwndFrame = (HWND) 0;
3781 }
3782 else {
3783# ifdef FORTIFY
3784 Fortify_ChangeScope(dcd, -1);
3785# endif
3786 RestorePresParams(dcd->hwndCnr, PCSZ_DIRCNR);
3787 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3788 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3789 (PFNWP) DirCnrWndProc);
3790 {
3791 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3792 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3793 };
3794
3795 if (!(flags & 2))
3796 ids[6] = 0;
3797 CommonCreateTextChildren(dcd->hwndClient,
3798 WC_DIRSTATUS, ids);
3799 }
3800 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3801 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3802 if (FrameFlags & FCF_TASKLIST) {
3803
3804 SWP swp, swpD;
3805 ULONG size = sizeof(swp);
3806 LONG cxScreen, cyScreen;
3807
3808 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3809 if (PrfQueryProfileData(fmprof, appname, "VDirSizePos", &swpD, &size)) {
3810 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3811 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3812 if (swp.x + swpD.cx > cxScreen)
3813 swp.x = cxScreen - swpD.cx;
3814 if (swp.y + swpD.cy > cyScreen)
3815 swp.y = cyScreen - swpD.cy;
3816 swp.cx = swpD.cx;
3817 swp.cy = swpD.cy;
3818 }
3819 WinSetWindowPos(hwndFrame,
3820 HWND_TOP,
3821 swp.x,
3822 swp.y,
3823 swp.cx,
3824 swp.cy,
3825 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3826 SWP_ACTIVATE);
3827 }
3828 WinShowWindow(dcd->hwndCnr, TRUE);
3829 }
3830 }
3831# ifdef FORTIFY
3832 Fortify_LeaveScope();
3833# endif
3834 }
3835 }
3836 return hwndFrame;
3837}
3838
3839#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3840#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3841#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.