source: trunk/dll/dircnrs.c@ 1871

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

Code cleanup

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 108.0 KB
Line 
1
2/***********************************************************************
3
4 $Id: dircnrs.c 1870 2015-09-20 22:48:03Z gyoung $
5
6 Directory containers
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2015 Steven H. Levine
10
11 16 Oct 02 SHL Handle large partitions
12 01 Aug 04 SHL Rework lstrip/rstrip usage
13 23 May 05 SHL Use QWL_USER
14 24 May 05 SHL Rework Win_Error usage
15 25 May 05 SHL Use ULONGLONG and CommaFmtULL
16 26 May 05 SHL More large file formatting updates
17 05 Jun 05 SHL Use QWL_USER
18 10 Nov 05 SHL Comments
19 13 Jul 06 SHL Use Runtime_Error
20 26 Jul 06 SHL Use chop_at_crnl
21 15 Aug 06 SHL Rework warning message text
22 07 Jan 07 GKY Move error strings etc. to string file
23 30 Mar 07 GKY Remove GetPString for window class names
24 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
25 06 Apr 07 GKY Add some error checking in drag/drop
26 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checking.
27 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
28 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
29 02 Aug 07 SHL Sync with CNRITEM mods
30 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
31 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
32 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
33 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
34 10 Jan 08 SHL Sync with CfgDlgProc mods
35 19 Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
36 15 Feb 08 SHL Sync with settings menu rework
37 22 Feb 08 JBS Ticket 230: Fix/improve various code related to state or presparam values in the INI file.
38 11 May 08 GKY Avoid using stale dcd after free
39 11 May 08 SHL Add stale dcd sanity checks
40 21 Jun 08 GKY Fix columns to honor preferences on new container open.
41 22 Jun 08 GKY Included free_... functions for fortify checking
42 06 Jul 08 GKY Update delete/undelete to include move to and open XWP trashcan
43 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
44 all the details view settings (both the global variables and those in the
45 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
46 20 Jul 08 GKY Add save/append filename to clipboard.
47 Change menu wording to make these easier to find
48 02 Aug 08 GKY Always pass temp variable point to treecnr UM_SHOWME to avoid
49 freeing dcd->directory early
50 25 Aug 08 GKY Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if
51 less than 10 KiB (It hangs and can't be closed)
52 29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate.
53 10 Dec 08 SHL Integrate exception handler support
54 26 Dec 08 GKY Fixed DROPHELP to check for copy as default is action is DO_DEFAULT
55 01 Jan 09 GKY Add Seek and Scan to drives & directory context menus pass drive/dir as search root
56 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
57 07 Feb 09 GKY Move repeated strings to PCSZs.
58 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
59 07 Feb 09 GKY Add *DateFormat functions to format dates based on locale
60 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
61 08 Mar 09 GKY Additional strings move to PCSZs in init.c
62 12 Mar 09 SHL Use common SearchContainer
63 14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring
64 29 Mar 09 SHL Keep more keys away from PM if extended search in progress
65 29 Mar 09 SHL Increase extended search timeout to 3 seconds
66 28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
67 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
68 22 Jul 09 SHL Cleanup of SETFOCUS code
69 14 Sep 09 SHL Drop experimental code
70 15 Sep 09 SHL Show rescan progress while filling container
71 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
72 profile calls for user settings that work and are setable in more than one
73 miniapp; FM3Str should be used for setting only relavent to FM/2 or that
74 aren't user settable; realappname should be used for setting applicable to
75 one or more miniapp but not to FM/2
76 17 Jan 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10).
77 Mostly cast CHAR CONSTANT * as CHAR *.
78 28 May 10 GKY Yet another attempt to prevent duplicate directory names in the tree by
79 suppressing SHOW_ME during initial drive scan.
80 20 Nov 10 GKY Rework scanning code to remove redundant scans, prevent double directory
81 entries in the tree container, fix related semaphore performance using
82 combination of event and mutex semaphores
83 04 Aug 12 GKY Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of
84 copy, move and delete operations
85 22 Feb 14 GKY Fix warn readonly yes don't ask to work when recursing directories.
86 02 Mar 14 GKY Speed up intial drive scans Ticket 528
87 26 Jun 14 SHL Rework DirObjWndProc UM_RESCAN to avoid hanging FM/2 Lite when tree hidden
88 30 Aug 14 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
89 a trap when FM2 is shutdown while directory containers are still populating
90 02 May 15 GKY Changes to allow a JAVA executable object to be created using "Real object"
91 menu item on a jar file.
92 02 Aug 15 GKY Remove unneed SubbyScan code and improve suppression of blank lines and
93 duplicate subdirectory name caused by running Stubby in worker threads.
94 07 Aug 15 SHL Rework to use AddFleshWorkRequest rather than direct calls to Stubby/Flesh/Unflesh
95
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#if 0 // 2015-08-13 SHL
905 if (fSwitchTreeOnDirChg)
906 DbgMsg(pszSrcFile, __LINE__, "DirObjWndProc UM_RESCAN cDirectoriesRestored %u", cDirectoriesRestored); // 2015-08-04 SHL FIXME debug
907#endif
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 dcd->stopflag++;;
2362 // DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2363 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2364 dcd->stopflag--;
2365 }
2366 break;
2367
2368 case IDM_SHOWLNAMES:
2369 case IDM_SHOWSUBJECT:
2370 case IDM_SHOWEAS:
2371 case IDM_SHOWSIZE:
2372 case IDM_SHOWICON:
2373 case IDM_SHOWLWDATE:
2374 case IDM_SHOWLWTIME:
2375 case IDM_SHOWLADATE:
2376 case IDM_SHOWLATIME:
2377 case IDM_SHOWCRDATE:
2378 case IDM_SHOWCRTIME:
2379 case IDM_SHOWATTR:
2380 AdjustDetailsSwitches(hwnd,
2381 dcd->hwndLastMenu,
2382 SHORT1FROMMP(mp1),
2383 dcd->directory, NULL, &dcd->ds, FALSE);
2384 break;
2385
2386 case IDM_TREEVIEW:
2387 case IDM_ICON:
2388 case IDM_TEXT:
2389 case IDM_DETAILS:
2390 case IDM_NAME:
2391 case IDM_MINIICONS:
2392 case IDM_DETAILSTITLES:
2393 {
2394 CNRINFO cnri;
2395
2396 memset(&cnri, 0, sizeof(CNRINFO));
2397 cnri.cb = sizeof(CNRINFO);
2398 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2399 MPFROMLONG(sizeof(CNRINFO)));
2400 switch (SHORT1FROMMP(mp1)) {
2401 case IDM_TREEVIEW:
2402 if (!(cnri.flWindowAttr & CV_TREE))
2403 dcd->lastattr = cnri.flWindowAttr;
2404 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2405 CV_DETAIL | CV_NAME | CA_TREELINE));
2406 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2407 if (!dcd->firsttree)
2408 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2409 break;
2410 case IDM_ICON:
2411 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2412 CV_DETAIL | CV_NAME | CA_TREELINE));
2413 cnri.flWindowAttr |= CV_ICON;
2414 break;
2415 case IDM_NAME:
2416 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2417 CV_DETAIL | CV_NAME | CA_TREELINE));
2418 cnri.flWindowAttr |= CV_NAME;
2419 break;
2420 case IDM_TEXT:
2421 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2422 CV_DETAIL | CV_NAME | CA_TREELINE));
2423 cnri.flWindowAttr |= CV_TEXT;
2424 break;
2425 case IDM_DETAILS:
2426 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2427 CV_DETAIL | CV_NAME | CA_TREELINE));
2428 cnri.flWindowAttr |= CV_DETAIL;
2429 break;
2430 case IDM_MINIICONS:
2431 if (cnri.flWindowAttr & CV_MINI)
2432 cnri.flWindowAttr &= (~CV_MINI);
2433 else
2434 cnri.flWindowAttr |= CV_MINI;
2435 break;
2436 case IDM_DETAILSTITLES:
2437 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2438 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2439 else
2440 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2441 break;
2442 }
2443 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2444 cnri.flWindowAttr |= CV_FLOW;
2445 dcd->flWindowAttr = cnri.flWindowAttr;
2446 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2447 MPFROMLONG(CMA_FLWINDOWATTR));
2448 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2449 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2450 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2451 DIR_VIEW), dcd->flWindowAttr);
2452 }
2453 break;
2454
2455 case IDM_SAVETOLIST:
2456 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2457 SAV_FRAME, MPFROMP(&hwnd));
2458 break;
2459
2460 case IDM_SIZES:
2461 {
2462 PCNRITEM pci;
2463 CHAR path[CCHMAXPATH];
2464
2465 pci = (PCNRITEM) CurrentRecord(hwnd);
2466 if (pci && (INT) pci != -1)
2467 strcpy(path, pci->pszFileName);
2468 else
2469 strcpy(path, dcd->directory);
2470 MakeValidDir(path);
2471 WinDlgBox(HWND_DESKTOP,
2472 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2473 }
2474 break;
2475
2476 case IDM_MKDIR:
2477 {
2478 PCNRITEM pci;
2479 BOOL saved;
2480
2481 saved = fSelectedAlways;
2482 fSelectedAlways = FALSE;
2483 pci = (PCNRITEM)CurrentRecord(hwnd);
2484 // 01 Oct 07 SHL Make below selected directory or in current directory
2485 PMMkDir(dcd->hwndParent,
2486 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2487 FALSE);
2488 fSelectedAlways = saved;
2489 }
2490 break;
2491
2492 case IDM_SWITCH:
2493 if (mp2) {
2494 strcpy(dcd->previous, dcd->directory);
2495 strcpy(dcd->directory, (CHAR *)mp2);
2496 dcd->stopflag++;
2497 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2498 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2499 strcpy(dcd->directory, dcd->previous);
2500 dcd->stopflag--;
2501 }
2502 else if (*dcd->directory) {
2503 if (hwndMain)
2504 WinSendMsg(hwndMain,
2505 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2506 else
2507 add_udir(FALSE, dcd->directory);
2508 }
2509 }
2510 break;
2511
2512 case IDM_PARENT:
2513 {
2514 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
2515
2516 strcpy(tempname1, dcd->directory);
2517 AddBackslashToPath(tempname1);
2518 strcat(tempname1, "..");
2519 DosError(FERR_DISABLEHARDERR);
2520 if (!DosQueryPathInfo(tempname1,
2521 FIL_QUERYFULLNAME,
2522 tempname2, sizeof(tempname2))) {
2523 if (stricmp(dcd->directory, tempname2)) {
2524 strcpy(dcd->previous, dcd->directory);
2525 strcpy(dcd->directory, tempname2);
2526 dcd->stopflag++;
2527 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2528 if (!PostMsg(dcd->hwndObject,
2529 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2530 strcpy(dcd->directory, dcd->previous);
2531 dcd->stopflag--;
2532 }
2533 else if (*dcd->directory) {
2534 if (hwndMain)
2535 WinSendMsg(hwndMain,
2536 UM_SETUSERLISTNAME,
2537 MPFROMP(dcd->directory), MPVOID);
2538 else
2539 add_udir(FALSE, dcd->directory);
2540 }
2541 }
2542 }
2543 }
2544 break;
2545
2546 case IDM_PREVIOUS:
2547 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
2548
2549 CHAR tempname[CCHMAXPATH];
2550
2551 if (IsValidDir(dcd->previous)) {
2552 strcpy(tempname, dcd->directory);
2553 strcpy(dcd->directory, dcd->previous);
2554 strcpy(dcd->previous, tempname);
2555 dcd->stopflag++; ;
2556 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2557 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2558 strcpy(dcd->directory, dcd->previous);
2559 dcd->stopflag--;
2560 }
2561 else if (*dcd->directory) {
2562 if (hwndMain)
2563 WinSendMsg(hwndMain,
2564 UM_SETUSERLISTNAME,
2565 MPFROMP(dcd->directory), MPVOID);
2566 else
2567 add_udir(FALSE, dcd->directory);
2568 }
2569 }
2570 else
2571 *dcd->previous = 0;
2572 }
2573 break;
2574
2575 case IDM_WALKDIR:
2576 {
2577 CHAR newdir[CCHMAXPATH];
2578
2579 strcpy(newdir, dcd->directory);
2580 if (!WinDlgBox(HWND_DESKTOP,
2581 dcd->hwndParent,
2582 WalkAllDlgProc,
2583 FM3ModHandle,
2584 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2585 break;
2586 if (stricmp(newdir, dcd->directory)) {
2587 strcpy(dcd->previous, dcd->directory);
2588 strcpy(dcd->directory, newdir);
2589 dcd->stopflag++;
2590 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
2591 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2592 strcpy(dcd->directory, dcd->previous);
2593 dcd->stopflag--;
2594 }
2595 else if (*dcd->directory) {
2596 if (hwndMain)
2597 WinSendMsg(hwndMain,
2598 UM_SETUSERLISTNAME,
2599 MPFROMP(dcd->directory), MPVOID);
2600 else
2601 add_udir(FALSE, dcd->directory);
2602 }
2603 }
2604 }
2605 break;
2606
2607 case IDM_OPENICONME:
2608 OpenObject(dcd->directory, PCSZ_ICON, dcd->hwndFrame);
2609 break;
2610 case IDM_OPENDETAILSME:
2611 OpenObject(dcd->directory, Details, dcd->hwndFrame);
2612 break;
2613 case IDM_OPENTREEME:
2614 OpenObject(dcd->directory, PCSZ_TREE, dcd->hwndFrame);
2615 break;
2616 case IDM_OPENSETTINGSME:
2617 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2618 break;
2619
2620 case IDM_DOITYOURSELF:
2621 case IDM_UPDATE:
2622 case IDM_OPENWINDOW:
2623 case IDM_OPENSETTINGS:
2624 case IDM_OPENDEFAULT:
2625 case IDM_OPENICON:
2626 case IDM_OPENDETAILS:
2627 case IDM_OPENTREE:
2628 case IDM_OBJECT:
2629 case IDM_SHADOW:
2630 case IDM_SHADOW2:
2631 case IDM_JAVAEXE:
2632 case IDM_DELETE:
2633 case IDM_PERMDELETE:
2634 case IDM_PRINT:
2635 case IDM_ATTRS:
2636 case IDM_INFO:
2637 case IDM_COPY:
2638 case IDM_MOVE:
2639 case IDM_WPSMOVE:
2640 case IDM_WPSCOPY:
2641 case IDM_WILDCOPY:
2642 case IDM_WILDMOVE:
2643 case IDM_RENAME:
2644 case IDM_COMPARE:
2645 case IDM_EAS:
2646 case IDM_SUBJECT:
2647 case IDM_VIEW:
2648 case IDM_VIEWTEXT:
2649 case IDM_VIEWBINARY:
2650 case IDM_VIEWARCHIVE:
2651 case IDM_EDIT:
2652 case IDM_EDITTEXT:
2653 case IDM_EDITBINARY:
2654 case IDM_SAVETOCLIP:
2655 case IDM_SAVETOCLIPFILENAME:
2656 case IDM_APPENDTOCLIP:
2657 case IDM_APPENDTOCLIPFILENAME:
2658 case IDM_ARCHIVE:
2659 case IDM_ARCHIVEM:
2660 case IDM_EXTRACT:
2661 case IDM_MCIPLAY:
2662 case IDM_COLLECTFROMFILE:
2663 case IDM_UUDECODE:
2664 case IDM_UNLOCKFILE:
2665 case IDM_MERGE:
2666 {
2667 LISTINFO *li;
2668 ULONG action = UM_ACTION;
2669 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2670 if (li) {
2671 li->type = SHORT1FROMMP(mp1);
2672 li->hwnd = hwnd;
2673 li->list = BuildList(hwnd);
2674 if (li->type == IDM_DELETE)
2675 ignorereadonly = FALSE;
2676 switch (SHORT1FROMMP(mp1)) {
2677 case IDM_WILDMOVE:
2678 case IDM_WILDCOPY:
2679 case IDM_MOVE:
2680 case IDM_COPY:
2681 case IDM_WPSMOVE:
2682 case IDM_WPSCOPY:
2683 break;
2684 default:
2685 strcpy(li->targetpath, dcd->directory);
2686 break;
2687 }
2688 if (li->list) {
2689 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2690 if (!Collector) {
2691
2692 HWND hwndC;
2693 SWP swp;
2694
2695 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2696 !fAutoTile &&
2697 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2698 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2699 hwndC = StartCollector((fExternalCollector ||
2700 strcmp(realappname, FM3Str)) ?
2701 HWND_DESKTOP : dcd->hwndParent, 4);
2702 if (hwndC) {
2703 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2704 !fAutoTile && (!fExternalCollector &&
2705 !strcmp(realappname, FM3Str)))
2706 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2707 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2708 SWP_SHOW | SWP_ZORDER);
2709 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2710 fAutoTile && !strcmp(realappname, FM3Str))
2711 TileChildren(dcd->hwndParent, TRUE);
2712 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2713 SWP_ACTIVATE);
2714 DosSleep(100); //05 Aug 07 GKY 250
2715 }
2716 }
2717 else
2718 StartCollector(dcd->hwndParent, 4);
2719 }
2720 switch (SHORT1FROMMP(mp1)) {
2721 case IDM_APPENDTOCLIP:
2722 case IDM_APPENDTOCLIPFILENAME:
2723 case IDM_SAVETOCLIP:
2724 case IDM_SAVETOCLIPFILENAME:
2725 case IDM_ARCHIVE:
2726 case IDM_ARCHIVEM:
2727 case IDM_DELETE:
2728 case IDM_PERMDELETE:
2729 case IDM_ATTRS:
2730 case IDM_PRINT:
2731 case IDM_SHADOW:
2732 case IDM_SHADOW2:
2733 case IDM_JAVAEXE:
2734 case IDM_OBJECT:
2735 case IDM_VIEW:
2736 case IDM_VIEWTEXT:
2737 case IDM_VIEWBINARY:
2738 case IDM_EDIT:
2739 case IDM_EDITTEXT:
2740 case IDM_EDITBINARY:
2741 case IDM_MCIPLAY:
2742 case IDM_UPDATE:
2743 case IDM_DOITYOURSELF:
2744 case IDM_INFO:
2745 case IDM_EAS:
2746 action = UM_MASSACTION;
2747 break;
2748 }
2749 if (li->type == IDM_DELETE)
2750 ignorereadonly = FALSE;
2751 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2752 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2753 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2754 *li->targetpath = 0;
2755 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2756 Runtime_Error(pszSrcFile, __LINE__, PCSZ_POSTMSG);
2757 FreeListInfo(li);
2758 }
2759 else if (fUnHilite)
2760 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2761 }
2762 else
2763 free(li);
2764 }
2765 }
2766 break;
2767
2768 case IDM_DRIVESMENU:
2769 if (!hwndMain)
2770 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2771 break;
2772
2773 default:
2774 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2775 return 0;
2776 else {
2777 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2778 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2779
2780 register INT x;
2781
2782 if (!cmdloaded)
2783 load_commands();
2784 x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
2785 if (x >= 0) {
2786 //x++;
2787 RunCommand(hwnd, x);
2788 if (fUnHilite)
2789 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
2790 }
2791 }
2792 }
2793 break;
2794 }
2795 }
2796 return 0;
2797
2798 case UM_FIXCNRMLE:
2799 case UM_FIXEDITNAME:
2800 return CommonCnrProc(hwnd, msg, mp1, mp2);
2801
2802 case UM_FILESMENU:
2803 {
2804 PCNRITEM pci;
2805 HWND menuHwnd = (HWND) 0;
2806
2807 pci = (PCNRITEM) CurrentRecord(hwnd);
2808 if (pci && (INT) pci != -1) {
2809 if (pci->attrFile & FILE_DIRECTORY) {
2810 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2811 // WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
2812 }
2813 else
2814 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2815 }
2816 return MRFROMLONG(menuHwnd);
2817 }
2818
2819 case WM_CONTROL:
2820 DosError(FERR_DISABLEHARDERR);
2821 if (dcd) {
2822 switch (SHORT2FROMMP(mp1)) {
2823 case CN_COLLAPSETREE:
2824 case CN_EXPANDTREE:
2825 {
2826 PCNRITEM pci = (PCNRITEM) mp2;
2827
2828 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
2829 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
2830 struct
2831 {
2832 ULONG serial;
2833 CHAR volumelength;
2834 CHAR volumelabel[CCHMAXPATH];
2835 }
2836 volser;
2837 APIRET rc;
2838
2839 memset(&volser, 0, sizeof(volser));
2840 DosError(FERR_DISABLEHARDERR);
2841 // fixme?
2842 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
2843 FSIL_VOLSER, &volser, sizeof(volser));
2844 if (rc) {
2845 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
2846 GetPString(IDS_CANTFINDDIRTEXT),
2847 pci->pszFileName);
2848 if (!fErrorBeepOff)
2849 DosBeep(250,100);
2850 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
2851 AddFleshWorkRequest(hwnd, pci, eUnFlesh);
2852 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2853 }
2854 else {
2855 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2856 !volser.serial ||
2857 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2858 volser.serial)
2859 AddFleshWorkRequest(hwnd, pci, eUnFlesh);
2860 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2861 (!volser.serial ||
2862 driveserial[toupper(*pci->pszFileName) - 'A'] !=
2863 volser.serial)) {
2864 // 2015-08-07 SHL FIXME to wait for Flesh to finish before PostMsg
2865 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && AddFleshWorkRequest(hwnd, pci, eFlesh) &&
2866 !dcd->suspendview && fTopDir ) {
2867 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2868 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
2869 }
2870 }
2871 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
2872 }
2873 }
2874 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2875 if (AddFleshWorkRequest(hwnd, pci, eFlesh) && !dcd->suspendview && fTopDir) {
2876 // 2015-08-07 SHL FIXME to wait for Flesh to finish before PostMsg
2877 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2878 //DbgMsg(pszSrcFile, __LINE__, "UM_TOPDIR %p pci %p", hwnd, pci);
2879 }
2880 }
2881 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2882 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2883
2884 }
2885 }
2886 break;
2887
2888 case CN_CONTEXTMENU:
2889 {
2890 PCNRITEM pci = (PCNRITEM) mp2;
2891
2892 if (pci) {
2893 WinSendMsg(hwnd,
2894 CM_SETRECORDEMPHASIS,
2895 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2896 MarkAll(hwnd, FALSE, FALSE, TRUE);
2897 if (pci->attrFile & FILE_DIRECTORY)
2898 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
2899 else
2900 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
2901 }
2902 else {
2903 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
2904 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2905 WinSendMsg(hwnd,
2906 CM_SETRECORDEMPHASIS,
2907 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2908 dcd->cnremphasized = TRUE;
2909 }
2910 }
2911 if (dcd->hwndLastMenu) {
2912 if (dcd->hwndLastMenu == DirCnrMenu) {
2913 if (dcd->flWindowAttr & CV_MINI)
2914 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2915 }
2916 if (dcd->hwndLastMenu == DirMenu)
2917 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2918 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2919 if (dcd->cnremphasized) {
2920 WinSendMsg(hwnd,
2921 CM_SETRECORDEMPHASIS,
2922 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2923 dcd->cnremphasized = TRUE;
2924 }
2925 MarkAll(hwnd, TRUE, FALSE, TRUE);
2926 }
2927 }
2928 }
2929 break;
2930
2931 case CN_DROPHELP:
2932 if (mp2) {
2933
2934 PDRAGINFO pDInfo;
2935 PCNRITEM pci;
2936 ULONG numitems;
2937 USHORT usOperation;
2938
2939 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2940 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2941 if (!DrgAccessDraginfo(pDInfo)) {
2942 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2943 GetPString(IDS_DROPERRORTEXT));
2944 }
2945 else {
2946 numitems = DrgQueryDragitemCount(pDInfo);
2947 usOperation = pDInfo->usOperation;
2948 if (usOperation == DO_DEFAULT)
2949 usOperation = fCopyDefault ? DO_COPY : DO_MOVE;
2950 FreeDragInfoData(hwnd, pDInfo);
2951 saymsg(MB_ENTER | MB_ICONASTERISK,
2952 hwnd,
2953 GetPString(IDS_DROPHELPHDRTEXT),
2954 GetPString(IDS_DROPHELPTEXT),
2955 numitems,
2956 &"s"[numitems == 1L],
2957 pci ? NullStr : GetPString(IDS_NOTEXT),
2958 pci ? NullStr : " ",
2959 pci ? pci->pszFileName : NullStr,
2960 pci ? " " : NullStr,
2961 GetPString((usOperation == DO_MOVE) ?
2962 IDS_MOVETEXT :
2963 (usOperation == DO_LINK) ?
2964 IDS_LINKTEXT : IDS_COPYTEXT));
2965 }
2966 }
2967 return 0;
2968
2969 case CN_DRAGLEAVE:
2970 return 0;
2971
2972 case CN_DRAGAFTER:
2973 case CN_DRAGOVER:
2974 if (mp2) {
2975
2976 PDRAGITEM pDItem; // Pointer to DRAGITEM
2977 PDRAGINFO pDInfo; // Pointer to DRAGINFO
2978 PCNRITEM pci;
2979 USHORT uso;
2980
2981 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2982 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2983 if (!DrgAccessDraginfo(pDInfo)) {
2984 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2985 PCSZ_DRGACCESSDRAGINFO);
2986 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2987 }
2988 if (*dcd->directory &&
2989 (driveflags[toupper(*dcd->directory) - 'A'] &
2990 DRIVE_NOTWRITEABLE)) {
2991 DrgFreeDraginfo(pDInfo);
2992 return MRFROM2SHORT(DOR_DROP, // Return okay to link
2993 DO_LINK); // (compare) only
2994 }
2995 if (pci) {
2996 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2997 DrgFreeDraginfo(pDInfo);
2998 return (MRFROM2SHORT(DOR_NODROP, 0));
2999 }
3000 uso = pDInfo->usOperation;
3001 if (uso == DO_DEFAULT)
3002 uso = fCopyDefault ? DO_COPY : DO_MOVE;
3003 if (!(pci->attrFile & FILE_DIRECTORY)) {
3004 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
3005 DrgFreeDraginfo(pDInfo);
3006 return MRFROM2SHORT(DOR_NODROP, 0);
3007 }
3008 if (uso != DO_LINK &&
3009 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
3010 DRIVE_NOTWRITEABLE)) {
3011
3012 ARC_TYPE *info = NULL;
3013
3014 if (!fQuickArcFind &&
3015 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
3016 DRIVE_SLOW))
3017 info = find_type(pci->pszFileName, NULL);
3018 else
3019 info = quick_find_type(pci->pszFileName, NULL);
3020 if (!info || ((uso == DO_MOVE && !info->move) ||
3021 (uso == DO_COPY && !info->create))) {
3022 DrgFreeDraginfo(pDInfo);
3023 return MRFROM2SHORT(DOR_NODROP, 0);
3024 }
3025 }
3026 }
3027 }
3028
3029 /**
3030 * Access DRAGITEM index to DRAGITEM
3031 * Check valid rendering mechanisms and data
3032 */
3033 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
3034 if (DrgVerifyRMF(pDItem, (CHAR *) DRM_OS2FILE, NULL) ||
3035 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
3036 DrgVerifyRMF(pDItem, (CHAR *) DRM_FM2ARCMEMBER, (CHAR *) DRF_FM2ARCHIVE))) {
3037 DrgFreeDraginfo(pDInfo);
3038 if (driveflags[toupper(*dcd->directory) - 'A'] &
3039 DRIVE_NOTWRITEABLE)
3040 return MRFROM2SHORT(DOR_DROP, DO_LINK);
3041 if (toupper(*dcd->directory) < 'C')
3042 return MRFROM2SHORT(DOR_DROP, DO_COPY);
3043 return MRFROM2SHORT(DOR_DROP, // Return okay to drop
3044 ((fCopyDefault) ? DO_COPY : DO_MOVE));
3045 }
3046 DrgFreeDraginfo(pDInfo); // Free DRAGINFO
3047 }
3048 return MRFROM2SHORT(DOR_NODROP, 0); // Drop not valid
3049
3050 case CN_INITDRAG:
3051 {
3052 BOOL wasemphasized = FALSE;
3053 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
3054 PCNRITEM pci;
3055
3056 if (pcd) {
3057 pci = (PCNRITEM) pcd->pRecord;
3058 if (pci) {
3059 if ((INT) pci == -1)
3060 pci = NULL;
3061 else if (pci->rc.flRecordAttr & CRA_SELECTED)
3062 wasemphasized = TRUE;
3063 }
3064 else if (!*dcd->directory) {
3065 Runtime_Error(pszSrcFile, __LINE__, NULL);
3066 break;
3067 }
3068 else if (IsRoot(dcd->directory)) {
3069 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
3070 GetPString(IDS_CANTDRAGROOTDIR));
3071 break;
3072 }
3073 if (hwndStatus2) {
3074 if (pci)
3075 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_DRAGFILEOBJTEXT));
3076 else
3077 WinSetWindowText(hwndStatus2, (CHAR *) GetPString(IDS_DRAGDIRTEXT));
3078 }
3079 if (DoFileDrag(hwnd,
3080 dcd->hwndObject,
3081 mp2,
3082 NULL,
3083 pci ? NULL : dcd->directory,
3084 pci ? TRUE : FALSE)) {
3085 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
3086 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
3087 }
3088 }
3089 if (hwndStatus2) {
3090 WinSetFocus(HWND_DESKTOP, hwnd);
3091 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3092 }
3093 }
3094 }
3095 return 0;
3096
3097 case CN_DROP:
3098 if (mp2) {
3099
3100 LISTINFO *li;
3101 ULONG action = UM_ACTION;
3102
3103 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
3104 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
3105 if (li) {
3106 if (li->list && li->list[0] && IsRoot(li->list[0]))
3107 li->type = DO_LINK;
3108 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
3109
3110 CHECKLIST cl;
3111
3112 memset(&cl, 0, sizeof(cl));
3113 cl.size = sizeof(cl);
3114 cl.flags = li->type;
3115 cl.list = li->list;
3116 cl.cmd = li->type;
3117 cl.prompt = li->targetpath;
3118 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
3119 DropListProc, FM3ModHandle,
3120 DND_FRAME, MPFROMP(&cl));
3121 if (li->type == DID_ERROR)
3122 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
3123 GetPString(IDS_DRAGDROPDIALOGTEXT));
3124 if (!li->type) {
3125 FreeListInfo(li);
3126 return 0;
3127 }
3128 li->list = cl.list;
3129 if (!li->list || !li->list[0]) {
3130 FreeListInfo(li);
3131 return 0;
3132 }
3133 }
3134 switch (li->type) {
3135 case DND_LAUNCH:
3136 strcat(li->targetpath, " %a");
3137 ExecOnList(dcd->hwndParent, li->targetpath,
3138 PROMPT | WINDOWED, NULL, NULL, li->list, NULL,
3139 pszSrcFile, __LINE__);
3140 FreeList(li->list);
3141 li->list = NULL;
3142 break;
3143 case DO_LINK:
3144 if (fLinkSetsIcon) {
3145 li->type = IDM_SETICON;
3146 action = UM_MASSACTION;
3147 }
3148 else
3149 li->type = IDM_COMPARE;
3150 break;
3151 case DND_EXTRACT:
3152 if (*li->targetpath && !IsFile(li->targetpath))
3153 li->type = IDM_EXTRACT;
3154 break;
3155 case DND_MOVE:
3156 li->type = IDM_MOVE;
3157 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3158 action = UM_MASSACTION;
3159 li->type = IDM_ARCHIVEM;
3160 }
3161 break;
3162 case DND_WILDMOVE:
3163 li->type = IDM_WILDMOVE;
3164 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3165 action = UM_MASSACTION;
3166 li->type = IDM_ARCHIVEM;
3167 }
3168 break;
3169 case DND_OBJECT:
3170 li->type = IDM_OBJECT;
3171 action = UM_MASSACTION;
3172 break;
3173 case DND_SHADOW:
3174 li->type = IDM_SHADOW;
3175 action = UM_MASSACTION;
3176 break;
3177 case DND_COMPARE:
3178 li->type = IDM_COMPARE;
3179 break;
3180 case DND_SETICON:
3181 action = UM_MASSACTION;
3182 li->type = IDM_SETICON;
3183 break;
3184 case DND_COPY:
3185 li->type = IDM_COPY;
3186 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3187 action = UM_MASSACTION;
3188 li->type = IDM_ARCHIVE;
3189 }
3190 break;
3191 case DND_WILDCOPY:
3192 li->type = IDM_WILDCOPY;
3193 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3194 action = UM_MASSACTION;
3195 li->type = IDM_ARCHIVE;
3196 }
3197 break;
3198 default:
3199 if (*li->arcname && li->info) {
3200 action = UM_MASSACTION;
3201 li->type =
3202 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3203 }
3204 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
3205 action = UM_MASSACTION;
3206 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3207 }
3208 else
3209 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3210 break;
3211 }
3212 if (!li->list || !li->list[0])
3213 FreeListInfo(li);
3214 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
3215 FreeListInfo(li);
3216 else {
3217
3218 USHORT usop = 0;
3219
3220 switch (li->type) {
3221 case IDM_COPY:
3222 case IDM_WILDCOPY:
3223 usop = DO_COPY;
3224 break;
3225 case IDM_MOVE:
3226 case IDM_WILDMOVE:
3227 case IDM_ARCHIVEM:
3228 usop = DO_MOVE;
3229 break;
3230 }
3231 if (usop)
3232 return MRFROM2SHORT(DOR_DROP, usop);
3233 }
3234 }
3235 }
3236 return 0;
3237
3238 case CN_ENDEDIT:
3239 case CN_BEGINEDIT:
3240 {
3241 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3242 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3243
3244 if (pfi || pci) {
3245
3246 MRESULT mre;
3247
3248 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3249 if (mre != (MRESULT) - 1)
3250 return mre;
3251 }
3252 else if (!pfi && !pci)
3253 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3254 }
3255 return 0;
3256
3257 case CN_REALLOCPSZ:
3258 {
3259 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3260 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3261 HWND hwndMLE;
3262 CHAR testname[CCHMAXPATH];
3263
3264 if (!pci && !pfi) {
3265 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3266 WinQueryWindowText(hwndMLE, sizeof(s), s);
3267 chop_at_crnl(s);
3268 bstrip(s);
3269 if (*s) {
3270 if (!DosQueryPathInfo(s,
3271 FIL_QUERYFULLNAME,
3272 testname, sizeof(testname))) {
3273 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3274 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3275 }
3276 }
3277 }
3278 }
3279 else {
3280
3281 MRESULT mre;
3282
3283 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3284 if (mre != (MRESULT) - 1)
3285 return mre;
3286 }
3287 }
3288 return 0;
3289
3290 case CN_EMPHASIS:
3291 if (!mp2)
3292 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3293 else {
3294 PNOTIFYRECORDEMPHASIS pre = mp2;
3295 PCNRITEM pci;
3296 CHAR s[CCHMAXPATHCOMP + 91];
3297
3298 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
3299 if (!pci) {
3300 if (hwndStatus2)
3301 WinSetWindowText(hwndStatus2, NullStr);
3302 if (fMoreButtons) {
3303 WinSetWindowText(hwndName, NullStr);
3304 WinSetWindowText(hwndDate, NullStr);
3305 WinSetWindowText(hwndAttr, NullStr);
3306 }
3307 if (hwndMain)
3308 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3309 break;
3310 }
3311 if (pre->fEmphasisMask & CRA_SELECTED) {
3312 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3313 dcd->selectedbytes += (pci->cbFile + pci->easize);
3314 dcd->selectedfiles++;
3315 }
3316 else if (dcd->selectedfiles) {
3317 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3318 dcd->selectedfiles--;
3319 }
3320 if (!dcd->suspendview) {
3321 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3322 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3323 sprintf(s, "%s / %s", tf, tb);
3324 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3325 }
3326 }
3327 if (!dcd->suspendview && hwndMain && pci->pszFileName != NullStr &&
3328 (pre->fEmphasisMask & CRA_CURSORED) &&
3329 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3330 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3331 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
3332 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3333 else
3334 WinSendMsg(hwndMain,
3335 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
3336 }
3337 if (!dcd->suspendview &&
3338 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3339 if (pre->fEmphasisMask & CRA_CURSORED) {
3340 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3341 if (fSplitStatus && hwndStatus2) {
3342 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3343 if (!fMoreButtons) {
3344 CHAR date[11];
3345
3346 DateFormat(date, pci->date);
3347 sprintf(s, " %s %s %02u%s%02u%s%02u [%s] %s",
3348 tb, date, pci->time.hours, TimeSeparator,
3349 pci->time.minutes, TimeSeparator, pci->time.seconds,
3350 pci->pszDispAttr, pci->pszFileName);
3351 }
3352 else {
3353 *tf = 0;
3354 if (pci->cbFile + pci->easize > 1024) {
3355 CommaFmtULL(tf, sizeof(tf),
3356 pci->cbFile + pci->easize, 'K');
3357 }
3358 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3359 tb,
3360 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3361 }
3362 WinSetWindowText(hwndStatus2, s);
3363 }
3364 if (fMoreButtons) {
3365 CHAR szDate[DATE_BUF_BYTES];
3366
3367 WinSetWindowText(hwndName, pci->pszFileName);
3368 DateFormat(szDate, pci->date);
3369 sprintf(s, "%s %02u%s%02u%s%02u",
3370 szDate, pci->time.hours, TimeSeparator, pci->time.minutes,
3371 TimeSeparator, pci->time.seconds);
3372 WinSetWindowText(hwndDate, s);
3373 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3374 }
3375 }
3376 }
3377 }
3378 }
3379 break;
3380
3381 case CN_ENTER:
3382 if (mp2) {
3383
3384 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
3385 FILEFINDBUF3 ffb;
3386 HDIR hDir = HDIR_CREATE;
3387 ULONG nm = 1;
3388 APIRET status = 0;
3389
3390 SetShiftState();
3391 if (pci) {
3392 if (pci->rc.flRecordAttr & CRA_INUSE)
3393 break;
3394 DosError(FERR_DISABLEHARDERR);
3395 status = DosFindFirst(pci->pszFileName,
3396 &hDir,
3397 FILE_NORMAL | FILE_DIRECTORY |
3398 FILE_ARCHIVED | FILE_READONLY |
3399 FILE_HIDDEN | FILE_SYSTEM,
3400 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
3401 priority_bumped();
3402 if (!status) {
3403 DosFindClose(hDir);
3404 if (ffb.attrFile & FILE_DIRECTORY) {
3405 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3406 PostMsg(hwnd,
3407 WM_COMMAND,
3408 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3409 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3410 (KC_CTRL | KC_SHIFT))
3411 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
3412 else if (shiftstate & KC_CTRL)
3413 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
3414 else if (shiftstate & KC_SHIFT) {
3415
3416 HWND hwndDir;
3417
3418 hwndDir = OpenDirCnr((HWND) 0,
3419 dcd->hwndParent,
3420 dcd->hwndFrame,
3421 FALSE, pci->pszFileName);
3422 if (hwndDir) {
3423 if (fMinOnOpen)
3424 WinSetWindowPos(dcd->hwndFrame,
3425 HWND_BOTTOM,
3426 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3427 if (fAutoTile)
3428 TileChildren(dcd->hwndParent, TRUE);
3429 WinSetWindowPos(hwndDir,
3430 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3431 }
3432 }
3433 else {
3434 strcpy(dcd->previous, dcd->directory);
3435 strcpy(dcd->directory, pci->pszFileName);
3436 dcd->stopflag++;
3437 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
3438 if (!PostMsg(dcd->hwndObject,
3439 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
3440 dcd->stopflag--;
3441 }
3442 else if (*dcd->directory) {
3443 if (hwndMain)
3444 WinSendMsg(hwndMain,
3445 UM_SETUSERLISTNAME,
3446 MPFROMP(dcd->directory), MPVOID);
3447 else
3448 add_udir(FALSE, dcd->directory);
3449 }
3450 }
3451 }
3452 else {
3453
3454 SWP swp;
3455
3456 WinQueryWindowPos(dcd->hwndFrame, &swp);
3457 WinSendMsg(hwnd,
3458 CM_SETRECORDEMPHASIS,
3459 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3460 DefaultViewKeys(hwnd,
3461 dcd->hwndFrame,
3462 dcd->hwndParent, &swp, pci->pszFileName);
3463 WinSendMsg(hwnd,
3464 CM_SETRECORDEMPHASIS,
3465 MPFROMP(pci),
3466 MPFROM2SHORT(FALSE,
3467 CRA_INUSE |
3468 ((fUnHilite) ? CRA_SELECTED : 0)));
3469 }
3470 }
3471 else {
3472 if (!*dcd->directory || IsValidDir(dcd->directory)) {
3473 NotifyError(pci->pszFileName, status);
3474 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
3475 if (hwndStatus)
3476 WinSetWindowText(hwndStatus,
3477 (CHAR *) GetPString(IDS_RESCANSUGGESTEDTEXT));
3478 }
3479 else {
3480 dcd->stopflag++;
3481 //DbgMsg(pszSrcFile, __LINE__, "WM_RESCAN");
3482 if (!PostMsg(dcd->hwndObject,
3483 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3484 dcd->stopflag--;
3485 }
3486 else if (*dcd->directory) {
3487 if (hwndMain)
3488 WinSendMsg(hwndMain,
3489 UM_SETUSERLISTNAME,
3490 MPFROMP(dcd->directory), MPVOID);
3491 else
3492 add_udir(FALSE, dcd->directory);
3493 }
3494 }
3495 }
3496 }
3497 else if (*dcd->directory)
3498 OpenObject(dcd->directory, Default, hwnd);
3499 } // CN_ENTER
3500 break;
3501 } // switch mp1
3502 break;
3503 } // if dcd
3504 return 0;
3505
3506 case UM_LOADFILE:
3507 if (dcd && mp2) {
3508
3509 HWND hwnd;
3510
3511 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
3512 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
3513 (CHAR *)mp2, dcd->hwndFrame);
3514 else
3515 hwnd = StartMLEEditor(dcd->hwndParent,
3516 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
3517 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
3518 return MRFROMLONG(hwnd);
3519 }
3520 return 0;
3521
3522 case WM_SAVEAPPLICATION:
3523 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3524
3525 SWP swp;
3526
3527 WinQueryWindowPos(dcd->hwndFrame, &swp);
3528 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3529 PrfWriteProfileData(fmprof, appname, "VDirSizePos", &swp, sizeof(swp));
3530 }
3531 break;
3532
3533 case WM_CLOSE:
3534 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3535 if (LastDir == hwnd)
3536 LastDir = (HWND) 0;
3537 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
3538 if (dcd) {
3539 dcd->stopflag++;
3540 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3541 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3542 if (dcd->hwndObject) {
3543 // Ensure object window destroy does not attempt duplicate clean up
3544 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3545 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3546 Win_Error(dcd->hwndObject, hwnd, pszSrcFile, __LINE__, "hwndObject WinPostMsg failed");
3547 }
3548 if (dcd->hwndRestore)
3549 WinSetWindowPos(dcd->hwndRestore,
3550 HWND_TOP,
3551 0,
3552 0,
3553 0,
3554 0,
3555 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3556 FreeList(dcd->lastselection);
3557 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3558 DosPostEventSem(CompactSem);
3559 }
3560 DosReleaseMutexSem(hmtxFiltering);
3561 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3562 QW_PARENT));
3563 return 0;
3564
3565 case WM_DESTROY:
3566# ifdef FORTIFY
3567 DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p TID %u", hwnd, GetTidForThread()); // 18 Jul 08 SHL fixme
3568# endif
3569 if (DirMenu)
3570 WinDestroyWindow(DirMenu);
3571 if (DirCnrMenu)
3572 WinDestroyWindow(DirCnrMenu);
3573 if (FileMenu)
3574 WinDestroyWindow(FileMenu);
3575 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3576 EmptyCnr(hwnd);
3577 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
3578 xfree(dcd, pszSrcFile, __LINE__);
3579 dcd = NULL;
3580 DosReleaseMutexSem(hmtxFiltering);
3581# ifdef FORTIFY
3582 Fortify_LeaveScope();
3583# endif
3584 break;
3585 } // switch
3586
3587 if (dcd && dcd->oldproc) {
3588# ifdef FORTIFY // 11 May 08 SHL fixme debug fortify
3589 if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
3590 DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x",
3591 msg, mp1, mp2);
3592# endif
3593 return dcd->oldproc(hwnd, msg, mp1, mp2);
3594 }
3595 else
3596 return PFNWPCnr(hwnd, msg, mp1, mp2);
3597}
3598
3599/**
3600 * Search container for matching text
3601 * @return TRUE if key completely handled here
3602 */
3603
3604MRESULT EXPENTRY SearchContainer(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3605{
3606 DIRCNRDATA *dcd = INSTDATA(hwnd);
3607 ULONG thistime;
3608 UINT len;
3609 SEARCHSTRING srch;
3610 PCNRITEM pci;
3611 USHORT key;
3612
3613 if (!dcd)
3614 return FALSE;
3615
3616 // Just to be safe, caller has probably already checked
3617 if (SHORT1FROMMP(mp1) & KC_KEYUP)
3618 return FALSE; // Let PM process key
3619
3620 // Just to be safe, caller has probably already cached
3621 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
3622
3623 // If not plain character or suppressed
3624 // Shift toggles configured setting
3625 if (shiftstate & (KC_ALT | KC_CTRL) || (shiftstate & KC_SHIFT ? !fNoSearch : fNoSearch))
3626 return FALSE; // Let PM process key
3627
3628 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
3629 key = SHORT2FROMMP(mp2);
3630 if (key == VK_BACKSPACE)
3631 key = '\x8';
3632 else if (key == VK_ESC)
3633 key = '\x1b';
3634 else
3635 return FALSE; // Let PM process key
3636 }
3637 else if (SHORT1FROMMP(mp1) & KC_CHAR)
3638 key = SHORT1FROMMP(mp2);
3639 else
3640 return FALSE;
3641
3642 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
3643 if (thistime > dcd->lasttime + 3000)
3644 *dcd->szCommonName = 0; // 3 seconds since last character
3645 dcd->lasttime = thistime;
3646
3647 switch (key) {
3648 case '\x1b': // Esc
3649 *dcd->szCommonName = 0;
3650 break;
3651 default:
3652 if (key == ' ' && !*dcd->szCommonName)
3653 break; // Let PM process space to allow select toggle
3654 len = strlen(dcd->szCommonName);
3655 if (key == '\x8') {
3656 // Backspace
3657 if (len) {
3658 len--;
3659 dcd->szCommonName[len] = 0; // Chop
3660 }
3661 }
3662 else {
3663 if (len >= CCHMAXPATH - 1) {
3664 if (!fErrorBeepOff)
3665 DosBeep(250,100);
3666 // WinAlarm(hwnd,WA_WARNING);
3667 }
3668 else {
3669 dcd->szCommonName[len] = toupper(key);
3670 dcd->szCommonName[len + 1] = 0;
3671 }
3672 }
3673 // Case insensitive search
3674 memset(&srch, 0, sizeof(SEARCHSTRING));
3675 srch.cb = (ULONG) sizeof(SEARCHSTRING);
3676 srch.pszSearch = (PSZ) dcd->szCommonName;
3677 srch.fsPrefix = TRUE;
3678 srch.fsCaseSensitive = FALSE;
3679 srch.usView = CV_ICON;
3680 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
3681 MPFROMLONG(CMA_FIRST));
3682 if (pci && (INT) pci != -1) {
3683 // Got match make found item current item
3684 USHORT attrib = CRA_CURSORED;
3685 // 29 Mar 09 SHL fixme to clear other object select if not extended select
3686 if (!stricmp(pci->pszDisplayName, dcd->szCommonName))
3687 attrib |= CRA_SELECTED;
3688 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
3689 MPFROM2SHORT(TRUE, attrib));
3690 // make sure that record shows in viewport
3691 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
3692 return (MRESULT)TRUE;
3693 }
3694 else {
3695 if (key == ' ')
3696 return FALSE; // Let PM process space to toggle select
3697 // No match
3698 // Erase non-matching last character, len is not yet incremented
3699 dcd->szCommonName[len] = 0;
3700 if (len == 0 && key != '\\') {
3701 // Let's see if user forgot leading backslash
3702 // key = SHORT1FROMMP(mp2);
3703 if (SearchContainer(hwnd, msg, mp1, MPFROM2SHORT('\\', 0))) {
3704 if (SearchContainer(hwnd, msg, mp1, mp2))
3705 return (MRESULT)TRUE; // Grab key from PM
3706 }
3707 }
3708 if (*dcd->szCommonName)
3709 return (MRESULT)TRUE; // Have partial match, grab key from PM
3710#if 0 // 15 Mar 09 SHL fixme to not hang
3711 if (!fErrorBeepOff)
3712 DosBeep(250,100);
3713 // WinAlarm(hwnd,WA_WARNING);
3714#endif
3715 }
3716 } // switch
3717
3718 return FALSE; // Let PM process key
3719}
3720
3721HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3722 ULONG flags)
3723{
3724 /**
3725 * bitmapped flags:
3726 * 0x00000001 = don't close app when window closes
3727 * 0x00000002 = no frame controls
3728 */
3729
3730 HWND hwndFrame = (HWND) 0, hwndClient;
3731 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3732 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3733 USHORT id;
3734 static USHORT idinc = 0;
3735 DIRCNRDATA *dcd;
3736 static BOOL first = FALSE;
3737
3738 if (flags & 2)
3739 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
3740 FCF_MINMAX | FCF_ICON));
3741 if (!idinc)
3742 idinc = (rand() % 100);
3743 if (!hwndParent)
3744 hwndParent = HWND_DESKTOP;
3745 if (ParentIsDesktop(hwndParent, hwndParent))
3746 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
3747 if (!hwndMain && !first) {
3748 if (DirCnrMenu) {
3749 MENUITEM mi;
3750 memset(&mi, 0, sizeof(mi));
3751 WinSendMsg(DirCnrMenu,
3752 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
3753 mi.iPosition = MIT_END;
3754 mi.afStyle = MIS_TEXT;
3755 mi.id = IDM_DRIVESMENU;
3756 WinSendMsg(DirCnrMenu,
3757 MM_INSERTITEM,
3758 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
3759 }
3760 first = TRUE;
3761 }
3762 if (directory) {
3763 hwndFrame = WinCreateStdWindow(hwndParent,
3764 WS_VISIBLE,
3765 &FrameFlags,
3766 (CHAR *) WC_DIRCONTAINER,
3767 NULL,
3768 WS_VISIBLE | fwsAnimate,
3769 FM3ModHandle, DIR_FRAME, &hwndClient);
3770 if (hwndFrame && hwndClient) {
3771 id = DIR_FRAME + idinc++;
3772 if (idinc > 99)
3773 idinc = 0;
3774 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3775# ifdef FORTIFY
3776 Fortify_EnterScope();
3777# endif
3778 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
3779 if (!dcd) {
3780 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3781 hwndFrame = (HWND) 0;
3782 }
3783 else {
3784 dcd->size = sizeof(DIRCNRDATA);
3785 dcd->id = id;
3786 dcd->type = DIR_FRAME;
3787 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3788 dcd->hwndFrame = hwndFrame;
3789 dcd->hwndClient = hwndClient;
3790 dcd->hwndRestore = hwndRestore;
3791 dcd->dontclose = ((flags & 1) != 0);
3792 dcd->ds.detailslongname = dsDirCnrDefault.detailslongname;
3793 dcd->ds.detailssubject = dsDirCnrDefault.detailssubject;
3794 dcd->ds.detailsea = dsDirCnrDefault.detailsea;
3795 dcd->ds.detailssize = dsDirCnrDefault.detailssize;
3796 dcd->ds.detailsicon = dsDirCnrDefault.detailsicon;
3797 dcd->ds.detailsattr = dsDirCnrDefault.detailsattr;
3798 dcd->ds.detailscrdate = dsDirCnrDefault.detailscrdate;
3799 dcd->ds.detailscrtime = dsDirCnrDefault.detailscrtime;
3800 dcd->ds.detailslwdate = dsDirCnrDefault.detailslwdate;
3801 dcd->ds.detailslwtime = dsDirCnrDefault.detailslwtime;
3802 dcd->ds.detailsladate = dsDirCnrDefault.detailsladate;
3803 dcd->ds.detailslatime = dsDirCnrDefault.detailslatime;
3804 strcpy(dcd->directory, directory);
3805 add_udir(FALSE, directory);
3806 {
3807 PFNWP oldproc;
3808
3809 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3810 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
3811 }
3812 dcd->hwndCnr = WinCreateWindow(hwndClient,
3813 WC_CONTAINER,
3814 NULL,
3815 CCS_AUTOPOSITION | CCS_MINIICONS |
3816 CCS_MINIRECORDCORE | ulCnrType, // |
3817 //WS_VISIBLE,
3818 0,
3819 0,
3820 0,
3821 0,
3822 hwndClient,
3823 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3824 if (!dcd->hwndCnr) {
3825 Win_Error(hwndClient, hwndClient, pszSrcFile, __LINE__,
3826 PCSZ_WINCREATEWINDOW);
3827 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3828 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
3829 free(dcd);
3830 DosReleaseMutexSem(hmtxFiltering);
3831 hwndFrame = (HWND) 0;
3832 }
3833 else {
3834# ifdef FORTIFY
3835 Fortify_ChangeScope(dcd, -1);
3836# endif
3837 RestorePresParams(dcd->hwndCnr, PCSZ_DIRCNR);
3838 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3839 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3840 (PFNWP) DirCnrWndProc);
3841 {
3842 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3843 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3844 };
3845
3846 if (!(flags & 2))
3847 ids[6] = 0;
3848 CommonCreateTextChildren(dcd->hwndClient,
3849 WC_DIRSTATUS, ids);
3850 }
3851 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3852 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3853 if (FrameFlags & FCF_TASKLIST) {
3854
3855 SWP swp, swpD;
3856 ULONG size = sizeof(swp);
3857 LONG cxScreen, cyScreen;
3858
3859 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3860 if (PrfQueryProfileData(fmprof, appname, "VDirSizePos", &swpD, &size)) {
3861 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3862 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3863 if (swp.x + swpD.cx > cxScreen)
3864 swp.x = cxScreen - swpD.cx;
3865 if (swp.y + swpD.cy > cyScreen)
3866 swp.y = cyScreen - swpD.cy;
3867 swp.cx = swpD.cx;
3868 swp.cy = swpD.cy;
3869 }
3870 WinSetWindowPos(hwndFrame,
3871 HWND_TOP,
3872 swp.x,
3873 swp.y,
3874 swp.cx,
3875 swp.cy,
3876 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3877 SWP_ACTIVATE);
3878 }
3879 WinShowWindow(dcd->hwndCnr, TRUE);
3880 }
3881 }
3882# ifdef FORTIFY
3883 Fortify_LeaveScope();
3884# endif
3885 }
3886 }
3887 return hwndFrame;
3888}
3889
3890#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3891#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3892#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.