source: trunk/dll/dircnrs.c@ 1451

Last change on this file since 1451 was 1451, checked in by Gregg Young, 16 years ago

Change WM_USER numbers to account for the fact that some values have been used by the toolkit; Fix unexpected behavior when doubleclick on dircnr dir icon; Provide option to tun off the drive exclude dialogg on startup.

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