source: trunk/dll/dircnrs.c@ 1020

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

Fix dircnr to follow "subject column" preference on open; match query & save profile key names for "details" settings.

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