source: trunk/dll/dircnrs.c@ 1497

Last change on this file since 1497 was 1497, checked in by Gregg Young, 16 years ago

Update ExecOnList to pass environment

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