source: trunk/dll/dircnrs.c@ 1874

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

DosSleep times in WaitFleshWorkListEmpty set by caller; TOPDIR code calls WaitFleshWorkListEmpty before ShowCnrRecord and now actually exists for directory containers in tree view. These calls are made from the object windows.

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