source: trunk/dll/dircnrs.c@ 1029

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

Fixed early memory free; Added free_... functions to make fortify checking easier; Added fortify scopes; Delete now moves to trash can on systems with the xworkplace trash can installed.

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