source: trunk/dll/dircnrs.c@ 1387

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

Updated history; comments minor code cleanup for recent changes

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