source: trunk/dll/dircnrs.c@ 1439

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

Changes to allow high mem loading of dll; Refactor .LONGNAME and .SUBJECT EA fetch to FetchCommonEAs. Add szFSType to FillInRecordFromFSA use to bypass EA scan and size formatting for tree container; Fix labels/FS type to work on scan on NOPRESCAN Drives; Fixed dbl directory names on restore of dir cnrs; (Tickets 47, 339, 363, 368, 369, 370)

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