source: trunk/dll/dircnrs.c@ 1344

Last change on this file since 1344 was 1335, checked in by Steven Levine, 17 years ago

Ticket 26: Add exception handlers to all threads using xbeginthread

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