source: trunk/dll/dircnrs.c@ 1673

Last change on this file since 1673 was 1673, checked in by Gregg Young, 13 years ago

Update to Doxygen comment style Ticket 55. Also some minor code cleanup.

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