source: trunk/dll/dircnrs.c@ 1357

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

Fixed DROPHELP issues Tickets 320 & 324

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