source: trunk/dll/dircnrs.c@ 1750

Last change on this file since 1750 was 1741, checked in by Gregg Young, 12 years ago

Fix warn readonly yes don't ask to work when recursing directories.

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