source: trunk/dll/dircnrs.c@ 1836

Last change on this file since 1836 was 1836, checked in by Gregg Young, 10 years ago

Fix trap in collector if a pci-pszFileName = NullStr and fix heap corruption problem and its related traps. This code reverts John double free fix. Ticket [551][555]

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