source: trunk/dll/dircnrs.c@ 1856

Last change on this file since 1856 was 1856, checked in by Steven Levine, 10 years ago

Rework Flesh/Stubby etc. to avoid running on thread 1
Should be ready for release after spurious traps resolved
DbgMsg calls retained - delete/disable before release

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