source: trunk/dll/dircnrs.c@ 1078

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

More Fortify infrastructure enhancements
Rework Fortify_SetOwner
Add Fortify_BecomeOwner
Avoid more spurious leak reports

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