source: trunk/dll/dircnrs.c@ 1526

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

Yet another attempt to prevent duplicate directory names in the tree by suppressing SHOW_ME during initial drive scan.

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