source: trunk/dll/dircnrs.c@ 1120

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

Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if less than 10 KiB (It hangs and can't be closed) (Ticket 214) Also some cleanup of the error messages for CheckDriveSpaceAvail.

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