source: trunk/dll/dircnrs.c@ 1194

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

Ticket 187: Draft 2: Move remaining function declarations

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