source: trunk/dll/dircnrs.c@ 1439

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

Changes to allow high mem loading of dll; Refactor .LONGNAME and .SUBJECT EA fetch to FetchCommonEAs. Add szFSType to FillInRecordFromFSA use to bypass EA scan and size formatting for tree container; Fix labels/FS type to work on scan on NOPRESCAN Drives; Fixed dbl directory names on restore of dir cnrs; (Tickets 47, 339, 363, 368, 369, 370)

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