source: trunk/dll/dircnrs.c@ 1444

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

Rework of drivebar to rescan all drives and refresh media buttons and menu items grey out inappropriate menu items. Streamline Tree scan code and use semaphores to serialize access. Add NOEASUPPORT and LOCALHD driveflag; .LONGNAME usage fixes; (Tickets 377-386)

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