source: trunk/dll/dircnrs.c@ 1344

Last change on this file since 1344 was 1335, checked in by Steven Levine, 17 years ago

Ticket 26: Add exception handlers to all threads using xbeginthread

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