source: trunk/dll/dircnrs.c@ 1400

Last change on this file since 1400 was 1400, checked in by Gregg Young, 17 years ago

Remainder of changes to rename commafmt.h/c (Ticket 28, 82); Additional strings moved to PCSZs in init.c (Ticket 6); Added WriteDetailsSwitches used it and LoadDetailsSwitches to consolidate inline code (Ticket 343, 344)

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