source: trunk/dll/dircnrs.c@ 1571

Last change on this file since 1571 was 1571, checked in by Steven Levine, 14 years ago

Minor cleanup

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