source: trunk/dll/dircnrs.c@ 1077

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

Enhance Fortify infrastructure
Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT support
Add more fm/2 Fortify tooling and rework existing tooling for correct nesting
Still lots to do for cross-thread allocations
Add misc.h
Add walkem.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 94.4 KB
RevLine 
[36]1
2/***********************************************************************
3
4 $Id: dircnrs.c 1077 2008-07-18 18:11:54Z 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
648 Fortify_ChangeOwner(dcd);
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:
1067 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1068 if (dcd) {
1069 if (dcd->hwndRestore)
1070 WinSetWindowPos(dcd->hwndRestore,
1071 HWND_TOP,
1072 0,
1073 0,
1074 0,
1075 0,
1076 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
1077 FreeList(dcd->lastselection);
[1009]1078 xfree(dcd, pszSrcFile, __LINE__);
[1063]1079# ifdef FORTIFY
1080 Fortify_LeaveScope();
1081# endif
[1017]1082 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
[551]1083 DosPostEventSem(CompactSem);
1084 }
1085 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1086 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1087 break;
[2]1088 }
[551]1089 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]1090}
1091
[551]1092MRESULT EXPENTRY DirCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[275]1093{
[672]1094 DIRCNRDATA *dcd = INSTDATA(hwnd);
[2]1095
[551]1096 switch (msg) {
[1077]1097 case WM_CREATE:
1098# ifdef FORTIFY
1099 Fortify_EnterScope();
1100# endif
1101 break;
1102
[551]1103 case DM_PRINTOBJECT:
1104 return MRFROMLONG(DRR_TARGET);
1105
1106 case DM_DISCARDOBJECT:
1107 if (dcd)
1108 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1109 else
[2]1110 return MRFROMLONG(DRR_TARGET);
1111
[551]1112 case WM_CHAR:
1113 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1114 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1115 return (MRESULT) TRUE;
1116 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1117 switch (SHORT2FROMMP(mp2)) {
1118 case VK_INSERT:
1119 if ((shiftstate & KC_CTRL) == KC_CTRL)
1120 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
1121 else if ((shiftstate & KC_ALT) == KC_ALT)
1122 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_CREATE, 0), MPVOID);
1123 break;
1124 case VK_PAGEUP:
1125 if ((shiftstate & KC_CTRL) == KC_CTRL)
1126 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PARENT, 0), MPVOID);
1127 break;
1128 case VK_PAGEDOWN:
1129 if ((shiftstate & KC_CTRL) == KC_CTRL)
1130 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), MPVOID);
1131 break;
1132 case VK_HOME:
1133 if ((shiftstate & KC_CTRL) == KC_CTRL && dcd) {
[2]1134
[551]1135 CHAR s[CCHMAXPATH], *p;
[2]1136
[551]1137 strcpy(s, dcd->directory);
1138 p = strchr(s, '\\');
1139 if (p) {
1140 p++;
1141 *p = 0;
1142 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(s), MPVOID);
1143 }
1144 }
1145 break;
1146 case VK_DELETE:
1147 if ((shiftstate & KC_CTRL) == KC_CTRL)
1148 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1149 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1150 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1151 else
1152 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1153 break;
[2]1154 }
[551]1155 }
1156 if (shiftstate || fNoSearch)
1157 break;
1158 if (SHORT1FROMMP(mp1) & KC_CHAR) {
[2]1159
[551]1160 ULONG thistime, len;
1161 SEARCHSTRING srch;
1162 PCNRITEM pci;
[2]1163
[551]1164 if (!dcd)
1165 break;
1166 switch (SHORT1FROMMP(mp2)) {
1167 case '\x1b':
1168 case '\r':
1169 case '\n':
1170 dcd->lasttime = 0;
1171 *dcd->szCommonName = 0;
1172 break;
1173 default:
1174 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1175 if (thistime > dcd->lasttime + 1250)
1176 *dcd->szCommonName = 0;
1177 dcd->lasttime = thistime;
1178 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1179 break;
1180 KbdRetry:
1181 len = strlen(dcd->szCommonName);
1182 if (len >= CCHMAXPATH - 1) {
1183 *dcd->szCommonName = 0;
1184 len = 0;
1185 }
1186 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1187 dcd->szCommonName[len + 1] = 0;
1188 memset(&srch, 0, sizeof(SEARCHSTRING));
1189 srch.cb = (ULONG) sizeof(SEARCHSTRING);
1190 srch.pszSearch = (PSZ) dcd->szCommonName;
1191 srch.fsPrefix = TRUE;
1192 srch.fsCaseSensitive = FALSE;
1193 srch.usView = CV_ICON;
1194 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1195 MPFROMLONG(CMA_FIRST));
1196 if (pci && (INT) pci != -1) {
[2]1197
[551]1198 USHORT attrib = CRA_CURSORED;
[2]1199
[551]1200 /* make found item current item */
1201 if (!stricmp(pci->pszFileName, dcd->szCommonName))
1202 attrib |= CRA_SELECTED;
1203 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1204 MPFROM2SHORT(TRUE, attrib));
1205 /* make sure that record shows in viewport */
1206 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1207 return (MRESULT) TRUE;
1208 }
1209 else {
1210 if (SHORT1FROMMP(mp2) == ' ') {
1211 dcd->szCommonName[len] = 0;
1212 break;
1213 }
1214 *dcd->szCommonName = 0;
1215 dcd->lasttime = 0;
1216 if (len) // retry as first letter if no match
1217 goto KbdRetry;
1218 }
1219 break;
[2]1220 }
[551]1221 }
1222 break;
[2]1223
[551]1224 case WM_MOUSEMOVE:
1225 case WM_BUTTON1UP:
1226 case WM_BUTTON2UP:
1227 case WM_BUTTON3UP:
1228 case WM_CHORD:
1229 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1230 break;
[2]1231
[551]1232 case WM_BUTTON1MOTIONEND:
1233 {
1234 CNRINFO cnri;
[2]1235
[551]1236 memset(&cnri, 0, sizeof(CNRINFO));
1237 cnri.cb = sizeof(CNRINFO);
1238 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1239 MPFROMLONG(sizeof(CNRINFO)))) {
1240 if (cnri.flWindowAttr & CV_DETAIL)
1241 PrfWriteProfileData(fmprof, appname, "CnrSplitBar",
1242 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
[2]1243 }
[551]1244 }
1245 break;
[2]1246
[551]1247 case UM_COMPARE:
1248 if (dcd && mp1 && mp2) {
[2]1249
[551]1250 COMPARE *cmp;
[1009]1251 CHAR *leftdir = (CHAR *)mp1, *rightdir = (CHAR *)mp2;
[2]1252
[551]1253 if (!IsFile(leftdir) && !IsFile(rightdir)) {
[1077]1254# ifdef FORTIFY
1255 Fortify_EnterScope();
1256# endif
[551]1257 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1258 if (cmp) {
1259 cmp->size = sizeof(COMPARE);
1260 strcpy(cmp->leftdir, leftdir);
1261 strcpy(cmp->rightdir, rightdir);
1262 cmp->hwndParent = dcd->hwndParent;
1263 cmp->dcd.hwndParent = dcd->hwndParent;
1264 WinDlgBox(HWND_DESKTOP,
1265 HWND_DESKTOP,
1266 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1267 }
[1077]1268# ifdef FORTIFY
1269 Fortify_LeaveScope();
1270# endif
[2]1271 }
[551]1272 }
1273 return 0;
[2]1274
[978]1275 case WM_PRESPARAMCHANGED:
1276 PresParamChanged(hwnd, "DirCnr", mp1, mp2);
1277 break;
[2]1278
[551]1279 case UM_UPDATERECORDLIST:
1280 if (dcd && mp1)
1281 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1282 return 0;
[2]1283
[551]1284 case UM_UPDATERECORD:
1285 if (dcd && mp1) {
[2]1286
[551]1287 CHAR *filename;
[2]1288
[551]1289 filename = mp1;
1290 if (filename)
1291 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1292 }
1293 return 0;
[2]1294
[551]1295 case WM_SETFOCUS:
1296 /*
1297 * put name of our window (directory name) on status line
1298 */
1299 if (dcd && hwndStatus && mp2) {
[2]1300
[551]1301 PCNRITEM pci = NULL;
[2]1302
[551]1303 if (fAutoView && hwndMain) {
1304 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
1305 MPFROMSHORT(CRA_CURSORED));
1306 if (pci && (INT) pci != -1 &&
[730]1307 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1308 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[551]1309 else
1310 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
[2]1311 }
[551]1312 if (*dcd->directory) {
1313 if (hwndMain)
1314 WinSendMsg(hwndMain,
1315 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1316 else
1317 add_udir(FALSE, dcd->directory);
[2]1318 }
[551]1319 if (hwndMain)
1320 PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
1321 }
1322 if (mp2) {
1323 LastDir = hwnd;
1324 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1325 if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory)
1326 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
1327 }
1328 break;
[2]1329
[551]1330 case UM_SETDIR:
1331 if (dcd && mp1) {
[2]1332
[551]1333 CHAR fullname[CCHMAXPATH];
[2]1334
[551]1335 DosError(FERR_DISABLEHARDERR);
[1009]1336 if (!DosQueryPathInfo((CHAR *)mp1,
[551]1337 FIL_QUERYFULLNAME, fullname, sizeof(fullname))) {
1338 if (stricmp(dcd->directory, fullname)) {
1339 strcpy(dcd->previous, dcd->directory);
1340 strcpy(dcd->directory, fullname);
1341 DosEnterCritSec();
1342 dcd->stopflag++;
1343 DosExitCritSec();
1344 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
1345 strcpy(dcd->directory, dcd->previous);
1346 DosEnterCritSec();
1347 dcd->stopflag--;
1348 DosExitCritSec();
1349 }
1350 else if (*dcd->directory) {
1351 if (hwndMain)
1352 WinSendMsg(hwndMain,
1353 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1354 else
1355 add_udir(FALSE, dcd->directory);
1356 }
1357 }
[2]1358 }
[551]1359 }
1360 break;
[2]1361
[551]1362 case UM_RESCAN:
1363 if (dcd) {
[2]1364
[551]1365 CNRINFO cnri;
1366 CHAR s[CCHMAXPATH * 2], tf[81], tb[81];
1367 PCNRITEM pci;
[2]1368
[551]1369 memset(&cnri, 0, sizeof(CNRINFO));
1370 cnri.cb = sizeof(CNRINFO);
1371 WinSendMsg(hwnd,
1372 CM_QUERYCNRINFO,
1373 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1374 cnri.pszCnrTitle = dcd->directory;
1375 WinSendMsg(hwnd,
1376 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
1377 dcd->totalfiles = cnri.cRecords;
1378 commafmt(tb, sizeof(tb), dcd->totalfiles);
1379 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
1380 sprintf(s, "%s / %s", tb, tf);
1381 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1382 commafmt(tb, sizeof(tb), dcd->selectedfiles);
1383 CommaFmtULL(tf, sizeof(tf), dcd->selectedbytes, 'K');
1384 sprintf(s, "%s / %s", tb, tf);
1385 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1386 if (hwndStatus &&
1387 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1388 PostMsg(dcd->hwndObject, UM_RESCAN2, MPVOID, MPVOID);
1389 if ((fSplitStatus && hwndStatus2) || fMoreButtons) {
1390 pci = WinSendMsg(hwnd,
1391 CM_QUERYRECORDEMPHASIS,
1392 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1393 if (pci && (INT) pci != -1) {
1394 if (fSplitStatus && hwndStatus2) {
1395 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1396 if (!fMoreButtons)
1397 sprintf(s,
1398 " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
1399 tb,
1400 pci->date.year,
1401 pci->date.month,
1402 pci->date.day,
1403 pci->time.hours,
1404 pci->time.minutes,
1405 pci->time.seconds,
1406 pci->pszDispAttr, pci->pszFileName);
1407 else {
1408 *tf = 0;
1409 if (pci->cbFile + pci->easize > 1024) {
1410 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1411 }
1412 sprintf(s,
1413 GetPString(IDS_STATUSSIZETEXT),
1414 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1415 }
1416 WinSetWindowText(hwndStatus2, s);
1417 }
1418 else
1419 WinSetWindowText(hwndStatus2, NullStr);
1420 if (fMoreButtons) {
1421 WinSetWindowText(hwndName, pci->pszFileName);
1422 sprintf(s,
1423 "%04u/%02u/%02u %02u:%02u:%02u",
1424 pci->date.year,
1425 pci->date.month,
1426 pci->date.day,
1427 pci->time.hours, pci->time.minutes, pci->time.seconds);
1428 WinSetWindowText(hwndDate, s);
1429 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1430 }
1431 }
1432 else {
1433 WinSetWindowText(hwndStatus2, NullStr);
1434 WinSetWindowText(hwndName, NullStr);
1435 WinSetWindowText(hwndDate, NullStr);
1436 WinSetWindowText(hwndAttr, NullStr);
1437 }
1438 }
[2]1439 }
[551]1440 }
1441 return 0;
[2]1442
[551]1443 case UM_SORTRECORD:
1444 if (dcd) {
[2]1445
[551]1446 CNRINFO cnri;
[2]1447
[551]1448 memset(&cnri, 0, sizeof(CNRINFO));
1449 cnri.cb = sizeof(CNRINFO);
1450 WinSendMsg(hwnd,
1451 CM_QUERYCNRINFO,
1452 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1453 cnri.pSortRecord = (PVOID) SortDirCnr;
1454 WinSendMsg(hwnd,
1455 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PSORTRECORD));
1456 WinSendMsg(hwnd,
1457 CM_SORTRECORD,
1458 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
1459 }
1460 return 0;
[2]1461
[551]1462 case UM_SETUP:
1463 if (dcd) {
1464 if (!dcd->hwndObject) {
1465 /*
1466 * first time through -- set things up
1467 */
[2]1468
[551]1469 CNRINFO cnri;
[2]1470
[551]1471 memset(&cnri, 0, sizeof(CNRINFO));
1472 cnri.cb = sizeof(CNRINFO);
1473 WinSendMsg(hwnd,
1474 CM_QUERYCNRINFO,
1475 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1476 cnri.cyLineSpacing = 0;
1477 cnri.cxTreeIndent = 12L;
[2]1478
[551]1479 cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1480 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
1481 CV_FLOW);
1482 cnri.pSortRecord = (PVOID) SortDirCnr;
[2]1483
[551]1484 {
1485 ULONG size = sizeof(ULONG);
[2]1486
[551]1487 PrfQueryProfileData(fmprof,
1488 appname,
1489 "DirflWindowAttr",
1490 (PVOID) & cnri.flWindowAttr, &size);
1491 size = sizeof(MASK);
1492 if (!*dcd->mask.szMask &&
1493 !dcd->mask.attrFile && !dcd->mask.antiattr) {
1494 if (PrfQueryProfileSize(fmprof,
1495 appname, "DirFilter", &size) && size) {
1496 PrfQueryProfileData(fmprof,
1497 appname, "DirFilter", &dcd->mask, &size);
1498 SetMask(dcd->mask.szMask, &dcd->mask);
1499 }
1500 else
1501 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1502 FILE_ARCHIVED | FILE_DIRECTORY |
1503 FILE_HIDDEN | FILE_SYSTEM);
1504 }
1505 *(dcd->mask.prompt) = 0;
1506 }
1507 if (dcd->flWindowAttr)
1508 cnri.flWindowAttr = dcd->flWindowAttr;
1509 else
1510 dcd->flWindowAttr = cnri.flWindowAttr;
1511 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH |
1512 CA_TITLEREADONLY | CA_TITLESEPARATOR));
1513 cnri.flWindowAttr |= CV_FLOW;
1514 dcd->flWindowAttr |= CV_FLOW;
1515 if (WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR))
1516 cnri.flWindowAttr &= (~CA_CONTAINERTITLE);
1517 else
1518 cnri.flWindowAttr |= CA_CONTAINERTITLE;
1519 if (!dcd->sortFlags)
1520 dcd->sortFlags = sortFlags;
1521 WinSendMsg(hwnd,
1522 CM_SETCNRINFO,
1523 MPFROMP(&cnri),
1524 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1525 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1526 SetCnrCols(hwnd, FALSE);
1527 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
1528 Runtime_Error(pszSrcFile, __LINE__,
1529 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1530 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1531 return 0;
1532 }
1533 else
[771]1534 DosSleep(32); //05 Aug 07 GKY 64
[551]1535 WinEnableMenuItem(DirCnrMenu, IDM_FINDINTREE, (hwndTree != (HWND) 0));
[2]1536 }
[1028]1537 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
[551]1538 }
1539 else {
1540 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
[2]1541 return 0;
[551]1542 }
1543 return 0;
[2]1544
[923]1545 case UM_SETUP2:
[992]1546 if (dcd) {
[1065]1547 AdjustCnrColsForPref(hwnd, NULL, &dcd->ds, FALSE);
[992]1548 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[1016]1549 DIR_FILTER), &dcd->mask, FALSE);
[992]1550 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[1016]1551 DIR_SORT), dcd->sortFlags, FALSE);
[992]1552 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[1016]1553 DIR_VIEW), dcd->flWindowAttr);
[992]1554 } else
[923]1555 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1556 return 0;
1557
[551]1558 case WM_MENUEND:
1559 if (dcd) {
[2]1560
[551]1561 HWND hwndMenu = (HWND) mp2;
[2]1562
[551]1563 if (hwndMenu == DirCnrMenu ||
[1016]1564 hwndMenu == FileMenu ||
1565 hwndMenu == DirMenu) {
[551]1566 MarkAll(hwnd, TRUE, FALSE, TRUE);
1567 if (dcd->cnremphasized) {
1568 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1569 MPFROM2SHORT(FALSE, CRA_SOURCE));
1570 dcd->cnremphasized = FALSE;
1571 }
[2]1572 }
[551]1573 }
1574 break;
[2]1575
[551]1576 case UM_OPENWINDOWFORME:
1577 if (dcd) {
[1009]1578 if (mp1 && !IsFile((CHAR *)mp1)) {
[551]1579 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
[2]1580 }
[551]1581 else if (mp1 && IsFile(mp1) == 1) {
1582 StartArcCnr(HWND_DESKTOP,
[1009]1583 dcd->hwndFrame, (CHAR *)mp1, 4, (ARC_TYPE *) mp2);
[551]1584 }
1585 }
1586 return 0;
[2]1587
[551]1588 case MM_PORTHOLEINIT:
1589 if (dcd) {
1590 switch (SHORT1FROMMP(mp1)) {
1591 case 0:
1592 case 1:
1593 {
1594 ULONG wmsg;
[2]1595
[551]1596 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1597 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
1598 wmsg, MPVOID, MPVOID), mp1, mp2);
1599 }
1600 break;
[2]1601 }
[551]1602 }
1603 break;
[2]1604
[551]1605 case UM_INITMENU:
1606 case WM_INITMENU:
1607 if (dcd) {
1608 switch (SHORT1FROMMP(mp1)) {
1609 case IDM_FILESMENU:
[907]1610 CopyPresParams((HWND) mp2, hwndMainMenu);
1611 if (isalpha(*dcd->directory)) {
[551]1612 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1613 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
1614 WinEnableMenuItem((HWND) mp2, IDM_RENAME, FALSE);
1615 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1616 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, FALSE);
1617 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, FALSE);
1618 WinEnableMenuItem((HWND) mp2, IDM_DELETE, FALSE);
1619 WinEnableMenuItem((HWND) mp2, IDM_EDIT, FALSE);
1620 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, FALSE);
1621 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, FALSE);
1622 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, FALSE);
1623 }
1624 else {
1625 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, TRUE);
1626 WinEnableMenuItem((HWND) mp2, IDM_RENAME, TRUE);
1627 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1628 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, TRUE);
1629 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, TRUE);
1630 WinEnableMenuItem((HWND) mp2, IDM_DELETE, TRUE);
1631 WinEnableMenuItem((HWND) mp2, IDM_EDIT, TRUE);
1632 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
1633 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
[907]1634 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
[551]1635 }
1636 }
1637 break;
[2]1638
[551]1639 case IDM_VIEWSMENU:
[907]1640 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
[877]1641 CopyPresParams((HWND) mp2, hwndMainMenu);
[907]1642 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1643 (dcd->lastselection != NULL));
1644 if (isalpha(*dcd->directory)) {
[551]1645 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
1646 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1647 else
1648 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1649 }
1650 WinEnableMenuItem((HWND) mp2,
1651 IDM_SELECTCOMPAREMENU,
1652 (CountDirCnrs(dcd->hwndParent) > 1));
1653 break;
[2]1654
[551]1655 case IDM_DETAILSSETUP:
[1065]1656 SetDetailsSwitches((HWND) mp2, &dcd->ds);
[551]1657 break;
[2]1658
[551]1659 case IDM_COMMANDSMENU:
1660 SetupCommandMenu((HWND) mp2, hwnd);
1661 break;
[2]1662
[551]1663 case IDM_SORTSUBMENU:
1664 SetSortChecks((HWND) mp2, dcd->sortFlags);
1665 break;
[2]1666
[551]1667 case IDM_WINDOWSMENU:
1668 SetupWinList((HWND) mp2,
1669 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
1670 break;
[2]1671 }
[551]1672 dcd->hwndLastMenu = (HWND) mp2;
1673 }
1674 if (msg == WM_INITMENU)
1675 break;
1676 return 0;
[2]1677
[551]1678 case UM_FILTER:
1679 if (dcd) {
[2]1680
[551]1681 PCNRITEM pci;
[2]1682
[551]1683 if (mp1) {
1684 DosEnterCritSec();
[1009]1685 SetMask((CHAR *)mp1, &dcd->mask);
[551]1686 DosExitCritSec();
[2]1687 }
[551]1688 dcd->suspendview = 1;
1689 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1690 dcd->suspendview = 0;
1691 if (fAutoView && hwndMain) {
1692 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1693 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1694 if (pci && (INT) pci != -1 &&
[730]1695 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1696 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[551]1697 else
1698 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1699 }
1700 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1701 }
1702 return 0;
[2]1703
[551]1704 case UM_COMMAND:
1705 if (mp1) {
1706 if (dcd) {
1707 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1708 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1709 FreeListInfo((LISTINFO *) mp1);
1710 }
1711 else
1712 return (MRESULT) TRUE;
[2]1713 }
[551]1714 else
1715 FreeListInfo((LISTINFO *) mp1);
1716 }
1717 return 0;
[2]1718
[551]1719 case UM_NOTIFY:
1720 if (mp2)
[1009]1721 Notify((CHAR *)mp2);
[551]1722 return 0;
[2]1723
[551]1724 case UM_DRIVECMD:
1725 if (mp1)
1726 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0), mp1);
1727 return 0;
[2]1728
[551]1729 case WM_COMMAND:
1730 DosError(FERR_DISABLEHARDERR);
1731 if (dcd) {
1732 switch (SHORT1FROMMP(mp1)) {
1733 case IDM_SETTARGET:
1734 SetTargetDir(hwnd, FALSE);
1735 break;
[2]1736
[551]1737 case IDM_CREATE:
1738 {
1739 STRINGINPARMS sip;
1740 CHAR filename[CCHMAXPATHCOMP];
[2]1741
[551]1742 memset(&sip, 0, sizeof(sip));
1743 sip.help = GetPString(IDS_CREATETEXT);
1744 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1745 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1746 strcpy(filename, "NEWFILE.TXT");
1747 sip.ret = filename;
1748 sip.title = GetPString(IDS_CREATETITLETEXT);
1749 if (WinDlgBox(HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle,
1750 STR_FRAME, &sip)) {
1751 bstrip(sip.ret);
1752 if (*sip.ret) {
1753 CHAR newfile[CCHMAXPATH];
1754 FILE *fp;
1755 INT test;
1756 PCNRITEM pci;
[2]1757
[551]1758 strcpy(newfile, dcd->directory);
1759 if (newfile[strlen(newfile) - 1] != '\\')
1760 strcat(newfile, "\\");
1761 strcat(newfile, sip.ret);
1762 test = IsFile(newfile);
1763 if (test != 1)
1764 fp = fopen(newfile, "w");
1765 if (test != 1 && !fp) {
1766 saymsg(MB_ENTER,
1767 hwnd,
1768 GetPString(IDS_ERRORTEXT),
1769 GetPString(IDS_CREATEERRORTEXT), newfile);
1770 }
1771 else {
1772 if (fp) {
1773 WinSendMsg(hwnd, UM_UPDATERECORD, MPFROMP(newfile), MPVOID);
1774 fclose(fp);
1775 }
1776 if (*editor) {
[2]1777
[551]1778 CHAR *dummy[2];
[2]1779
[551]1780 dummy[0] = newfile;
1781 dummy[1] = NULL;
1782 ExecOnList(hwnd,
[907]1783 editor, WINDOWED | SEPARATE, NULL, dummy, NULL,
1784 pszSrcFile, __LINE__);
[551]1785 }
1786 else
1787 StartMLEEditor(dcd->hwndParent, 4, newfile, dcd->hwndFrame);
1788 pci = FindCnrRecord(hwnd, newfile, NULL, TRUE, FALSE, TRUE);
1789 if (pci && (INT) pci != -1)
1790 /* make sure that record shows in viewport */
1791 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1792 }
1793 }
1794 }
1795 }
1796 break;
[2]1797
[551]1798 case IDM_CONTEXTMENU:
1799 {
1800 PCNRITEM pci;
[2]1801
[551]1802 pci = (PCNRITEM) CurrentRecord(hwnd);
1803 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
1804 MPFROMP(pci));
1805 }
1806 break;
[2]1807
[551]1808 case IDM_MAXIMIZE:
1809 PostMsg(hwndMain, UM_MAXIMIZE, MPFROMLONG(dcd->hwndFrame), MPVOID);
1810 break;
[2]1811
[551]1812 case IDM_SHOWALLFILESCNR:
1813 StartSeeAll(HWND_DESKTOP, FALSE, dcd->directory);
1814 break;
[2]1815
[551]1816 case IDM_SHOWALLFILES:
1817 {
1818 PCNRITEM pci;
[2]1819
[551]1820 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1821 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1822 if (pci && (INT) pci != -1) {
[2]1823
[551]1824 static CHAR dirname[CCHMAXPATH];
[2]1825
[730]1826 strcpy(dirname, pci->pszFileName);
[551]1827 MakeValidDir(dirname);
1828 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1829 }
1830 }
1831 break;
[2]1832
[551]1833 case IDM_FINDINTREE:
1834 if (hwndTree)
1835 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory),
1836 MPFROMLONG(1L));
1837 break;
[2]1838
[551]1839 case IDM_BEGINEDIT:
1840 OpenEdit(hwnd);
1841 break;
[2]1842
[551]1843 case IDM_ENDEDIT:
1844 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1845 break;
[2]1846
[551]1847 case IDM_SHOWSELECT:
1848 QuickPopup(hwnd,
1849 dcd,
[877]1850 CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP), IDM_SELECTSUBMENU);
[551]1851 break;
[2]1852
[551]1853 case IDM_SHOWSORT:
[877]1854 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP),
[551]1855 IDM_SORTSUBMENU);
1856 break;
[2]1857
[551]1858 case IDM_VIEWORARC:
1859 {
1860 SWP swp;
1861 PCNRITEM pci;
[2]1862
[551]1863 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1864 MPFROMLONG(CMA_FIRST),
1865 MPFROMSHORT(CRA_CURSORED));
1866 if (pci && (INT) pci != -1) {
1867 WinQueryWindowPos(dcd->hwndFrame, &swp);
1868 DefaultViewKeys(hwnd,
1869 dcd->hwndFrame,
[730]1870 dcd->hwndParent, &swp, pci->pszFileName);
[551]1871 }
1872 }
1873 break;
[2]1874
[953]1875 case IDM_DIRCNRSETTINGS:
[551]1876 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
[917]1877 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_DIRCNRSETTINGS), mp2);
1878 else {
1879 WinDlgBox(HWND_DESKTOP,
1880 hwnd,
1881 CfgDlgProc,
1882 FM3ModHandle,
1883 CFG_FRAME,
1884 MPFROMLONG(IDM_DIRCNRSETTINGS));
1885 }
[551]1886 break;
[2]1887
[551]1888 case IDM_QTREE:
1889 case IDM_TREE:
1890 {
1891 CHAR newpath[CCHMAXPATH];
1892 APIRET rc;
1893 PCNRITEM pci;
[2]1894
[551]1895 if (SHORT1FROMMP(mp1) == IDM_TREE) {
1896 pci = (PCNRITEM) CurrentRecord(hwnd);
1897 if (pci && (INT) pci != -1)
[730]1898 strcpy(newpath, pci->pszFileName);
[551]1899 else
1900 strcpy(newpath, dcd->directory);
1901 }
1902 else
1903 strcpy(newpath, dcd->directory);
1904 MakeValidDir(newpath);
1905 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ObjCnrDlgProc,
1906 FM3ModHandle, QTREE_FRAME, MPFROMP(newpath));
1907 if (rc)
1908 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(newpath), MPVOID);
1909 }
1910 break;
[2]1911
[551]1912 case IDM_RESELECT:
1913 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1914 break;
[2]1915
[551]1916 case IDM_HELP:
1917 if (hwndHelp) {
1918 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1919 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
1920 else
1921 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
1922 }
1923 break;
[2]1924
[551]1925 case IDM_WINDOWDLG:
1926 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1927 PostMsg(dcd->hwndParent, UM_COMMAND,
1928 MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
1929 break;
[2]1930
[551]1931 case IDM_SORTSMARTNAME:
1932 case IDM_SORTNAME:
1933 case IDM_SORTFILENAME:
1934 case IDM_SORTSIZE:
1935 case IDM_SORTEASIZE:
1936 case IDM_SORTFIRST:
1937 case IDM_SORTLAST:
1938 case IDM_SORTLWDATE:
1939 case IDM_SORTLADATE:
1940 case IDM_SORTCRDATE:
1941 case IDM_SORTSUBJECT:
1942 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1943 case IDM_SORTDIRSFIRST:
1944 case IDM_SORTDIRSLAST:
1945 case IDM_SORTREVERSE:
1946 switch (SHORT1FROMMP(mp1)) {
1947 case IDM_SORTSUBJECT:
1948 dcd->sortFlags |= SORT_SUBJECT;
1949 break;
1950 case IDM_SORTSMARTNAME:
1951 case IDM_SORTFILENAME:
1952 dcd->sortFlags |= SORT_FILENAME;
1953 break;
1954 case IDM_SORTSIZE:
1955 dcd->sortFlags |= SORT_SIZE;
1956 break;
1957 case IDM_SORTEASIZE:
1958 dcd->sortFlags |= SORT_EASIZE;
1959 break;
1960 case IDM_SORTFIRST:
1961 dcd->sortFlags |= SORT_FIRSTEXTENSION;
1962 break;
1963 case IDM_SORTLAST:
1964 dcd->sortFlags |= SORT_LASTEXTENSION;
1965 break;
1966 case IDM_SORTLWDATE:
1967 dcd->sortFlags |= SORT_LWDATE;
1968 break;
1969 case IDM_SORTLADATE:
1970 dcd->sortFlags |= SORT_LADATE;
1971 break;
1972 case IDM_SORTCRDATE:
1973 dcd->sortFlags |= SORT_CRDATE;
1974 break;
1975 case IDM_SORTDIRSFIRST:
1976 if (dcd->sortFlags & SORT_DIRSFIRST)
1977 dcd->sortFlags &= (~SORT_DIRSFIRST);
1978 else {
1979 dcd->sortFlags |= SORT_DIRSFIRST;
1980 dcd->sortFlags &= (~SORT_DIRSLAST);
1981 }
1982 break;
1983 case IDM_SORTDIRSLAST:
1984 if (dcd->sortFlags & SORT_DIRSLAST)
1985 dcd->sortFlags &= (~SORT_DIRSLAST);
1986 else {
1987 dcd->sortFlags |= SORT_DIRSLAST;
1988 dcd->sortFlags &= (~SORT_DIRSFIRST);
1989 }
1990 break;
1991 case IDM_SORTREVERSE:
1992 if (dcd->sortFlags & SORT_REVERSE)
1993 dcd->sortFlags &= (~SORT_REVERSE);
1994 else
1995 dcd->sortFlags |= SORT_REVERSE;
1996 break;
1997 }
1998 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
1999 MPFROMLONG(dcd->sortFlags));
2000 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2001 DIR_SORT), dcd->sortFlags, FALSE);
2002 break;
[2]2003
[551]2004 case IDM_COLLECT:
2005 if (!Collector) {
[2]2006
[551]2007 HWND hwndC;
2008 SWP swp;
[2]2009
[551]2010 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2011 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2012 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2013 hwndC = StartCollector((fExternalCollector ||
2014 strcmp(realappname, FM3Str)) ?
2015 HWND_DESKTOP : dcd->hwndParent, 4);
2016 if (hwndC) {
2017 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
2018 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2019 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2020 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2021 SWP_SHOW | SWP_ZORDER);
2022 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) && fAutoTile &&
2023 !strcmp(realappname, FM3Str))
2024 TileChildren(dcd->hwndParent, TRUE);
2025 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
[771]2026 DosSleep(100); //05 Aug 07 GKY 250
[551]2027 }
2028 }
2029 else
2030 StartCollector(dcd->hwndParent, 4);
2031 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
2032 break;
[2]2033
[551]2034 case IDM_COLLECTOR:
[771]2035 DosSleep(32); //05 Aug 07 GKY 64
[551]2036 {
2037 CHAR **list;
[2]2038
[551]2039 list = BuildList(hwnd);
2040 if (list) {
2041 if (Collector) {
2042 if (!PostMsg(Collector,
2043 WM_COMMAND,
2044 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2045 FreeList(list);
2046 else if (fUnHilite)
[672]2047 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]2048 }
2049 else
2050 FreeList(list);
2051 }
2052 }
2053 break;
[2]2054
[551]2055 case IDM_UNDELETE:
2056 {
2057 PCNRITEM pci;
[1077]2058 CHAR path[CCHMAXPATH];
2059 HOBJECT hObject;
2060 HWND hwndDesktop;
[2]2061
[1077]2062 hObject = WinQueryObject("<XWP_TRASHCAN>");
2063 if (hObject != NULLHANDLE && fTrashCan) {
2064 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
[1041]2065 WinSetFocus(HWND_DESKTOP, hwndDesktop);
[1077]2066 WinOpenObject(hObject, 0, TRUE);
[551]2067 }
[1077]2068 else {
2069 pci = (PCNRITEM) CurrentRecord(hwnd);
2070 if (pci && (INT) pci != -1) {
2071 strcpy(path, pci->pszFileName);
2072 MakeValidDir(path);
2073 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2074 UNDEL_FRAME, MPFROMP(path));
2075 }
2076 }
[551]2077 }
2078 break;
[2]2079
[551]2080 case IDM_UNDELETESPEC:
[1077]2081 {
2082 HOBJECT hObject;
2083 HWND hwndDesktop;
[2]2084
[1077]2085 hObject = WinQueryObject("<XWP_TRASHCAN>");
2086 if (hObject != NULLHANDLE && fTrashCan) {
2087 hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
[1041]2088 WinSetFocus(HWND_DESKTOP, hwndDesktop);
[1077]2089 WinOpenObject(hObject, 0, TRUE);
2090 }
2091 else
[1041]2092 WinDlgBox(HWND_DESKTOP,
2093 hwnd,
2094 UndeleteDlgProc,
[1077]2095 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2096 }
2097 break;
[1041]2098
[551]2099 case IDM_RESORT:
[930]2100// WinSendMsg(hwnd,
2101// CM_SORTRECORD,
2102// MPFROMP(SortDirCnr),
2103// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
[551]2104 WinSendMsg(hwnd,
2105 CM_SORTRECORD,
2106 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2107 break;
[2]2108
[551]2109 case IDM_FILTER:
2110 {
2111 BOOL empty = FALSE;
2112 PCNRITEM pci;
2113 CHAR *p;
[2]2114
[551]2115 if (!*dcd->mask.szMask) {
2116 empty = TRUE;
2117 pci = (PCNRITEM) CurrentRecord(hwnd);
2118 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
[730]2119 p = strrchr(pci->pszFileName, '\\');
[551]2120 if (p) {
2121 p++;
2122 strcpy(dcd->mask.szMask, p);
2123 }
2124 }
2125 }
2126 *(dcd->mask.prompt) = 0;
[2]2127
[551]2128 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2129 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2130 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2131 else if (empty)
2132 *dcd->mask.szMask = 0;
2133 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2134 DIR_FILTER), &dcd->mask, FALSE);
2135 }
[1016]2136 break;
[2]2137
[958]2138 case IDM_UNHIDEALL:
[1016]2139 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
2140 break;
[958]2141
[551]2142 case IDM_HIDEALL:
2143 if (fAutoView && hwndMain)
2144 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2145 dcd->suspendview = 1;
2146 HideAll(hwnd);
2147 dcd->suspendview = 0;
2148 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2149 break;
[2]2150
[551]2151 case IDM_SELECTBOTH:
2152 case IDM_SELECTONE:
2153 case IDM_SELECTMORE:
2154 case IDM_SELECTNEWER:
2155 case IDM_SELECTOLDER:
2156 case IDM_SELECTBIGGER:
2157 case IDM_SELECTSMALLER:
2158 case IDM_DESELECTBOTH:
2159 case IDM_DESELECTONE:
2160 case IDM_DESELECTMORE:
2161 case IDM_DESELECTNEWER:
2162 case IDM_DESELECTOLDER:
2163 case IDM_DESELECTBIGGER:
2164 case IDM_DESELECTSMALLER:
2165 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2166 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2167 break;
2168 }
2169 case IDM_SELECTLIST:
2170 case IDM_SELECTALL:
2171 case IDM_DESELECTALL:
2172 case IDM_SELECTALLFILES:
2173 case IDM_DESELECTALLFILES:
2174 case IDM_SELECTALLDIRS:
2175 case IDM_DESELECTALLDIRS:
2176 case IDM_SELECTMASK:
2177 case IDM_DESELECTMASK:
2178 case IDM_INVERT:
2179 case IDM_SELECTCLIP:
2180 case IDM_DESELECTCLIP:
2181 {
2182 PCNRITEM pci;
[2]2183
[551]2184 pci = (PCNRITEM) CurrentRecord(hwnd);
2185 if ((INT) pci == -1)
2186 pci = NULL;
2187 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2188 if (pci) {
2189 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2190 pci->rc.flRecordAttr |= CRA_FILTERED;
2191 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2192 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2193 break;
2194 }
2195 }
2196 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2197 }
2198 break;
[2]2199
[551]2200 case IDM_RESCAN:
2201 DosEnterCritSec();
2202 dcd->stopflag++;
2203 DosExitCritSec();
2204 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2205 DosEnterCritSec();
2206 dcd->stopflag--;
2207 DosExitCritSec();
2208 }
2209 break;
[2]2210
[551]2211 case IDM_SHOWLNAMES:
2212 case IDM_SHOWSUBJECT:
2213 case IDM_SHOWEAS:
2214 case IDM_SHOWSIZE:
2215 case IDM_SHOWICON:
2216 case IDM_SHOWLWDATE:
2217 case IDM_SHOWLWTIME:
2218 case IDM_SHOWLADATE:
2219 case IDM_SHOWLATIME:
2220 case IDM_SHOWCRDATE:
2221 case IDM_SHOWCRTIME:
2222 case IDM_SHOWATTR:
2223 AdjustDetailsSwitches(hwnd,
2224 dcd->hwndLastMenu,
2225 SHORT1FROMMP(mp1),
[1065]2226 dcd->directory, NULL, &dcd->ds, FALSE);
[551]2227 break;
[2]2228
[551]2229 case IDM_TREEVIEW:
2230 case IDM_ICON:
2231 case IDM_TEXT:
2232 case IDM_DETAILS:
2233 case IDM_NAME:
2234 case IDM_MINIICONS:
2235 case IDM_DETAILSTITLES:
2236 {
2237 CNRINFO cnri;
[2]2238
[551]2239 memset(&cnri, 0, sizeof(CNRINFO));
2240 cnri.cb = sizeof(CNRINFO);
2241 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2242 MPFROMLONG(sizeof(CNRINFO)));
2243 switch (SHORT1FROMMP(mp1)) {
2244 case IDM_TREEVIEW:
2245 if (!(cnri.flWindowAttr & CV_TREE))
2246 dcd->lastattr = cnri.flWindowAttr;
2247 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2248 CV_DETAIL | CV_NAME | CA_TREELINE));
2249 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2250 if (!dcd->firsttree)
2251 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2252 break;
2253 case IDM_ICON:
2254 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2255 CV_DETAIL | CV_NAME | CA_TREELINE));
2256 cnri.flWindowAttr |= CV_ICON;
2257 break;
2258 case IDM_NAME:
2259 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2260 CV_DETAIL | CV_NAME | CA_TREELINE));
2261 cnri.flWindowAttr |= CV_NAME;
2262 break;
2263 case IDM_TEXT:
2264 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2265 CV_DETAIL | CV_NAME | CA_TREELINE));
2266 cnri.flWindowAttr |= CV_TEXT;
2267 break;
2268 case IDM_DETAILS:
2269 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2270 CV_DETAIL | CV_NAME | CA_TREELINE));
2271 cnri.flWindowAttr |= CV_DETAIL;
2272 break;
2273 case IDM_MINIICONS:
2274 if (cnri.flWindowAttr & CV_MINI)
2275 cnri.flWindowAttr &= (~CV_MINI);
2276 else
2277 cnri.flWindowAttr |= CV_MINI;
2278 break;
2279 case IDM_DETAILSTITLES:
2280 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2281 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2282 else
2283 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2284 break;
2285 }
2286 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2287 cnri.flWindowAttr |= CV_FLOW;
2288 dcd->flWindowAttr = cnri.flWindowAttr;
2289 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2290 MPFROMLONG(CMA_FLWINDOWATTR));
2291 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2292 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2293 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2294 DIR_VIEW), dcd->flWindowAttr);
2295 }
2296 break;
[2]2297
[551]2298 case IDM_SAVETOLIST:
2299 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2300 SAV_FRAME, MPFROMP(&hwnd));
2301 break;
[2]2302
[551]2303 case IDM_SIZES:
2304 {
2305 PCNRITEM pci;
2306 CHAR path[CCHMAXPATH];
[2]2307
[551]2308 pci = (PCNRITEM) CurrentRecord(hwnd);
2309 if (pci && (INT) pci != -1)
[730]2310 strcpy(path, pci->pszFileName);
[551]2311 else
2312 strcpy(path, dcd->directory);
2313 MakeValidDir(path);
2314 WinDlgBox(HWND_DESKTOP,
2315 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2316 }
2317 break;
[2]2318
[551]2319 case IDM_MKDIR:
2320 {
[907]2321 PCNRITEM pci;
2322 BOOL saved;
[2]2323
[907]2324 saved = fSelectedAlways;
2325 fSelectedAlways = FALSE;
2326 pci = (PCNRITEM)CurrentRecord(hwnd);
2327 // 01 Oct 07 SHL Make below selected directory or in current directory
[551]2328 PMMkDir(dcd->hwndParent,
[907]2329 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2330 FALSE);
2331 fSelectedAlways = saved;
[551]2332 }
2333 break;
[2]2334
[551]2335 case IDM_SWITCH:
2336 if (mp2) {
2337 strcpy(dcd->previous, dcd->directory);
[1009]2338 strcpy(dcd->directory, (CHAR *)mp2);
[551]2339 DosEnterCritSec();
2340 dcd->stopflag++;
2341 DosExitCritSec();
2342 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2343 strcpy(dcd->directory, dcd->previous);
2344 DosEnterCritSec();
2345 dcd->stopflag--;
2346 DosExitCritSec();
2347 }
2348 else if (*dcd->directory) {
2349 if (hwndMain)
2350 WinSendMsg(hwndMain,
2351 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2352 else
2353 add_udir(FALSE, dcd->directory);
2354 }
2355 }
2356 break;
[2]2357
[551]2358 case IDM_PARENT:
2359 {
2360 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
[2]2361
[551]2362 strcpy(tempname1, dcd->directory);
2363 if (tempname1[strlen(tempname1) - 1] != '\\')
2364 strcat(tempname1, "\\");
2365 strcat(tempname1, "..");
2366 DosError(FERR_DISABLEHARDERR);
2367 if (!DosQueryPathInfo(tempname1,
2368 FIL_QUERYFULLNAME,
2369 tempname2, sizeof(tempname2))) {
2370 if (stricmp(dcd->directory, tempname2)) {
2371 strcpy(dcd->previous, dcd->directory);
2372 strcpy(dcd->directory, tempname2);
2373 DosEnterCritSec();
2374 dcd->stopflag++;
2375 DosExitCritSec();
2376 if (!PostMsg(dcd->hwndObject,
2377 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2378 strcpy(dcd->directory, dcd->previous);
2379 DosEnterCritSec();
2380 dcd->stopflag--;
2381 DosExitCritSec();
2382 }
2383 else if (*dcd->directory) {
2384 if (hwndMain)
2385 WinSendMsg(hwndMain,
2386 UM_SETUSERLISTNAME,
2387 MPFROMP(dcd->directory), MPVOID);
2388 else
2389 add_udir(FALSE, dcd->directory);
2390 }
2391 }
2392 }
2393 }
2394 break;
[2]2395
[551]2396 case IDM_PREVIOUS:
2397 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
[2]2398
[551]2399 CHAR tempname[CCHMAXPATH];
[2]2400
[551]2401 if (IsValidDir(dcd->previous)) {
2402 strcpy(tempname, dcd->directory);
2403 strcpy(dcd->directory, dcd->previous);
2404 strcpy(dcd->previous, tempname);
2405 DosEnterCritSec();
2406 dcd->stopflag++;
2407 DosExitCritSec();
2408 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2409 strcpy(dcd->directory, dcd->previous);
2410 DosEnterCritSec();
2411 dcd->stopflag--;
2412 DosExitCritSec();
2413 }
2414 else if (*dcd->directory) {
2415 if (hwndMain)
2416 WinSendMsg(hwndMain,
2417 UM_SETUSERLISTNAME,
2418 MPFROMP(dcd->directory), MPVOID);
2419 else
2420 add_udir(FALSE, dcd->directory);
2421 }
2422 }
2423 else
2424 *dcd->previous = 0;
2425 }
2426 break;
[2]2427
[551]2428 case IDM_WALKDIR:
2429 {
2430 CHAR newdir[CCHMAXPATH];
[2]2431
[551]2432 strcpy(newdir, dcd->directory);
2433 if (!WinDlgBox(HWND_DESKTOP,
2434 dcd->hwndParent,
2435 WalkAllDlgProc,
2436 FM3ModHandle,
2437 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2438 break;
2439 if (stricmp(newdir, dcd->directory)) {
2440 strcpy(dcd->previous, dcd->directory);
2441 strcpy(dcd->directory, newdir);
2442 DosEnterCritSec();
2443 dcd->stopflag++;
2444 DosExitCritSec();
2445 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2446 strcpy(dcd->directory, dcd->previous);
2447 DosEnterCritSec();
2448 dcd->stopflag--;
2449 DosExitCritSec();
2450 }
2451 else if (*dcd->directory) {
2452 if (hwndMain)
2453 WinSendMsg(hwndMain,
2454 UM_SETUSERLISTNAME,
2455 MPFROMP(dcd->directory), MPVOID);
2456 else
2457 add_udir(FALSE, dcd->directory);
2458 }
2459 }
2460 }
2461 break;
[2]2462
[551]2463 case IDM_OPENICONME:
2464 OpenObject(dcd->directory, "ICON", dcd->hwndFrame);
2465 break;
2466 case IDM_OPENDETAILSME:
2467 OpenObject(dcd->directory, "DETAILS", dcd->hwndFrame);
2468 break;
2469 case IDM_OPENTREEME:
2470 OpenObject(dcd->directory, "TREE", dcd->hwndFrame);
2471 break;
2472 case IDM_OPENSETTINGSME:
2473 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2474 break;
[2]2475
[551]2476 case IDM_DOITYOURSELF:
2477 case IDM_UPDATE:
2478 case IDM_OPENWINDOW:
2479 case IDM_OPENSETTINGS:
2480 case IDM_OPENDEFAULT:
2481 case IDM_OPENICON:
2482 case IDM_OPENDETAILS:
2483 case IDM_OPENTREE:
2484 case IDM_OBJECT:
2485 case IDM_SHADOW:
2486 case IDM_SHADOW2:
2487 case IDM_DELETE:
2488 case IDM_PERMDELETE:
2489 case IDM_PRINT:
2490 case IDM_ATTRS:
2491 case IDM_INFO:
2492 case IDM_COPY:
2493 case IDM_MOVE:
2494 case IDM_WPSMOVE:
2495 case IDM_WPSCOPY:
2496 case IDM_WILDCOPY:
2497 case IDM_WILDMOVE:
2498 case IDM_RENAME:
2499 case IDM_COMPARE:
2500 case IDM_EAS:
2501 case IDM_SUBJECT:
2502 case IDM_VIEW:
2503 case IDM_VIEWTEXT:
2504 case IDM_VIEWBINARY:
2505 case IDM_VIEWARCHIVE:
2506 case IDM_EDIT:
2507 case IDM_EDITTEXT:
2508 case IDM_EDITBINARY:
2509 case IDM_SAVETOCLIP:
2510 case IDM_APPENDTOCLIP:
2511 case IDM_ARCHIVE:
2512 case IDM_ARCHIVEM:
2513 case IDM_EXTRACT:
2514 case IDM_MCIPLAY:
2515 case IDM_COLLECTFROMFILE:
2516 case IDM_UUDECODE:
2517 case IDM_MERGE:
2518 {
2519 LISTINFO *li;
2520 ULONG action = UM_ACTION;
2521 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2522 if (li) {
2523 li->type = SHORT1FROMMP(mp1);
2524 li->hwnd = hwnd;
2525 li->list = BuildList(hwnd);
2526 switch (SHORT1FROMMP(mp1)) {
2527 case IDM_WILDMOVE:
2528 case IDM_WILDCOPY:
2529 case IDM_MOVE:
2530 case IDM_COPY:
2531 case IDM_WPSMOVE:
2532 case IDM_WPSCOPY:
2533 break;
2534 default:
2535 strcpy(li->targetpath, dcd->directory);
2536 break;
2537 }
2538 if (li->list) {
2539 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2540 if (!Collector) {
[2]2541
[551]2542 HWND hwndC;
2543 SWP swp;
[2]2544
[551]2545 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2546 !fAutoTile &&
2547 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2548 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2549 hwndC = StartCollector((fExternalCollector ||
2550 strcmp(realappname, FM3Str)) ?
2551 HWND_DESKTOP : dcd->hwndParent, 4);
2552 if (hwndC) {
2553 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2554 !fAutoTile && (!fExternalCollector &&
2555 !strcmp(realappname, FM3Str)))
2556 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2557 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2558 SWP_SHOW | SWP_ZORDER);
2559 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2560 fAutoTile && !strcmp(realappname, FM3Str))
2561 TileChildren(dcd->hwndParent, TRUE);
2562 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2563 SWP_ACTIVATE);
[771]2564 DosSleep(100); //05 Aug 07 GKY 250
[551]2565 }
2566 }
2567 else
2568 StartCollector(dcd->hwndParent, 4);
2569 }
2570 switch (SHORT1FROMMP(mp1)) {
2571 case IDM_APPENDTOCLIP:
2572 case IDM_SAVETOCLIP:
2573 case IDM_ARCHIVE:
2574 case IDM_ARCHIVEM:
2575 case IDM_DELETE:
2576 case IDM_PERMDELETE:
2577 case IDM_ATTRS:
2578 case IDM_PRINT:
2579 case IDM_SHADOW:
2580 case IDM_SHADOW2:
2581 case IDM_OBJECT:
2582 case IDM_VIEW:
2583 case IDM_VIEWTEXT:
2584 case IDM_VIEWBINARY:
2585 case IDM_EDIT:
2586 case IDM_EDITTEXT:
2587 case IDM_EDITBINARY:
2588 case IDM_MCIPLAY:
2589 case IDM_UPDATE:
2590 case IDM_DOITYOURSELF:
2591 case IDM_INFO:
2592 case IDM_EAS:
2593 action = UM_MASSACTION;
2594 break;
2595 }
2596 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2597 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2598 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2599 *li->targetpath = 0;
2600 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2601 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2602 FreeListInfo(li);
2603 }
2604 else if (fUnHilite)
[672]2605 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]2606 }
2607 else
[1039]2608 free(li);
[551]2609 }
2610 }
2611 break;
[2]2612
[551]2613 case IDM_DRIVESMENU:
2614 if (!hwndMain)
2615 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2616 break;
[2]2617
[551]2618 default:
2619 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2620 return 0;
2621 else {
2622 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2623 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
[2]2624
[551]2625 register INT x;
[2]2626
[551]2627 if (!cmdloaded)
2628 load_commands();
2629 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2630 if (x >= 0) {
2631 x++;
2632 RunCommand(hwnd, x);
2633 if (fUnHilite)
[672]2634 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]2635 }
2636 }
2637 }
2638 break;
[2]2639 }
[551]2640 }
2641 return 0;
[2]2642
[551]2643 case UM_FIXCNRMLE:
2644 case UM_FIXEDITNAME:
2645 return CommonCnrProc(hwnd, msg, mp1, mp2);
[2]2646
[551]2647 case UM_FILESMENU:
2648 {
2649 PCNRITEM pci;
2650 HWND menuHwnd = (HWND) 0;
[2]2651
[551]2652 pci = (PCNRITEM) CurrentRecord(hwnd);
2653 if (pci && (INT) pci != -1) {
2654 if (pci->attrFile & FILE_DIRECTORY) {
[875]2655 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
[930]2656// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
[551]2657 }
2658 else
[875]2659 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
[2]2660 }
[551]2661 return MRFROMLONG(menuHwnd);
2662 }
[2]2663
[551]2664 case WM_CONTROL:
2665 DosError(FERR_DISABLEHARDERR);
2666 if (dcd) {
2667 switch (SHORT2FROMMP(mp1)) {
2668 case CN_COLLAPSETREE:
2669 case CN_EXPANDTREE:
2670 {
2671 PCNRITEM pci = (PCNRITEM) mp2;
[2]2672
[551]2673 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
[730]2674 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
[551]2675 struct
[275]2676 {
[551]2677 ULONG serial;
2678 CHAR volumelength;
2679 CHAR volumelabel[CCHMAXPATH];
2680 }
2681 volser;
2682 APIRET rc;
[2]2683
[551]2684 memset(&volser, 0, sizeof(volser));
2685 DosError(FERR_DISABLEHARDERR);
[907]2686 // fixme?
[730]2687 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
[551]2688 FSIL_VOLSER, &volser, sizeof(volser));
2689 if (rc) {
2690 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[552]2691 GetPString(IDS_CANTFINDDIRTEXT),
[730]2692 pci->pszFileName);
[552]2693 DosBeep(250,100);
[730]2694 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
[551]2695 UnFlesh(hwnd, pci);
2696 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2697 }
2698 else {
2699 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2700 !volser.serial ||
[907]2701 driveserial[toupper(*pci->pszFileName) - 'A'] !=
[551]2702 volser.serial)
2703 UnFlesh(hwnd, pci);
2704 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2705 (!volser.serial ||
[730]2706 driveserial[toupper(*pci->pszFileName) - 'A'] !=
[551]2707 volser.serial)) {
2708 if (Flesh(hwnd, pci) &&
2709 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2710 !dcd->suspendview && fTopDir)
2711 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2712 }
[730]2713 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
[551]2714 }
2715 }
2716 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2717 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2718 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2719 }
2720 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2721 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2722 }
2723 }
2724 break;
[2]2725
2726/*
[618]2727 case CN_PICKUP:
2728 return PickUp(hwnd,dcd->hwndObject,mp2);
[2]2729*/
2730
[551]2731 case CN_CONTEXTMENU:
2732 {
2733 PCNRITEM pci = (PCNRITEM) mp2;
[2]2734
[551]2735 if (pci) {
2736 WinSendMsg(hwnd,
2737 CM_SETRECORDEMPHASIS,
2738 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
[907]2739 MarkAll(hwnd, FALSE, FALSE, TRUE);
2740 if (pci->attrFile & FILE_DIRECTORY)
[875]2741 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
[551]2742 else
[875]2743 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
[551]2744 }
2745 else {
[877]2746 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
[551]2747 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2748 WinSendMsg(hwnd,
2749 CM_SETRECORDEMPHASIS,
2750 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2751 dcd->cnremphasized = TRUE;
2752 }
2753 }
2754 if (dcd->hwndLastMenu) {
2755 if (dcd->hwndLastMenu == DirCnrMenu) {
2756 if (dcd->flWindowAttr & CV_MINI)
2757 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2758 }
2759 if (dcd->hwndLastMenu == DirMenu)
2760 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2761 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2762 if (dcd->cnremphasized) {
2763 WinSendMsg(hwnd,
2764 CM_SETRECORDEMPHASIS,
2765 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2766 dcd->cnremphasized = TRUE;
2767 }
2768 MarkAll(hwnd, TRUE, FALSE, TRUE);
2769 }
2770 }
2771 }
2772 break;
[2]2773
[551]2774 case CN_DROPHELP:
2775 if (mp2) {
[2]2776
[551]2777 PDRAGINFO pDInfo;
2778 PCNRITEM pci;
2779 ULONG numitems;
2780 USHORT usOperation;
[2]2781
[551]2782 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2783 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2784 if (!DrgAccessDraginfo(pDInfo)) {
2785 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2786 GetPString(IDS_DROPERRORTEXT));
2787 }
[618]2788 else {
2789 numitems = DrgQueryDragitemCount(pDInfo);
2790 usOperation = pDInfo->usOperation;
2791 FreeDragInfoData(hwnd, pDInfo);
2792 saymsg(MB_ENTER | MB_ICONASTERISK,
2793 hwnd,
2794 GetPString(IDS_DROPHELPHDRTEXT),
2795 GetPString(IDS_DROPHELPTEXT),
2796 numitems,
2797 &"s"[numitems == 1L],
2798 pci ? NullStr : GetPString(IDS_NOTEXT),
2799 pci ? NullStr : " ",
[730]2800 pci ? pci->pszFileName : NullStr,
[618]2801 pci ? " " : NullStr,
2802 GetPString((usOperation == DO_COPY) ?
2803 IDS_COPYTEXT :
2804 (usOperation == DO_LINK) ?
2805 IDS_LINKTEXT : IDS_MOVETEXT));
2806 }
[551]2807 }
2808 return 0;
[2]2809
[551]2810 case CN_DRAGLEAVE:
2811 return 0;
[2]2812
[551]2813 case CN_DRAGAFTER:
2814 case CN_DRAGOVER:
2815 if (mp2) {
[2]2816
[618]2817 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2818 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
[551]2819 PCNRITEM pci;
2820 USHORT uso;
[2]2821
[551]2822 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2823 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
[907]2824 if (!DrgAccessDraginfo(pDInfo)) {
2825 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2826 "DrgAccessDraginfo");
[618]2827 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
[907]2828 }
2829 if (*dcd->directory &&
[687]2830 (driveflags[toupper(*dcd->directory) - 'A'] &
2831 DRIVE_NOTWRITEABLE)) {
[551]2832 DrgFreeDraginfo(pDInfo);
2833 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
[618]2834 DO_LINK); /* (compare) only */
[551]2835 }
2836 if (pci) {
2837 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2838 DrgFreeDraginfo(pDInfo);
2839 return (MRFROM2SHORT(DOR_NODROP, 0));
2840 }
2841 uso = pDInfo->usOperation;
2842 if (uso == DO_DEFAULT)
[618]2843 uso = fCopyDefault ? DO_COPY : DO_MOVE;
[551]2844 if (!(pci->attrFile & FILE_DIRECTORY)) {
2845 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2846 DrgFreeDraginfo(pDInfo);
2847 return MRFROM2SHORT(DOR_NODROP, 0);
2848 }
2849 if (uso != DO_LINK &&
[730]2850 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
[551]2851 DRIVE_NOTWRITEABLE)) {
[2]2852
[551]2853 ARC_TYPE *info = NULL;
[2]2854
[551]2855 if (!fQuickArcFind &&
[730]2856 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
[551]2857 DRIVE_SLOW))
[730]2858 info = find_type(pci->pszFileName, NULL);
[551]2859 else
[730]2860 info = quick_find_type(pci->pszFileName, NULL);
[551]2861 if (!info || ((uso == DO_MOVE && !info->move) ||
2862 (uso == DO_COPY && !info->create))) {
2863 DrgFreeDraginfo(pDInfo);
2864 return MRFROM2SHORT(DOR_NODROP, 0);
2865 }
2866 }
2867 }
2868 }
[275]2869
[551]2870 /* Access DRAGITEM index to DRAGITEM
2871 * Check valid rendering mechanisms and data
2872 */
2873 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2874 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
2875 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
2876 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
2877 DrgFreeDraginfo(pDInfo);
2878 if (driveflags[toupper(*dcd->directory) - 'A'] &
2879 DRIVE_NOTWRITEABLE)
2880 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2881 if (toupper(*dcd->directory) < 'C')
2882 return MRFROM2SHORT(DOR_DROP, DO_COPY);
[618]2883 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
[551]2884 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2885 }
[618]2886 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[551]2887 }
[618]2888 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
[2]2889
[551]2890 case CN_INITDRAG:
2891 {
2892 BOOL wasemphasized = FALSE;
2893 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2894 PCNRITEM pci;
[2]2895
[551]2896 if (pcd) {
2897 pci = (PCNRITEM) pcd->pRecord;
2898 if (pci) {
2899 if ((INT) pci == -1)
2900 pci = NULL;
2901 else if (pci->rc.flRecordAttr & CRA_SELECTED)
2902 wasemphasized = TRUE;
2903 }
2904 else if (!*dcd->directory) {
2905 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2906 break;
2907 }
2908 else if (IsRoot(dcd->directory)) {
[618]2909 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
2910 GetPString(IDS_CANTDRAGROOTDIR));
[551]2911 break;
2912 }
2913 if (hwndStatus2) {
2914 if (pci)
2915 WinSetWindowText(hwndStatus2,
2916 GetPString(IDS_DRAGFILEOBJTEXT));
2917 else
2918 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
2919 }
2920 if (DoFileDrag(hwnd,
2921 dcd->hwndObject,
2922 mp2,
2923 NULL,
[618]2924 pci ? NULL : dcd->directory,
2925 pci ? TRUE : FALSE)) {
[672]2926 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
2927 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
[618]2928 }
[551]2929 }
2930 if (hwndStatus2) {
2931 WinSetFocus(HWND_DESKTOP, hwnd);
2932 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2933 }
2934 }
2935 }
2936 return 0;
[2]2937
[551]2938 case CN_DROP:
2939 if (mp2) {
[2]2940
[551]2941 LISTINFO *li;
2942 ULONG action = UM_ACTION;
[2]2943
[907]2944 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
2945 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
[551]2946 if (li) {
2947 if (li->list && li->list[0] && IsRoot(li->list[0]))
2948 li->type = DO_LINK;
2949 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
[2]2950
[551]2951 CHECKLIST cl;
[2]2952
[551]2953 memset(&cl, 0, sizeof(cl));
2954 cl.size = sizeof(cl);
2955 cl.flags = li->type;
2956 cl.list = li->list;
2957 cl.cmd = li->type;
2958 cl.prompt = li->targetpath;
2959 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2960 DropListProc, FM3ModHandle,
[618]2961 DND_FRAME, MPFROMP(&cl));
2962 if (li->type == DID_ERROR)
2963 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2964 "Drag & Drop Dialog");
2965 if (!li->type) {
[551]2966 FreeListInfo(li);
2967 return 0;
2968 }
2969 li->list = cl.list;
[618]2970 if (!li->list || !li->list[0]) {
[551]2971 FreeListInfo(li);
2972 return 0;
2973 }
2974 }
2975 switch (li->type) {
2976 case DND_LAUNCH:
2977 strcat(li->targetpath, " %a");
2978 ExecOnList(dcd->hwndParent, li->targetpath,
[907]2979 PROMPT | WINDOWED, NULL, li->list, NULL,
2980 pszSrcFile, __LINE__);
[551]2981 FreeList(li->list);
2982 li->list = NULL;
2983 break;
2984 case DO_LINK:
2985 if (fLinkSetsIcon) {
2986 li->type = IDM_SETICON;
2987 action = UM_MASSACTION;
2988 }
2989 else
2990 li->type = IDM_COMPARE;
2991 break;
2992 case DND_EXTRACT:
2993 if (*li->targetpath && !IsFile(li->targetpath))
2994 li->type = IDM_EXTRACT;
2995 break;
2996 case DND_MOVE:
2997 li->type = IDM_MOVE;
2998 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2999 action = UM_MASSACTION;
3000 li->type = IDM_ARCHIVEM;
3001 }
3002 break;
3003 case DND_WILDMOVE:
3004 li->type = IDM_WILDMOVE;
3005 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3006 action = UM_MASSACTION;
3007 li->type = IDM_ARCHIVEM;
3008 }
3009 break;
3010 case DND_OBJECT:
3011 li->type = IDM_OBJECT;
3012 action = UM_MASSACTION;
3013 break;
3014 case DND_SHADOW:
3015 li->type = IDM_SHADOW;
3016 action = UM_MASSACTION;
3017 break;
3018 case DND_COMPARE:
3019 li->type = IDM_COMPARE;
3020 break;
3021 case DND_SETICON:
3022 action = UM_MASSACTION;
3023 li->type = IDM_SETICON;
3024 break;
3025 case DND_COPY:
3026 li->type = IDM_COPY;
3027 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3028 action = UM_MASSACTION;
3029 li->type = IDM_ARCHIVE;
3030 }
3031 break;
3032 case DND_WILDCOPY:
3033 li->type = IDM_WILDCOPY;
3034 if (*li->targetpath && IsFile(li->targetpath) == 1) {
3035 action = UM_MASSACTION;
3036 li->type = IDM_ARCHIVE;
3037 }
3038 break;
3039 default:
3040 if (*li->arcname && li->info) {
3041 action = UM_MASSACTION;
3042 li->type =
3043 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
3044 }
3045 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
3046 action = UM_MASSACTION;
3047 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
3048 }
3049 else
3050 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
3051 break;
3052 }
3053 if (!li->list || !li->list[0])
3054 FreeListInfo(li);
3055 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
3056 FreeListInfo(li);
3057 else {
[2]3058
[551]3059 USHORT usop = 0;
[2]3060
[551]3061 switch (li->type) {
3062 case IDM_COPY:
3063 case IDM_WILDCOPY:
3064 usop = DO_COPY;
3065 break;
3066 case IDM_MOVE:
3067 case IDM_WILDMOVE:
3068 case IDM_ARCHIVEM:
3069 usop = DO_MOVE;
3070 break;
3071 }
3072 if (usop)
3073 return MRFROM2SHORT(DOR_DROP, usop);
3074 }
3075 }
3076 }
3077 return 0;
[2]3078
[551]3079 case CN_ENDEDIT:
3080 case CN_BEGINEDIT:
3081 {
3082 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3083 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[2]3084
[551]3085 if (pfi || pci) {
[2]3086
[551]3087 MRESULT mre;
[2]3088
[551]3089 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3090 if (mre != (MRESULT) - 1)
3091 return mre;
3092 }
3093 else if (!pfi && !pci)
3094 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3095 }
3096 return 0;
[2]3097
[551]3098 case CN_REALLOCPSZ:
3099 {
3100 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3101 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3102 HWND hwndMLE;
3103 static CHAR szData[CCHMAXPATH];
[689]3104 CHAR testname[CCHMAXPATH];
[2]3105
[551]3106 if (!pci && !pfi) {
3107 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3108 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3109 chop_at_crnl(szData);
3110 bstrip(szData);
3111 if (*szData) {
3112 if (!DosQueryPathInfo(szData,
3113 FIL_QUERYFULLNAME,
3114 testname, sizeof(testname))) {
3115 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3116 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3117 }
3118 }
3119 }
3120 }
3121 else {
[2]3122
[551]3123 MRESULT mre;
[2]3124
[551]3125 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3126 if (mre != (MRESULT) - 1)
3127 return mre;
3128 }
3129 }
3130 return 0;
[2]3131
[551]3132 case CN_EMPHASIS:
3133 if (!mp2)
3134 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3135 else {
3136 PNOTIFYRECORDEMPHASIS pre = mp2;
3137 PCNRITEM pci;
3138 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
[2]3139
[762]3140 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
[551]3141 if (!pci) {
3142 if (hwndStatus2)
3143 WinSetWindowText(hwndStatus2, NullStr);
3144 if (fMoreButtons) {
3145 WinSetWindowText(hwndName, NullStr);
3146 WinSetWindowText(hwndDate, NullStr);
3147 WinSetWindowText(hwndAttr, NullStr);
3148 }
3149 if (hwndMain)
3150 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3151 break;
3152 }
3153 if (pre->fEmphasisMask & CRA_SELECTED) {
3154 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3155 dcd->selectedbytes += (pci->cbFile + pci->easize);
3156 dcd->selectedfiles++;
3157 }
3158 else if (dcd->selectedfiles) {
3159 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3160 dcd->selectedfiles--;
3161 }
3162 if (!dcd->suspendview) {
3163 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3164 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3165 sprintf(s, "%s / %s", tf, tb);
3166 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3167 }
3168 }
3169 if (!dcd->suspendview && hwndMain &&
3170 (pre->fEmphasisMask & CRA_CURSORED) &&
3171 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3172 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
[730]3173 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
[551]3174 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3175 else
3176 WinSendMsg(hwndMain,
[730]3177 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[551]3178 }
3179 if (!dcd->suspendview &&
3180 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3181 if (pre->fEmphasisMask & CRA_CURSORED) {
3182 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3183 if (fSplitStatus && hwndStatus2) {
3184 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3185 if (!fMoreButtons) {
3186 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3187 tb, pci->date.year,
3188 pci->date.month, pci->date.day, pci->time.hours,
3189 pci->time.minutes, pci->time.seconds,
3190 pci->pszDispAttr, pci->pszFileName);
3191 }
3192 else {
3193 *tf = 0;
3194 if (pci->cbFile + pci->easize > 1024) {
3195 CommaFmtULL(tf, sizeof(tf),
3196 pci->cbFile + pci->easize, 'K');
3197 }
3198 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3199 tb,
3200 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3201 }
3202 WinSetWindowText(hwndStatus2, s);
3203 }
3204 if (fMoreButtons) {
3205 WinSetWindowText(hwndName, pci->pszFileName);
3206 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
3207 pci->date.year, pci->date.month,
3208 pci->date.day, pci->time.hours, pci->time.minutes,
3209 pci->time.seconds);
3210 WinSetWindowText(hwndDate, s);
3211 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3212 }
3213 }
3214 }
3215 }
3216 }
3217 break;
[2]3218
[551]3219 case CN_ENTER:
3220 if (mp2) {
[2]3221
[551]3222 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
[847]3223 FILEFINDBUF3 ffb;
[551]3224 HDIR hDir = HDIR_CREATE;
[761]3225 ULONG nm = 1;
[551]3226 APIRET status = 0;
[2]3227
[551]3228 SetShiftState();
3229 if (pci) {
3230 if (pci->rc.flRecordAttr & CRA_INUSE)
3231 break;
3232 DosError(FERR_DISABLEHARDERR);
[847]3233 status = DosFindFirst(pci->pszFileName,
[838]3234 &hDir,
3235 FILE_NORMAL | FILE_DIRECTORY |
3236 FILE_ARCHIVED | FILE_READONLY |
3237 FILE_HIDDEN | FILE_SYSTEM,
[847]3238 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
[551]3239 priority_bumped();
3240 if (!status) {
3241 DosFindClose(hDir);
3242 if (ffb.attrFile & FILE_DIRECTORY) {
3243 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3244 PostMsg(hwnd,
3245 WM_COMMAND,
3246 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3247 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3248 (KC_CTRL | KC_SHIFT))
[730]3249 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
[551]3250 else if (shiftstate & KC_CTRL)
[730]3251 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
[551]3252 else if (shiftstate & KC_SHIFT) {
[2]3253
[551]3254 HWND hwndDir;
[2]3255
[551]3256 hwndDir = OpenDirCnr((HWND) 0,
3257 dcd->hwndParent,
3258 dcd->hwndFrame,
[730]3259 FALSE, pci->pszFileName);
[551]3260 if (hwndDir) {
3261 if (fMinOnOpen)
3262 WinSetWindowPos(dcd->hwndFrame,
3263 HWND_BOTTOM,
3264 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3265 if (fAutoTile)
3266 TileChildren(dcd->hwndParent, TRUE);
3267 WinSetWindowPos(hwndDir,
3268 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3269 }
3270 }
3271 else {
3272 strcpy(dcd->previous, dcd->directory);
[730]3273 strcpy(dcd->directory, pci->pszFileName);
[551]3274 DosEnterCritSec();
3275 dcd->stopflag++;
3276 DosExitCritSec();
3277 if (!PostMsg(dcd->hwndObject,
[841]3278 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
[551]3279 DosEnterCritSec();
3280 dcd->stopflag--;
3281 DosExitCritSec();
3282 }
3283 else if (*dcd->directory) {
3284 if (hwndMain)
3285 WinSendMsg(hwndMain,
3286 UM_SETUSERLISTNAME,
3287 MPFROMP(dcd->directory), MPVOID);
3288 else
3289 add_udir(FALSE, dcd->directory);
3290 }
3291 }
3292 }
3293 else {
[2]3294
[551]3295 SWP swp;
[2]3296
[551]3297 WinQueryWindowPos(dcd->hwndFrame, &swp);
3298 WinSendMsg(hwnd,
3299 CM_SETRECORDEMPHASIS,
3300 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3301 DefaultViewKeys(hwnd,
3302 dcd->hwndFrame,
[730]3303 dcd->hwndParent, &swp, pci->pszFileName);
[551]3304 WinSendMsg(hwnd,
3305 CM_SETRECORDEMPHASIS,
3306 MPFROMP(pci),
3307 MPFROM2SHORT(FALSE,
3308 CRA_INUSE |
3309 ((fUnHilite) ? CRA_SELECTED : 0)));
3310 }
3311 }
3312 else {
3313 if (!*dcd->directory || IsValidDir(dcd->directory)) {
[730]3314 NotifyError(pci->pszFileName, status);
[751]3315 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
[551]3316 if (hwndStatus)
3317 WinSetWindowText(hwndStatus,
3318 GetPString(IDS_RESCANSUGGESTEDTEXT));
3319 }
3320 else {
3321 DosEnterCritSec();
3322 dcd->stopflag++;
3323 DosExitCritSec();
3324 if (!PostMsg(dcd->hwndObject,
3325 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3326 DosEnterCritSec();
3327 dcd->stopflag--;
3328 DosExitCritSec();
3329 }
3330 else if (*dcd->directory) {
3331 if (hwndMain)
3332 WinSendMsg(hwndMain,
3333 UM_SETUSERLISTNAME,
3334 MPFROMP(dcd->directory), MPVOID);
3335 else
3336 add_udir(FALSE, dcd->directory);
3337 }
3338 }
3339 }
3340 }
3341 else if (*dcd->directory)
3342 OpenObject(dcd->directory, Default, hwnd);
[787]3343 } // CN_ENTER
[551]3344 break;
[787]3345 } // switch mp1
[551]3346 break;
[787]3347 } // if dcd
[551]3348 return 0;
[2]3349
[551]3350 case UM_LOADFILE:
3351 if (dcd && mp2) {
[2]3352
[1037]3353 HWND hwnd;
3354
3355 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
[1077]3356 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
3357 (CHAR *)mp2, dcd->hwndFrame);
[1037]3358 else
[1077]3359 hwnd = StartMLEEditor(dcd->hwndParent,
3360 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
[1009]3361 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
[1037]3362 return MRFROMLONG(hwnd);
[551]3363 }
3364 return 0;
[2]3365
[551]3366 case WM_SAVEAPPLICATION:
3367 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
[2]3368
[551]3369 SWP swp;
[2]3370
[551]3371 WinQueryWindowPos(dcd->hwndFrame, &swp);
3372 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3373 PrfWriteProfileData(fmprof,
3374 appname, "VDirSizePos", &swp, sizeof(swp));
3375 }
3376 break;
[2]3377
[551]3378 case WM_CLOSE:
3379 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3380 if (LastDir == hwnd)
3381 LastDir = (HWND) 0;
3382 if (dcd) {
3383 dcd->stopflag++;
3384 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
[1016]3385 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
[1012]3386 if (dcd->hwndObject) {
[1016]3387 // Ensure object window destroy does not attempt duplicate clean up
3388 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3389 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3390 Win_Error(dcd->hwndObject, hwnd, pszSrcFile, __LINE__, "hwndObject WinPostMsg failed");
[2]3391 }
[1012]3392 if (dcd->hwndRestore)
[1016]3393 WinSetWindowPos(dcd->hwndRestore,
3394 HWND_TOP,
3395 0,
3396 0,
3397 0,
3398 0,
3399 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
[1012]3400 FreeList(dcd->lastselection);
[1039]3401 free(dcd);
[1012]3402 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3403 DosPostEventSem(CompactSem);
[551]3404 }
3405 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3406 QW_PARENT));
3407 return 0;
[2]3408
[551]3409 case WM_DESTROY:
3410 if (DirMenu)
3411 WinDestroyWindow(DirMenu);
3412 if (DirCnrMenu)
3413 WinDestroyWindow(DirCnrMenu);
3414 if (FileMenu)
3415 WinDestroyWindow(FileMenu);
3416 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3417 EmptyCnr(hwnd);
[1077]3418# ifdef FORTIFY
3419 Fortify_LeaveScope();
3420# endif
[551]3421 break;
[1016]3422 } // switch
3423
3424 if (dcd && dcd->oldproc) {
3425 // 11 May 08 SHL fixme debug fortify
3426 if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
3427 DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x", msg, mp1, mp2);
[705]3428 return dcd->oldproc(hwnd, msg, mp1, mp2);
3429 }
3430 else
3431 return PFNWPCnr(hwnd, msg, mp1, mp2);
[2]3432}
3433
[551]3434HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3435 ULONG flags)
[275]3436{
[2]3437 /* bitmapped flags:
3438 * 0x00000001 = don't close app when window closes
3439 * 0x00000002 = no frame controls
3440 */
3441
[551]3442 HWND hwndFrame = (HWND) 0, hwndClient;
3443 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3444 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3445 USHORT id;
[2]3446 static USHORT idinc = 0;
[551]3447 DIRCNRDATA *dcd;
3448 static BOOL first = FALSE;
[2]3449
[551]3450 if (flags & 2)
[2]3451 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
[551]3452 FCF_MINMAX | FCF_ICON));
3453 if (!idinc)
[2]3454 idinc = (rand() % 100);
[551]3455 if (!hwndParent)
[2]3456 hwndParent = HWND_DESKTOP;
[551]3457 if (ParentIsDesktop(hwndParent, hwndParent))
[2]3458 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
[551]3459 if (!hwndMain && !first) {
3460 if (DirCnrMenu) {
[2]3461 MENUITEM mi;
[551]3462 memset(&mi, 0, sizeof(mi));
[2]3463 WinSendMsg(DirCnrMenu,
[551]3464 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
[2]3465 mi.iPosition = MIT_END;
3466 mi.afStyle = MIS_TEXT;
3467 mi.id = IDM_DRIVESMENU;
3468 WinSendMsg(DirCnrMenu,
[551]3469 MM_INSERTITEM,
3470 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
[2]3471 }
3472 first = TRUE;
3473 }
[551]3474 if (directory) {
[2]3475 hwndFrame = WinCreateStdWindow(hwndParent,
[551]3476 WS_VISIBLE,
3477 &FrameFlags,
[593]3478 WC_DIRCONTAINER,
[551]3479 NULL,
3480 WS_VISIBLE | fwsAnimate,
3481 FM3ModHandle, DIR_FRAME, &hwndClient);
3482 if (hwndFrame && hwndClient) {
[2]3483 id = DIR_FRAME + idinc++;
[551]3484 if (idinc > 99)
3485 idinc = 0;
3486 WinSetWindowUShort(hwndFrame, QWS_ID, id);
[1063]3487# ifdef FORTIFY
3488 Fortify_EnterScope();
[1077]3489# endif
[551]3490 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
[358]3491 if (!dcd) {
[1016]3492 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
[551]3493 hwndFrame = (HWND) 0;
[358]3494 }
3495 else {
[551]3496 dcd->size = sizeof(DIRCNRDATA);
3497 dcd->id = id;
3498 dcd->type = DIR_FRAME;
3499 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3500 dcd->hwndFrame = hwndFrame;
3501 dcd->hwndClient = hwndClient;
3502 dcd->hwndRestore = hwndRestore;
3503 dcd->dontclose = ((flags & 1) != 0);
[1065]3504 dcd->ds.detailslongname = dsDirCnrDefault.detailslongname;
3505 dcd->ds.detailssubject = dsDirCnrDefault.detailssubject;
3506 dcd->ds.detailsea = dsDirCnrDefault.detailsea;
3507 dcd->ds.detailssize = dsDirCnrDefault.detailssize;
3508 dcd->ds.detailsicon = dsDirCnrDefault.detailsicon;
3509 dcd->ds.detailsattr = dsDirCnrDefault.detailsattr;
3510 dcd->ds.detailscrdate = dsDirCnrDefault.detailscrdate;
3511 dcd->ds.detailscrtime = dsDirCnrDefault.detailscrtime;
3512 dcd->ds.detailslwdate = dsDirCnrDefault.detailslwdate;
3513 dcd->ds.detailslwtime = dsDirCnrDefault.detailslwtime;
3514 dcd->ds.detailsladate = dsDirCnrDefault.detailsladate;
3515 dcd->ds.detailslatime = dsDirCnrDefault.detailslatime;
[551]3516 strcpy(dcd->directory, directory);
3517 add_udir(FALSE, directory);
3518 {
3519 PFNWP oldproc;
[2]3520
[551]3521 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3522 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
[377]3523 }
[551]3524 dcd->hwndCnr = WinCreateWindow(hwndClient,
3525 WC_CONTAINER,
3526 NULL,
3527 CCS_AUTOPOSITION | CCS_MINIICONS |
3528 CCS_MINIRECORDCORE | ulCnrType |
3529 WS_VISIBLE,
3530 0,
3531 0,
3532 0,
3533 0,
3534 hwndClient,
3535 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3536 if (!dcd->hwndCnr) {
3537 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3538 IDS_WINCREATEWINDOW);
3539 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
[1077]3540 free(dcd);
[551]3541 hwndFrame = (HWND) 0;
3542 }
[377]3543 else {
[1016]3544 RestorePresParams(dcd->hwndCnr, "DirCnr");
[551]3545 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3546 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
[1016]3547 (PFNWP) DirCnrWndProc);
[551]3548 {
3549 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3550 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3551 };
[2]3552
[551]3553 if (!(flags & 2))
3554 ids[6] = 0;
3555 CommonCreateTextChildren(dcd->hwndClient,
[593]3556 WC_DIRSTATUS, ids);
[551]3557 }
3558 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3559 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3560 if (FrameFlags & FCF_TASKLIST) {
[2]3561
[551]3562 SWP swp, swpD;
3563 ULONG size = sizeof(swp);
3564 LONG cxScreen, cyScreen;
[2]3565
[551]3566 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3567 if (PrfQueryProfileData(fmprof,
3568 appname, "VDirSizePos", &swpD, &size)) {
3569 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3570 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3571 if (swp.x + swpD.cx > cxScreen)
3572 swp.x = cxScreen - swpD.cx;
3573 if (swp.y + swpD.cy > cyScreen)
3574 swp.y = cyScreen - swpD.cy;
3575 swp.cx = swpD.cx;
3576 swp.cy = swpD.cy;
3577 }
3578 WinSetWindowPos(hwndFrame,
3579 HWND_TOP,
3580 swp.x,
3581 swp.y,
3582 swp.cx,
3583 swp.cy,
3584 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3585 SWP_ACTIVATE);
3586 }
3587 }
[2]3588 }
[1077]3589# ifdef FORTIFY
3590 Fortify_LeaveScope();
3591# endif
[2]3592 }
3593 }
3594 return hwndFrame;
3595}
[793]3596
3597#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3598#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3599#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.