source: trunk/dll/dircnrs.c@ 1304

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

Move DosEnterCritSec into SetMask Replace 2 more with semaphore(Ticket 308)

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