source: trunk/dll/dircnrs.c@ 1076

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

Ticket 230: Simplified code and eliminated some local variables by incorporating
all the details view settings (both the global variables and those in the
DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.

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