source: trunk/dll/dircnrs.c@ 1211

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

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