source: trunk/dll/dircnrs.c@ 1505

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

Changes to get FM2 to compile with the latest watcom 1.9 beta (mostly type casts of CHAR CONSTANT * to CHAR *). Changes to get the environment settings working everywhere again (broken by the change that moved commands to the INI); Added an environment size variable (set to 2048 which was the largest I found hard coded). Still need to find everywhere the environment size is set and use this variable.

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