source: trunk/dll/dircnrs.c@ 1858

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

Rework FlestWaitForWorkListEmpty to support wait for parents of path
Clean up some obsolete code

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