source: trunk/dll/dircnrs.c@ 1451

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

Change WM_USER numbers to account for the fact that some values have been used by the toolkit; Fix unexpected behavior when doubleclick on dircnr dir icon; Provide option to tun off the drive exclude dialogg on startup.

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