source: trunk/dll/dircnrs.c@ 1222

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

Ticket 187: Moved typedef's and some #define's from fm3dll.h

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