source: trunk/dll/dircnrs.c@ 1664

Last change on this file since 1664 was 1664, checked in by Gregg Young, 13 years ago

Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of copy, move and delete operations. Changes to allow copy and move over readonly files with a warning dialog; also added a warning dialog for delete of readonly files

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