source: trunk/dll/dircnrs.c@ 1459

Last change on this file since 1459 was 1459, checked in by Steven Levine, 16 years ago

Show rescan progress while filling container, ticket #291

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