source: trunk/dll/dircnrs.c@ 1323

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

Fix dbl free error for deletes by disabling fSyncUpdates for deletes; ironically the container now update faster then with it on. Also improved failure of container to update following an archive extract. It now should work for all but may be the largest archives (based on root filenames). It work with the largest I could find.

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