source: trunk/dll/dircnrs.c@ 1194

Last change on this file since 1194 was 1177, checked in by John Small, 17 years ago

Ticket 187: Draft 2: Move remaining function declarations

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