source: trunk/dll/dircnrs.c@ 1551

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

This code adds the semaphores to prevent a rescan from starting before the current one is finished; it fixes the double directory listing in the tree container and streamlines scanning. It update mapsym.pl to the latest version. Some code cleanup is included

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