source: trunk/dll/misc.c@ 1734

Last change on this file since 1734 was 1734, checked in by Gregg Young, 12 years ago

Tentative fix for container double free error.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 78.9 KB
RevLine 
[70]1/***********************************************************************
2
3 $Id: misc.c 1734 2014-02-21 00:01:29Z gyoung $
4
[406]5 Misc GUI support functions
[70]6
7 Copyright (c) 1993-98 M. Kimes
[1498]8 Copyright (c) 2003, 2010 Steven H. Levine
[70]9
[161]10 11 Jun 03 SHL Add JFS and FAT32 support
11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 01 Aug 04 SHL LoadLibPath: avoid buffer overflow
[198]13 07 Jun 05 SHL Drop obsoletes
[231]14 24 Jul 05 SHL Beautify
[245]15 24 Jul 05 SHL Correct longname display option
[350]16 17 Jul 06 SHL Use Runtime_Error
[369]17 26 Jul 06 SHL Use chop_at_crnl
[397]18 27 Jul 06 SHL Comments, apply indent
[406]19 29 Jul 06 SHL Use xfgets_bstripcr
[451]20 16 Aug 06 SHL Comments
[468]21 31 Aug 06 SHL disable_menuitem: rework args to match name - sheesh
[526]22 10 Oct 06 GKY Add NDFS32 support
[552]23 18 Feb 07 GKY More drive type and drive icon support
[688]24 10 Jun 07 GKY Add IsFm2Window as part of work around PM drag limit
[730]25 05 Jul 07 GKY Fix menu removals for WORKPLACE_PROCESS=YES
[737]26 23 Jul 07 SHL Sync with CNRITEM updates (ticket#24)
[751]27 31 Jul 07 SHL Clean up and report errors (ticket#24)
[756]28 03 Aug 07 GKY Direct editting fixed (ticket#24)
[773]29 06 Aug 07 SHL Use BldQuotedFileName
[775]30 06 Aug 07 GKY Increase Subject EA to 1024
31 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
[787]32 14 Aug 07 SHL Delete obsoletes
33 14 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
[827]34 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
[860]35 05 Nov 07 GKY Use commafmtULL to display file sizes for large file support
[872]36 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
[921]37 12 Jan 08 SHL Document SetConditionalCascade
[940]38 13 Jan 08 GKY Get Subjectwidth/Subjectleft working in the collector.
[998]39 19 Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
[940]40 21 Jan 08 GKY Stop reallocating NullStr by direct editing of empty subject and longname strings.
[985]41 29 Feb 08 GKY Use xfree where appropriate
[998]42 08 Mar 08 JBS Ticket 230: Replace prefixless INI keys for default directory containers with
[1394]43 keys using a "DirCnr." prefix
[1026]44 19 Jun 08 JBS Ticket 239: Fix LoadDetailsSwitches so INI file is read correctly and details
[1394]45 switches are set correctly.
[1065]46 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
[1394]47 all the details view settings (both the global variables and those in the
48 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
[1077]49 17 Jul 08 SHL Add GetTidForWindow for Fortify support
[1084]50 20 Jul 08 GKY Add save/append filename to clipboard.
[1394]51 Change menu wording to make these easier to find
[1112]52 23 Aug 08 GKY Add CheckDriveSpaceAvail To pre check drive space to prevent failures
[1358]53 25 Dec 08 GKY Add code to allow write verify to be turned off on a per drive basis
[1360]54 28 Dec 08 GKY Check for LVM.EXE and remove Refresh removable media menu item as appropriate
[1395]55 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
[1400]56 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
57 08 Mar 09 GKY Additional strings move to PCSZs in init.c
58 08 Mar 09 GKY Add WriteDetailsSwitches and use LoadDetailsSwitches to replace in line code
[1402]59 08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used)
[1410]60 28 Mar 09 GKY Add RemoveOldCnrSwitches to remove pre 3.16 style ini keys;
61 add State.version key for check
[1480]62 12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory
[1444]63 22 Jul 09 GKY Check if drives support EAs add driveflag for this
64 22 Jul 09 GKY Allow .LONGNAME to be displayed for FAT drives.
[1488]65 21 Dec 09 GKY Allow command menu reorder without changing the "ID" or hot key for a command.
66 Added load_inicommand to load the IDs from the ini file.
[1498]67 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
[1546]68 23 Oct 10 GKY Add menu items for opening directory cnrs based on path of selected item
69 including the option to use walk directories to select path
[1627]70 26 Aug 11 GKY Add a low mem version of xDosAlloc* wrappers; move error checking into all the
71 xDosAlloc* wrappers.
[1647]72 12 Nov 11 GKY Fixed HelpViewer's failure to open help files and subsequent failure with files with spaces.
[70]73
74***********************************************************************/
75
[907]76#include <stdlib.h>
77#include <string.h>
78#include <ctype.h>
79#include <share.h>
[1159]80#include <malloc.h> // _heapmin
[907]81
[2]82#define INCL_DOS
83#define INCL_WIN
84#define INCL_GPI
[841]85#define INCL_LONGLONG
[2]86
[1182]87#include "fm3dll.h"
[1225]88#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
89#include "misc.h"
[1210]90#include "killproc.h" // Data declaration(s)
91#include "comp.h" // Data declaration(s)
92#include "treecnr.h" // Data declaration(s)
93#include "mainwnd.h" // Data declaration(s)
94#include "init.h" // Data declaration(s)
95#include "dircnrs.h" // Data declaration(s)
96#include "newview.h" // Data declarations
97#include "collect.h" // data declaration(s)
98#include "notebook.h" // data declaration(s)
99#include "arccnrs.h"
[2]100#include "fm3dlg.h"
101#include "fm3str.h"
[1159]102#include "pathutil.h" // BldQuotedFileName
103#include "errutil.h" // Dos_Error...
104#include "strutil.h" // GetPString
105#include "command.h" // LINKCMDS
106#include "cmdline.h" // CmdLineDlgProc
107#include "defview.h" // QuickView
108#include "copyf.h" // WriteLongName
109#include "strips.h" // chop_at_crnl
[1182]110#include "valid.h" // CheckDrive
111#include "presparm.h" // CopyPresParams
112#include "systemf.h" // ExecOnList
113#include "viewer.h" // StartMLEEditor
114#include "subj.h" // Subject
115#include "wrappers.h" // xDosSetPathInfo
[1400]116#include "i18nutil.h" // CommaFmtULL
[1159]117#include "fortify.h"
[1354]118#include "info.h" // driveflags
[2]119
[1673]120#define CONTAINER_COLUMNS 13 // Number of columns in details view
[1225]121#define MS_POPUP 0x00000010L
122
[1210]123// Data definitions
124#pragma data_seg(GLOBAL1)
125HWND CollectorDirMenu;
126HWND CollectorFileMenu;
127HWND DirMenu;
128HWND FileMenu;
129HWND TreeMenu;
130BOOL fDefaultDeletePerm;
131BOOL fWorkPlace;
132
133#pragma data_seg(GLOBAL4)
134ULONG numswitches;
135HSWITCH switches[499];
136
[2]137#pragma data_seg(DATA1)
[350]138static PSZ pszSrcFile = __FILE__;
139
[2]140#ifndef BEGIN_LIBPATH
[1159]141#define BEGIN_LIBPATH 1
[2]142#endif
[231]143
[2]144#ifndef END_LIBPATH
[1159]145#define END_LIBPATH 2
[2]146#endif
[231]147
[2]148#ifndef ORD_DOS32QUERYEXTLIBPATH
[231]149#define ORD_DOS32QUERYEXTLIBPATH 874
[2]150#endif
151
[687]152BOOL IsFm2Window(HWND hwnd, BOOL chkTid)
153{
154 PIB *ppib;
155 TIB *ptib;
[751]156 BOOL yes;
157 APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
[687]158
[733]159 if (rc) {
[687]160 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1398]161 PCSZ_DOSGETINFOBLOCKS);
[751]162 yes = FALSE;
[733]163 }
[687]164 else {
165 PID pid;
166 TID tid;
167
[751]168 // Check window owned by FM2 process
169 // Check say same thread too, if requested
170 // OK for window to be dead - just return FALSE
171 yes = WinQueryWindowProcess(hwnd, &pid, &tid) &&
[1394]172 pid == ppib->pib_ulpid &&
173 (!chkTid || tid == ptib->tib_ptib2->tib2_ultid);
[687]174 }
[751]175 return yes;
[687]176}
177
[1077]178#ifdef FORTIFY
179
180/**
[1078]181 * Return thread ordinal for fm/2 window
[1077]182 * window must exist and must be created by fm/2
183 * @param hwnd is window handle
[1078]184 * @returns thread ordinal or -1 if error
[1077]185 */
186
187INT GetTidForWindow(HWND hwnd)
188{
189 PIB *ppib;
190 TIB *ptib;
[1078]191 LONG ordinal = -1;
[1077]192 APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
193
194 if (rc) {
195 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1398]196 PCSZ_DOSGETINFOBLOCKS);
[1077]197 }
198 else {
199 PID pid;
200 TID tid;
201 if (!WinQueryWindowProcess(hwnd, &pid, &tid))
[1394]202 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryWindowProcess failed for %X", hwnd);
[1077]203 else if (pid != ppib->pib_ulpid)
[1394]204 Runtime_Error(pszSrcFile, __LINE__, "hwnd %X not created by fm/2", hwnd);
[1077]205 else
[1394]206 ordinal = ptib->tib_ptib2->tib2_ultid;
[1077]207 }
[1078]208 return ordinal;
[1077]209}
210
[1078]211/**
212 * Return thread ordinal for current thread
213 * @returns thread ordinal or -1 if error
214 */
215
216INT GetTidForThread(VOID)
217{
218 PIB *ppib;
219 TIB *ptib;
220 LONG ordinal = -1;
221 APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
222
223 if (rc) {
224 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1398]225 PCSZ_DOSGETINFOBLOCKS);
[1078]226 }
227 else
228 ordinal = ptib->tib_ptib2->tib2_ultid;
229
230 return ordinal;
231}
232
[1077]233#endif // FORTIFY
234
[231]235VOID SetShiftState(VOID)
236{
[397]237 shiftstate = 0;
238 if (WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
239 shiftstate |= KC_CTRL;
240 if (WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
241 shiftstate |= KC_SHIFT;
242 if (WinGetKeyState(HWND_DESKTOP, VK_ALT) & 0x8000)
243 shiftstate |= KC_ALT;
[2]244}
245
[231]246void EmphasizeButton(HWND hwnd, BOOL on)
247{
[397]248 HPS hps = DrgGetPS(hwnd);
[2]249
[397]250 // fixme to complain?
251 if (hps) {
252 POINTL ptl;
253 SWP swp;
[2]254
[397]255 WinQueryWindowPos(hwnd, &swp);
256 ptl.x = 1;
257 ptl.y = 1;
258 GpiMove(hps, &ptl);
[787]259 GpiSetColor(hps, on ? CLR_BLACK : CLR_PALEGRAY);
[397]260 ptl.x = swp.cx - 2;
261 ptl.y = swp.cy - 2;
262 GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
263 DrgReleasePS(hps);
[551]264 if (remove) //fixme always true
[397]265 WinInvalidateRect(hwnd, NULL, FALSE);
266 }
[2]267}
268
[231]269void DrawTargetEmphasis(HWND hwnd, BOOL on)
270{
[397]271 HPS hps = DrgGetPS(WinQueryWindow(hwnd, QW_PARENT));
[551]272
[397]273 if (hps) {
[787]274 BoxWindow(hwnd, hps, on ? CLR_BLACK : CLR_PALEGRAY);
[397]275 DrgReleasePS(hps);
276 }
[2]277}
278
[231]279void BoxWindow(HWND hwnd, HPS hps, LONG color)
280{
[397]281 POINTL ptl;
282 SWP swp;
283 BOOL releaseme = FALSE;
[2]284
[397]285 if (!hps) {
286 hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
287 releaseme = TRUE;
288 }
289 if (hps && WinQueryWindowPos(hwnd, &swp)) {
290 ptl.x = swp.x - 2;
291 ptl.y = swp.y - 2;
292 GpiMove(hps, &ptl);
293 GpiSetColor(hps, color);
294 ptl.x = swp.x + swp.cx + 1;
295 ptl.y = swp.y + swp.cy + 1;
296 GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
297 }
298 if (releaseme && hps)
299 WinReleasePS(hps);
[2]300}
301
[231]302void PaintSTextWindow(HWND hwnd, HPS hps)
303{
[1673]304 /**
[397]305 * paint a text window such that the rightmost part of the text is
306 * always visible even if the text length exceeds the length of the
307 * window -- otherwise, paint the window so that it is left-justified
308 * and vertically centered.
309 */
[2]310
[397]311 char *s = NULL;
312 long len;
313 POINTL aptl[TXTBOX_COUNT], ptl;
314 RECTL rcl;
315 char *p;
316 BOOL releaseme = FALSE;
[2]317
[397]318 if (!hps) {
319 releaseme = TRUE;
320 hps = WinGetPS(hwnd);
321 }
322 if (hps) {
323 WinQueryWindowRect(hwnd, &rcl);
324 WinFillRect(hps, &rcl, CLR_PALEGRAY);
325 len = WinQueryWindowTextLength(hwnd);
326 if (len)
327 s = xmalloc(len + 1, pszSrcFile, __LINE__);
328 if (s) {
329 *s = 0;
330 WinQueryWindowText(hwnd, CCHMAXPATH, s);
331 if (*s) {
[1394]332 rcl.xRight -= 3;
333 p = s;
334 GpiQueryTextBox(hps, 3, "...", TXTBOX_COUNT, aptl);
335 len = aptl[TXTBOX_TOPRIGHT].x;
336 do {
337 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
338 if (aptl[TXTBOX_TOPRIGHT].x > (rcl.xRight - (p != s ? len : 0)))
339 p++;
340 else
341 break;
342 }
343 while (*p);
344 if (*p) {
345 GpiSetMix(hps, FM_OVERPAINT);
346 GpiSetColor(hps, CLR_BLACK);
347 ptl.x = 3;
348 ptl.y = ((rcl.yTop / 2) -
349 ((aptl[TXTBOX_TOPRIGHT].y +
350 aptl[TXTBOX_BOTTOMLEFT].y) / 2));
351 GpiMove(hps, &ptl);
352 if (p != s)
353 GpiCharString(hps, 3, "...");
354 GpiCharString(hps, strlen(p), p);
355 }
[397]356 }
[1039]357 free(s);
[231]358 }
[397]359 if (releaseme)
360 WinReleasePS(hps);
361 }
[2]362}
363
[231]364VOID PaintRecessedWindow(HWND hwnd, HPS hps, BOOL outtie, BOOL dbl)
365{
[1673]366 /**
[397]367 * paint a recessed box around the window
368 * two pixels width required around window for painting...
369 */
370 BOOL releaseme = FALSE;
[2]371
[397]372 if (!hps) {
373 hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
374 releaseme = TRUE;
375 }
376 if (hps) {
[2]377
[397]378 POINTL ptl;
379 SWP swp;
[2]380
[397]381 WinQueryWindowPos(hwnd, &swp);
382 ptl.x = swp.x - 1;
383 ptl.y = swp.y - 1;
384 GpiMove(hps, &ptl);
385 if (!outtie)
386 GpiSetColor(hps, CLR_WHITE);
387 else
388 GpiSetColor(hps, CLR_DARKGRAY);
389 ptl.x = swp.x + swp.cx;
390 GpiLine(hps, &ptl);
391 ptl.y = swp.y + swp.cy;
392 GpiLine(hps, &ptl);
393 if (dbl) {
394 ptl.x = swp.x - 2;
395 ptl.y = swp.y - 2;
396 GpiMove(hps, &ptl);
397 ptl.x = swp.x + swp.cx + 1;
398 GpiLine(hps, &ptl);
399 ptl.y = swp.y + swp.cy + 1;
400 GpiLine(hps, &ptl);
[2]401 }
[397]402 if (!outtie)
403 GpiSetColor(hps, CLR_DARKGRAY);
404 else
405 GpiSetColor(hps, CLR_WHITE);
406 if (dbl) {
407 ptl.x = swp.x - 2;
408 GpiLine(hps, &ptl);
409 ptl.y = swp.y - 2;
410 GpiLine(hps, &ptl);
411 ptl.x = swp.x + swp.cx;
412 ptl.y = swp.y + swp.cy;
413 GpiMove(hps, &ptl);
414 }
415 ptl.x = swp.x - 1;
416 GpiLine(hps, &ptl);
417 ptl.y = swp.y - 1;
418 GpiLine(hps, &ptl);
419 GpiSetColor(hps, CLR_PALEGRAY);
420 ptl.x = swp.x - (2 + (dbl != FALSE));
421 ptl.y = swp.y - (2 + (dbl != FALSE));
422 GpiMove(hps, &ptl);
423 ptl.x = swp.x + swp.cx + (1 + (dbl != FALSE));
424 GpiLine(hps, &ptl);
425 ptl.y = swp.y + swp.cy + (1 + (dbl != FALSE));
426 GpiLine(hps, &ptl);
427 ptl.x = swp.x - (2 + (dbl != FALSE));
428 GpiLine(hps, &ptl);
429 ptl.y = swp.y - (2 + (dbl != FALSE));
430 GpiLine(hps, &ptl);
431 if (releaseme)
432 WinReleasePS(hps);
433 }
[2]434}
435
[1394]436BOOL AdjustCnrColVis(HWND hwndCnr, PCSZ title, BOOL visible, BOOL toggle)
[231]437{
[551]438 PFIELDINFO pfi = (PFIELDINFO) WinSendMsg(hwndCnr,
[1394]439 CM_QUERYDETAILFIELDINFO,
440 MPVOID, MPFROMSHORT(CMA_FIRST));
[551]441
[397]442 while (pfi) {
443 if (!strcmp(pfi->pTitleData, title)) {
444 if (toggle) {
[1394]445 if (pfi->flData & CFA_INVISIBLE)
446 pfi->flData &= (~CFA_INVISIBLE);
447 else
448 pfi->flData |= CFA_INVISIBLE;
449 return !(pfi->flData & CFA_INVISIBLE);
[397]450 }
451 else {
[1394]452 if (visible)
453 pfi->flData &= (~CFA_INVISIBLE);
454 else
455 pfi->flData |= CFA_INVISIBLE;
[397]456 }
457 return TRUE;
[2]458 }
[397]459 pfi = pfi->pNextFieldInfo;
460 }
461 return FALSE;
[2]462}
463
[1394]464BOOL AdjustCnrColRO(HWND hwndCnr, PCSZ title, BOOL readonly, BOOL toggle)
[70]465{
[551]466 PFIELDINFO pfi = (PFIELDINFO) WinSendMsg(hwndCnr,
[1394]467 CM_QUERYDETAILFIELDINFO,
468 MPVOID, MPFROMSHORT(CMA_FIRST));
[551]469
[397]470 while (pfi) {
471 if (!strcmp(pfi->pTitleData, title)) {
472 if (toggle) {
[1394]473 if (pfi->flData & CFA_FIREADONLY)
474 pfi->flData &= (~CFA_FIREADONLY);
475 else
476 pfi->flData |= CFA_FIREADONLY;
477 return (pfi->flData & CFA_FIREADONLY);
[397]478 }
479 else {
[1394]480 if (!readonly)
481 pfi->flData &= (~CFA_FIREADONLY);
482 else
483 pfi->flData |= CFA_FIREADONLY;
[397]484 }
485 return TRUE;
[2]486 }
[397]487 pfi = pfi->pNextFieldInfo;
488 }
489 return FALSE;
[2]490}
491
[1444]492VOID AdjustCnrColsForFSType(HWND hwndCnr, PCSZ directory, DETAILS_SETTINGS *pds, BOOL compare)
[231]493{
[397]494 CHAR FileSystem[CCHMAXPATH];
495 INT x;
496 BOOL hasCreateDT;
497 BOOL hasAccessDT;
498 BOOL hasLongNames;
[1444]499 BOOL hasSubjects;
[2]500
[397]501 if (!directory || !*directory)
502 return;
503 x = CheckDrive(toupper(*directory), FileSystem, NULL);
504 if (x != -1) {
[1444]505 x = toupper(*directory) - 'A';
[397]506 if (!stricmp(FileSystem, HPFS) ||
[1394]507 !stricmp(FileSystem, JFS) ||
508 !stricmp(FileSystem, FAT32) ||
509 !stricmp(FileSystem, RAMFS) ||
510 !stricmp(FileSystem, NDFS32) ||
511 !stricmp(FileSystem, NTFS) ||
512 !stricmp(FileSystem, HPFS386)) {
[397]513 hasCreateDT = TRUE;
514 hasAccessDT = TRUE;
[1444]515 if (driveflags[x] & DRIVE_NOEASUPPORT) {
516 hasSubjects = FALSE;
517 hasLongNames = FALSE;
518 }
519 else {
520 hasSubjects = TRUE;
521 hasLongNames = TRUE;
522 }
[2]523 }
[552]524 else if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS)) {
[397]525 hasCreateDT = TRUE;
526 hasAccessDT = FALSE;
[1444]527 if (driveflags[x] & DRIVE_NOEASUPPORT) {
528 hasSubjects = FALSE;
529 hasLongNames = FALSE;
530 }
531 else {
532 hasSubjects = TRUE;
533 hasLongNames = TRUE;
534 }
[2]535 }
[397]536 else {
537 // Assume FAT
538 hasCreateDT = FALSE;
539 hasAccessDT = FALSE;
[1444]540 if (driveflags[x] & DRIVE_NOEASUPPORT) {
541 hasSubjects = FALSE;
542 hasLongNames = FALSE;
543 }
544 else {
545 hasSubjects = TRUE;
546 hasLongNames = TRUE;
547 }
[397]548 }
549 }
550 else {
551 // Assume FAT
552 hasCreateDT = FALSE;
553 hasAccessDT = FALSE;
[1444]554 if (driveflags[x] & DRIVE_NOEASUPPORT) {
555 hasSubjects = FALSE;
556 hasLongNames = FALSE;
557 }
558 else {
559 hasSubjects = TRUE;
560 hasLongNames = TRUE;
561 }
[397]562 }
[787]563 AdjustCnrColVis(hwndCnr,
[1394]564 GetPString(IDS_LADATE),
565 pds->detailsladate ? hasAccessDT : FALSE,
566 FALSE);
[787]567 AdjustCnrColVis(hwndCnr,
[1394]568 GetPString(IDS_LATIME),
569 pds->detailslatime ? hasAccessDT : FALSE,
570 FALSE);
[787]571 AdjustCnrColVis(hwndCnr,
[1394]572 GetPString(IDS_CRDATE),
573 pds->detailscrdate ? hasCreateDT : FALSE,
574 FALSE);
[787]575 AdjustCnrColVis(hwndCnr,
[1394]576 GetPString(IDS_CRTIME),
577 pds->detailscrtime ? hasCreateDT : FALSE,
[1444]578 FALSE);
579 if (pds->detailslongname && !pds->detailssubject && hasSubjects) {
580 AdjustCnrColVis(hwndCnr,
581 compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ),
582 TRUE,
583 FALSE);
584 AdjustCnrColVis(hwndCnr,
585 GetPString(IDS_LNAME),
586 pds->detailslongname ? hasLongNames : FALSE,
587 FALSE);
588 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
589 }
590 else
591 AdjustCnrColVis(hwndCnr,
592 GetPString(IDS_LNAME),
593 pds->detailslongname ? hasLongNames : FALSE,
594 FALSE);
[787]595 AdjustCnrColVis(hwndCnr,
[1444]596 compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ),
597 pds->detailssubject ? hasSubjects : FALSE,
598 FALSE);
[397]599 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
[2]600}
601
[1444]602VOID AdjustCnrColsForPref(HWND hwndCnr, PCSZ directory, DETAILS_SETTINGS *pds,
[1394]603 BOOL compare)
[231]604{
[1065]605 AdjustCnrColVis(hwndCnr, GetPString(IDS_ATTR), pds->detailsattr, FALSE);
606 AdjustCnrColVis(hwndCnr, GetPString(IDS_ICON), pds->detailsicon, FALSE);
607 AdjustCnrColVis(hwndCnr, GetPString(IDS_LWDATE), pds->detailslwdate, FALSE);
608 AdjustCnrColVis(hwndCnr, GetPString(IDS_LWTIME), pds->detailslwtime, FALSE);
609 AdjustCnrColVis(hwndCnr, GetPString(IDS_EA), pds->detailsea, FALSE);
610 AdjustCnrColVis(hwndCnr, GetPString(IDS_SIZE), pds->detailssize, FALSE);
[751]611
[397]612 if (!directory) {
[1444]613 AdjustCnrColVis(hwndCnr,
614 compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ),
615 pds->detailssubject,
616 FALSE);
[1065]617 AdjustCnrColVis(hwndCnr, GetPString(IDS_LADATE), pds->detailsladate, FALSE);
618 AdjustCnrColVis(hwndCnr, GetPString(IDS_LATIME), pds->detailslatime, FALSE);
619 AdjustCnrColVis(hwndCnr, GetPString(IDS_CRDATE), pds->detailscrdate, FALSE);
620 AdjustCnrColVis(hwndCnr, GetPString(IDS_CRTIME), pds->detailscrtime, FALSE);
621 AdjustCnrColVis(hwndCnr, GetPString(IDS_LNAME), pds->detailslongname, FALSE);
[397]622 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
623 }
[1444]624 else {
625 AdjustCnrColsForFSType(hwndCnr, directory, pds, compare);
626 }
[2]627}
628
[751]629BOOL SetCnrCols(HWND hwndCnr, BOOL isCompCnr)
[231]630{
[397]631 BOOL fSuccess = TRUE;
632 PFIELDINFO pfi, pfiLastLeftCol, pfiIconCol;
[2]633
[397]634 // Allocate storage for container column data
[2]635
[397]636 pfi = WinSendMsg(hwndCnr, CM_ALLOCDETAILFIELDINFO,
[1394]637 MPFROMLONG(CONTAINER_COLUMNS), NULL);
[2]638
[751]639 if (!pfi) {
640 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCDETAILFIELDINFO");
641 fSuccess = FALSE;
642 }
643 else {
[2]644
[397]645 PFIELDINFO pfiFirst;
646 FIELDINFOINSERT fii;
[2]647
[397]648 // Store original value of pfi so we won't lose it when it changes.
649 // This will be needed on the CM_INSERTDETAILFIELDINFO message.
[2]650
[397]651 pfiFirst = pfi;
[2]652
[397]653 // Fill in column information for the icon column
[2]654
[397]655 pfi->flData = CFA_BITMAPORICON | CFA_CENTER | CFA_FIREADONLY;
656 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
[1394]657 pfi->pTitleData = (PSZ)GetPString(IDS_ICON);
[397]658 pfi->offStruct = FIELDOFFSET(MINIRECORDCORE, hptrIcon);
[2]659
[397]660 pfiIconCol = pfi;
[2]661
[397]662 // Fill in column information for the file name. Note that we are
[737]663 // using the pszDisplayName variable rather than pszFileName. We do this
664 // because the container does not always display the full path file name.
[2]665
[397]666 pfi = pfi->pNextFieldInfo;
[856]667
[397]668 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
[792]669 pfi->flTitle = CFA_LEFT;
[1394]670 pfi->pTitleData = (PSZ)GetPString(IDS_FILENAME);
[737]671 pfi->offStruct = FIELDOFFSET(CNRITEM, pszDisplayName);
[2]672
[397]673 // Fill in column information for the longname.
[2]674
[397]675 pfi = pfi->pNextFieldInfo;
[1444]676 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
[792]677 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
[1394]678 pfi->pTitleData = (PSZ)GetPString(IDS_LNAME);
[762]679 pfi->offStruct = FIELDOFFSET(CNRITEM, pszLongName);
[1444]680 pfiLastLeftCol = pfi;
[2]681
[1444]682 // Store the current pfi value as that will be used to indicate the
683 // last column in the lefthand container window (we have a splitbar)
684 if (!dsDirCnrDefault.fSubjectInLeftPane)
[796]685 pfiLastLeftCol = pfi;
[1444]686 else
687 pfiLastLeftCol = pfi->pNextFieldInfo;
[792]688
[1444]689 // Fill in column info for subjects
690 pfi = pfi->pNextFieldInfo;
691 pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
692 if (isCompCnr)
693 pfi->flData |= CFA_FIREADONLY;
694 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
695 pfi->pTitleData = isCompCnr ? (PSZ)GetPString(IDS_STATUS) :
696 (PSZ)GetPString(IDS_SUBJ);
697 pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
698 pfi->cxWidth = dsDirCnrDefault.SubjectDisplayWidth;
[796]699
[397]700 // Fill in column information for the file size
[2]701
[859]702 pfi = pfi->pNextFieldInfo;
703 pfi->flData = CFA_STRING | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
704 pfi->flTitle = CFA_CENTER;
[1394]705 pfi->pTitleData = (PSZ)GetPString(IDS_SIZE);
[859]706 pfi->offStruct = FIELDOFFSET(CNRITEM, pszFmtFileSize);
707
708
[397]709 // Fill in the column information for the file's ea size
[2]710
[397]711 pfi = pfi->pNextFieldInfo;
712 pfi->flData = CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
713 pfi->flTitle = CFA_CENTER;
[1394]714 pfi->pTitleData = (PSZ)GetPString(IDS_EA);
[397]715 pfi->offStruct = FIELDOFFSET(CNRITEM, easize);
[2]716
[397]717 // Fill in the column information for the file attribute
[2]718
[397]719 pfi = pfi->pNextFieldInfo;
720 pfi->flData = CFA_STRING | CFA_CENTER | CFA_SEPARATOR | CFA_FIREADONLY;
721 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
[1394]722 pfi->pTitleData = (PSZ)GetPString(IDS_ATTR);
[397]723 pfi->offStruct = FIELDOFFSET(CNRITEM, pszDispAttr);
[2]724
[397]725 // Fill in column information for last write file date
[2]726
[397]727 pfi = pfi->pNextFieldInfo;
728 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
729 pfi->flTitle = CFA_CENTER;
[1394]730 pfi->pTitleData = (PSZ)GetPString(IDS_LWDATE);
[397]731 pfi->offStruct = FIELDOFFSET(CNRITEM, date);
[2]732
[397]733 // Fill in column information for the last write file time
[2]734
[397]735 pfi = pfi->pNextFieldInfo;
736 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
737 pfi->flTitle = CFA_CENTER;
[1394]738 pfi->pTitleData = (PSZ)GetPString(IDS_LWTIME);
[397]739 pfi->offStruct = FIELDOFFSET(CNRITEM, time);
[2]740
[397]741 // Fill in column information for last access file date
[2]742
[397]743 pfi = pfi->pNextFieldInfo;
744 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
745 pfi->flTitle = CFA_CENTER;
[1394]746 pfi->pTitleData = (PSZ)GetPString(IDS_LADATE);
[397]747 pfi->offStruct = FIELDOFFSET(CNRITEM, ladate);
[2]748
[397]749 // Fill in column information for the last access file time
[2]750
[397]751 pfi = pfi->pNextFieldInfo;
752 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
753 pfi->flTitle = CFA_CENTER;
[1394]754 pfi->pTitleData = (PSZ)GetPString(IDS_LATIME);
[397]755 pfi->offStruct = FIELDOFFSET(CNRITEM, latime);
[2]756
[397]757 // Fill in column information for create file date
[2]758
[397]759 pfi = pfi->pNextFieldInfo;
760 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
761 pfi->flTitle = CFA_CENTER;
[1394]762 pfi->pTitleData = (PSZ)GetPString(IDS_CRDATE);
[397]763 pfi->offStruct = FIELDOFFSET(CNRITEM, crdate);
[2]764
[397]765 // Fill in column information for the create file time
[2]766
[397]767 pfi = pfi->pNextFieldInfo;
768 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_FIREADONLY;
769 pfi->flTitle = CFA_CENTER;
[1394]770 pfi->pTitleData = (PSZ)GetPString(IDS_CRTIME);
[397]771 pfi->offStruct = FIELDOFFSET(CNRITEM, crtime);
[2]772
[397]773 // Use the CM_INSERTDETAILFIELDINFO message to tell the container
774 // all the column information it needs to function properly. Place
775 // this column info first in the column list and update the display
776 // after they are inserted (fInvalidateFieldInfo = TRUE)
[2]777
[397]778 (void)memset(&fii, 0, sizeof(FIELDINFOINSERT));
[2]779
[397]780 fii.cb = sizeof(FIELDINFOINSERT);
781 fii.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
782 fii.cFieldInfoInsert = (SHORT) CONTAINER_COLUMNS;
783 fii.fInvalidateFieldInfo = TRUE;
[2]784
[397]785 if (!WinSendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO, MPFROMP(pfiFirst),
[1394]786 MPFROMP(&fii))) {
[751]787 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_INSERTDETAILFIELDINFO");
[397]788 fSuccess = FALSE;
[751]789 }
[397]790 }
[2]791
[397]792 if (fSuccess) {
[2]793
[397]794 CNRINFO cnri;
795 ULONG size;
[2]796
[397]797 // Tell the container about the splitbar and where it goes
[2]798
[397]799 cnri.cb = sizeof(CNRINFO);
800 cnri.pFieldInfoLast = pfiLastLeftCol;
801 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
802 cnri.pFieldInfoObject = pfiIconCol;
803 size = sizeof(LONG);
804 PrfQueryProfileData(fmprof,
[1394]805 appname, "CnrSplitBar", &cnri.xVertSplitbar, &size);
[397]806 if (cnri.xVertSplitbar <= 0)
807 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
808 if (!WinSendMsg(hwndCnr, CM_SETCNRINFO, MPFROMP(&cnri),
[1394]809 MPFROMLONG(CMA_PFIELDINFOLAST | CMA_PFIELDINFOOBJECT |
810 CMA_XVERTSPLITBAR))) {
[751]811 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_SETCNRINFO");
[397]812 fSuccess = FALSE;
[751]813 }
[397]814 }
[2]815
[397]816 return fSuccess;
[2]817}
818
[231]819MRESULT CnrDirectEdit(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[161]820{
[397]821 switch (SHORT2FROMMP(mp1)) {
822 case CN_BEGINEDIT:
823 if (mp2) {
824 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
825 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[2]826
[397]827 if (pci &&
[1394]828 (INT) pci != -1 &&
829 !IsRoot(pci->pszFileName) &&
830 !(pci->flags & RECFLAGS_ENV) && !(pci->flags & RECFLAGS_UNDERENV)) {
831 if (!pfi || pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName)) {
832 PostMsg(hwnd, UM_FIXEDITNAME, MPFROMP(pci->pszFileName), MPVOID);
833 }
834 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, pszSubject))
835 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(1048), MPVOID);
836 else
837 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
[397]838 }
839 else
[1394]840 PostMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
[397]841 }
842 break;
[2]843
[397]844 case CN_REALLOCPSZ:
845 if (mp2) {
846 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
847 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[689]848 CHAR szData[CCHMAXPATH], testname[CCHMAXPATH];
[397]849 HWND hwndMLE = WinWindowFromID(hwnd, CID_MLE);
[1354]850 BOOL fResetVerify = FALSE;
[2]851
[730]852 if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
[1394]853 if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszSubject)) {
[2]854
[1394]855 APIRET rc;
856 EAOP2 eaop;
857 PFEA2LIST pfealist = NULL;
858 CHAR szSubject[1048];
859 ULONG ealen;
860 USHORT len;
861 CHAR *eaval;
862 LONG retlen;
863 PSZ psz;
[2]864
[1394]865 retlen = WinQueryWindowText(hwndMLE, sizeof(szSubject), szSubject);
866 szSubject[retlen + 1] = 0;
867 bstrip(szSubject);
868 if (pci->pszSubject != NullStr) {
869 if (retlen == 0) {
870 psz = pci->pszSubject;
871 pci->pszSubject = NullStr;
872 xfree(psz, pszSrcFile, __LINE__);
873 }
874 else
875 pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
876 }
877 else {
878 pci->pszSubject = xmalloc(retlen + 1, pszSrcFile, __LINE__);
879 if (!pci->pszSubject)
880 return FALSE;
881 }
882 len = strlen(szSubject);
883 if (len)
884 ealen = sizeof(FEA2LIST) + 9 + len + 4;
885 else
886 ealen = sizeof(FEALIST) + 9;
[1628]887 if (!xDosAllocMem((PPVOID) & pfealist, ealen + 64, pszSrcFile, __LINE__)) {
[1394]888 memset(pfealist, 0, ealen + 1);
889 pfealist->cbList = ealen;
890 pfealist->list[0].oNextEntryOffset = 0;
891 pfealist->list[0].fEA = 0;
892 pfealist->list[0].cbName = 8;
893 strcpy(pfealist->list[0].szName, SUBJECT);
894 if (len) {
895 eaval = pfealist->list[0].szName + 9;
896 *(USHORT *) eaval = (USHORT) EAT_ASCII;
897 eaval += sizeof(USHORT);
898 *(USHORT *) eaval = (USHORT) len;
899 eaval += sizeof(USHORT);
900 memcpy(eaval, szSubject, len);
901 pfealist->list[0].cbValue = len + (sizeof(USHORT) * 2);
902 }
903 else
904 pfealist->list[0].cbValue = 0;
905 eaop.fpGEA2List = (PGEA2LIST) 0;
906 eaop.fpFEA2List = pfealist;
907 eaop.oError = 0;
908 rc = xDosSetPathInfo(pci->pszFileName, FIL_QUERYEASIZE,
909 &eaop, sizeof(eaop), DSPI_WRTTHRU);
910 DosFreeMem(pfealist);
911 if (rc)
912 return FALSE;
913 }
914 return (MRESULT) TRUE;
915 }
916 else if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszLongName)) {
[2]917
[1394]918 CHAR longname[CCHMAXPATHCOMP];
919 LONG retlen;
920 PSZ psz;
[2]921
[1394]922 *longname = 0;
923 retlen = WinQueryWindowText(hwndMLE, sizeof(longname), longname);
924 longname[retlen + 1] = 0;
925 chop_at_crnl(longname);
926 bstrip(longname);
927 WinSetWindowText(hwndMLE, longname);
928 if (pci->pszLongName != NullStr) {
929 if (retlen == 0) {
930 psz = pci->pszLongName;
931 pci->pszLongName = NullStr;
932 xfree(psz, pszSrcFile, __LINE__);
933 }
934 else
935 pci->pszLongName = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__);
936 }
937 else {
938 pci->pszLongName = xmalloc(retlen + 1, pszSrcFile, __LINE__);
939 if (!pci->pszLongName)
940 return FALSE;
941 }
942 return (MRESULT) WriteLongName(pci->pszFileName, longname);
943 }
944 else {
945 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
946 if (strchr(szData, '?') ||
947 strchr(szData, '*') || IsRoot(pci->pszFileName))
948 return (MRESULT) FALSE;
[1673]949 // If the text changed, rename the file system object.
[1394]950 chop_at_crnl(szData);
951 bstrip(szData);
952 if (!IsFullName(szData))
953 Runtime_Error(pszSrcFile, __LINE__, "bad name");
954 else {
955 if (DosQueryPathInfo(szData,
956 FIL_QUERYFULLNAME,
957 testname, sizeof(testname)))
958 return FALSE;
959 if (DosQueryPathInfo(pci->pszFileName,
960 FIL_QUERYFULLNAME,
961 szData,
962 sizeof(szData)))
[1734]963 {
964 BOOL fDisplayEqualFile = FALSE;
965
966 if (pci->pszFileName == pci->pszDisplayName)
967 fDisplayEqualFile = TRUE;
[1394]968 pci->pszFileName = xrealloc(pci->pszFileName, sizeof(szData), pszSrcFile, __LINE__);
[1734]969 strcpy(szData, pci->pszFileName);
970 if (fDisplayEqualFile)
971 pci->pszDisplayName = pci->pszFileName;
[1394]972 }
973 WinSetWindowText(hwndMLE, szData);
974 if (strcmp(szData, testname)) {
[1395]975 if (stricmp(szData, testname) && IsFile(testname) != -1) {
976 if (!fAlertBeepOff)
[1673]977 DosBeep(50, 100);
978 return (MRESULT) FALSE; // exists; disallow
[1394]979 }
980 if (fVerify && (driveflags[toupper(*szData) - 'A'] & DRIVE_WRITEVERIFYOFF ||
981 driveflags[toupper(*testname) - 'A'] & DRIVE_WRITEVERIFYOFF)) {
982 DosSetVerify(FALSE);
983 fResetVerify = TRUE;
984 }
[1402]985 if (docopyf(MOVE, szData, testname))
[1394]986 Runtime_Error(pszSrcFile, __LINE__, "docopyf");
987 else {
988 CHAR *filename;
[2]989
[1394]990 filename = xstrdup(testname, pszSrcFile, __LINE__);
991 if (filename) {
992 if (!PostMsg(hwnd,
993 UM_FIXEDITNAME, MPVOID, MPFROMP(filename)))
994 free(filename);
995 }
996 if (stricmp(testname, pci->pszFileName)) {
997 PostMsg(hwnd, UM_FIXEDITNAME, MPFROMLONG(-1), MPFROMP(pci));
998 filename = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
999 if (filename) {
1000 if (!PostMsg(hwnd,
1001 UM_FIXEDITNAME, MPVOID, MPFROMP(filename)))
1002 free(filename);
1003 }
1004 }
1005 }
1006 if (fResetVerify) {
1007 DosSetVerify(fVerify);
1008 fResetVerify = FALSE;
1009 }
1010 }
1011 }
1012 }
[397]1013 }
1014 }
1015 return FALSE;
[2]1016
[397]1017 case CN_ENDEDIT:
1018 if (mp2) {
1019 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
1020 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[2]1021
[730]1022 if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
[1394]1023 WinSendMsg(hwnd,
1024 CM_INVALIDATERECORD,
1025 MPFROMP(&pci),
1026 MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
1027 if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName))
1028 PostMsg(hwnd, UM_SORTRECORD, MPVOID, MPVOID);
[397]1029 }
1030 else {
[1394]1031 USHORT cmd = 0;
[2]1032
[1394]1033 if (!pfi || pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName))
1034 cmd = IDM_SORTSMARTNAME;
1035 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, cbFile))
1036 cmd = IDM_SORTSIZE;
1037 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, easize))
1038 cmd = IDM_SORTEASIZE;
1039 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, date))
1040 cmd = IDM_SORTLWDATE;
1041 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, time))
1042 cmd = IDM_SORTLWDATE;
1043 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, ladate))
1044 cmd = IDM_SORTLADATE;
1045 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, latime))
1046 cmd = IDM_SORTLADATE;
1047 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, crdate))
1048 cmd = IDM_SORTCRDATE;
1049 else if (pfi->offStruct == FIELDOFFSET(CNRITEM, crtime))
1050 cmd = IDM_SORTCRDATE;
1051 if (cmd)
1052 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
[397]1053 }
[231]1054 }
[397]1055 break;
1056 }
1057 return (MRESULT) - 1;
[2]1058}
1059
[231]1060BOOL SetMenuCheck(HWND hwndMenu, USHORT id, BOOL * bool, BOOL toggle,
[1394]1061 PCSZ savename)
[231]1062{
[397]1063 if (toggle) {
[787]1064 *bool = *bool ? FALSE : TRUE;
[397]1065 if (savename && *savename)
[1498]1066 PrfWriteProfileData(fmprof, appname, (CHAR *) savename, bool, sizeof(BOOL));
[397]1067 }
1068 WinSendMsg(hwndMenu, MM_SETITEMATTR,
[1394]1069 MPFROM2SHORT(id, 1),
1070 MPFROM2SHORT(MIA_CHECKED, (*bool ? MIA_CHECKED : 0)));
[397]1071 return *bool;
[2]1072}
1073
[468]1074//== disable_menuitem() disable or enable_menuitem ==
1075
1076VOID disable_menuitem(HWND hwndMenu, USHORT id, BOOL disable)
[231]1077{
[397]1078 WinSendMsg(hwndMenu, MM_SETITEMATTR,
[1394]1079 MPFROM2SHORT(id, TRUE),
1080 MPFROM2SHORT(MIA_DISABLED, (disable ? MIA_DISABLED : 0)));
[2]1081}
1082
[451]1083//== ViewHelp() invoke view.exe, return TRUE if OK ==
1084
[1394]1085BOOL ViewHelp(PCSZ filename)
[231]1086{
[397]1087 CHAR s[CCHMAXPATH + 81];
[891]1088 CHAR szQuotedFileName[CCHMAXPATH];
[397]1089 FILE *fp;
1090 INT ret = -1;
[1544]1091 CHAR *moderb = "rb";
[2]1092
[1544]1093 fp = xfsopen(filename, moderb, SH_DENYNO, pszSrcFile, __LINE__, FALSE);
[397]1094 if (fp) {
1095 *s = 0;
1096 fread(s, 1, 3, fp);
1097 if (*s != 'H' || s[1] != 'S' || s[2] != 'P') {
1098 fclose(fp);
1099 return FALSE;
[2]1100 }
[397]1101 fclose(fp);
[888]1102 ret = runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
[1394]1103 NULL, NULL,
[1647]1104 "VIEW.EXE %s",
[1394]1105 BldQuotedFileName(szQuotedFileName, filename));
[397]1106 }
[2]1107
[397]1108 return (ret != -1);
[2]1109}
1110
[451]1111//== ExecFile() run file, return 1 if OK 0 if skipped -1 if can't run ==
1112
[1394]1113INT ExecFile(HWND hwnd, PCSZ filename)
[231]1114{
[397]1115 EXECARGS ex;
[989]1116 CHAR path[CCHMAXPATH], *p;
1117 PSZ pszCmdLine;
[397]1118 APIRET ret;
1119 static INT lastflags = 0;
[2]1120
[397]1121 strcpy(path, filename);
1122 p = strrchr(path, '\\');
1123 if (!p)
1124 p = strrchr(path, ':');
1125 if (p) {
1126 if (*p == ':') {
1127 p++;
1128 *p = '\\';
1129 p++;
[2]1130 }
[397]1131 *p = 0;
1132 }
1133 else
1134 *path = 0;
[989]1135 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1136 if (pszCmdLine) {
1137 BldQuotedFileName(pszCmdLine, filename);
1138 memset(&ex, 0, sizeof(ex));
1139 ex.flags = lastflags;
1140 ex.commandline = pszCmdLine;
1141 *ex.path = 0;
1142 *ex.environment = 0;
1143 ret = WinDlgBox(HWND_DESKTOP, hwnd, CmdLineDlgProc, FM3ModHandle,
[1394]1144 EXEC_FRAME, &ex);
[989]1145 if (ret == 1) {
1146 lastflags = ex.flags;
1147 return runemf2(ex.flags, hwnd, pszSrcFile, __LINE__, path,
[1394]1148 *ex.environment ? ex.environment : NULL,
1149 "%s", pszCmdLine) != -1;
[989]1150 }
1151 else if (ret != 0)
1152 return -1;
[1039]1153 free(pszCmdLine);
[397]1154 }
1155 return 0;
[2]1156}
1157
[1065]1158VOID SetDetailsSwitches(HWND hwnd, DETAILS_SETTINGS * pds)
[231]1159{
[1065]1160 WinCheckMenuItem(hwnd, IDM_SHOWLNAMES, pds->detailslongname);
1161 WinCheckMenuItem(hwnd, IDM_SHOWSUBJECT, pds->detailssubject);
1162 WinCheckMenuItem(hwnd, IDM_SHOWEAS, pds->detailsea);
1163 WinCheckMenuItem(hwnd, IDM_SHOWSIZE, pds->detailssize);
1164 WinCheckMenuItem(hwnd, IDM_SHOWICON, pds->detailsicon);
1165 WinCheckMenuItem(hwnd, IDM_SHOWLWDATE, pds->detailslwdate);
1166 WinCheckMenuItem(hwnd, IDM_SHOWLWTIME, pds->detailslwtime);
1167 WinCheckMenuItem(hwnd, IDM_SHOWLADATE, pds->detailsladate);
1168 WinCheckMenuItem(hwnd, IDM_SHOWLATIME, pds->detailslatime);
1169 WinCheckMenuItem(hwnd, IDM_SHOWCRDATE, pds->detailscrdate);
1170 WinCheckMenuItem(hwnd, IDM_SHOWCRTIME, pds->detailscrtime);
1171 WinCheckMenuItem(hwnd, IDM_SHOWATTR, pds->detailsattr);
[2]1172}
1173
[231]1174VOID AdjustDetailsSwitches(HWND hwnd, HWND hwndMenu, USHORT cmd,
[1394]1175 PCSZ directory, PCSZ keyroot,
1176 DETAILS_SETTINGS * pds, BOOL compare)
[231]1177{
[397]1178 BOOL *bool = NULL;
[2]1179
[397]1180 switch (cmd) {
1181 case IDM_SHOWLNAMES:
[1065]1182 bool = &pds->detailslongname;
[397]1183 break;
1184 case IDM_SHOWSUBJECT:
[1065]1185 bool = &pds->detailssubject;
[397]1186 break;
1187 case IDM_SHOWEAS:
[1065]1188 bool = &pds->detailsea;
[397]1189 break;
1190 case IDM_SHOWSIZE:
[1065]1191 bool = &pds->detailssize;
[397]1192 break;
1193 case IDM_SHOWICON:
[1065]1194 bool = &pds->detailsicon;
[397]1195 break;
1196 case IDM_SHOWLWDATE:
[1065]1197 bool = &pds->detailslwdate;
[397]1198 break;
1199 case IDM_SHOWLWTIME:
[1065]1200 bool = &pds->detailslwtime;
[397]1201 break;
1202 case IDM_SHOWLADATE:
[1065]1203 bool = &pds->detailsladate;
[397]1204 break;
1205 case IDM_SHOWLATIME:
[1065]1206 bool = &pds->detailslatime;
[397]1207 break;
1208 case IDM_SHOWCRDATE:
[1065]1209 bool = &pds->detailscrdate;
[397]1210 break;
1211 case IDM_SHOWCRTIME:
[1065]1212 bool = &pds->detailscrtime;
[397]1213 break;
1214 case IDM_SHOWATTR:
[1065]1215 bool = &pds->detailsattr;
[397]1216 break;
1217 default:
[231]1218 if (hwndMenu)
[1065]1219 SetDetailsSwitches(hwndMenu, pds);
[397]1220 return;
1221 }
1222 if (bool)
[787]1223 *bool = *bool ? FALSE : TRUE;
[397]1224 if (hwnd)
[1065]1225 AdjustCnrColsForPref(hwnd, directory, pds, compare);
[397]1226 if (hwndMenu)
[1065]1227 SetDetailsSwitches(hwndMenu, pds);
[2]1228}
1229
[921]1230/**
1231 * Set default menu item to invoke for top level conditional cascade menu
1232 * @param def is default menu id (i.e. IDM_...)
1233 */
1234
[231]1235VOID SetConditionalCascade(HWND hwndMenu, USHORT id, USHORT def)
1236{
[397]1237 MENUITEM mi;
[2]1238
[397]1239 mi.iPosition = MIT_END;
[921]1240 mi.hItem = 0;
1241 mi.hwndSubMenu = (HWND)0;
[397]1242 mi.afAttribute = 0;
1243 mi.afStyle = MIS_TEXT;
[921]1244 if (WinSendMsg(hwndMenu,
[1394]1245 MM_QUERYITEM,
1246 MPFROM2SHORT(id, TRUE),
1247 MPFROMP(&mi)))
[921]1248 {
[397]1249 WinSetWindowBits(mi.hwndSubMenu, QWL_STYLE, MS_CONDITIONALCASCADE,
[1394]1250 MS_CONDITIONALCASCADE);
[397]1251 WinSendMsg(mi.hwndSubMenu, MM_SETDEFAULTITEMID, MPFROMSHORT(def), MPVOID);
1252 WinCheckMenuItem(mi.hwndSubMenu, def, TRUE);
1253 }
[2]1254}
1255
[231]1256VOID SetSortChecks(HWND hwndMenu, INT sortflags)
1257{
[397]1258 WinCheckMenuItem(hwndMenu, IDM_SORTNONE, FALSE);
1259 WinCheckMenuItem(hwndMenu, IDM_SORTFIRST, FALSE);
1260 WinCheckMenuItem(hwndMenu, IDM_SORTLAST, FALSE);
1261 WinCheckMenuItem(hwndMenu, IDM_SORTSIZE, FALSE);
1262 WinCheckMenuItem(hwndMenu, IDM_SORTEASIZE, FALSE);
1263 WinCheckMenuItem(hwndMenu, IDM_SORTLWDATE, FALSE);
1264 WinCheckMenuItem(hwndMenu, IDM_SORTLADATE, FALSE);
1265 WinCheckMenuItem(hwndMenu, IDM_SORTCRDATE, FALSE);
1266 WinCheckMenuItem(hwndMenu, IDM_SORTFILENAME, FALSE);
1267 WinCheckMenuItem(hwndMenu, IDM_SORTNAME, FALSE);
1268 WinCheckMenuItem(hwndMenu, IDM_SORTSUBJECT, FALSE);
1269 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSFIRST, FALSE);
1270 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSLAST, FALSE);
1271 WinCheckMenuItem(hwndMenu, IDM_SORTREVERSE, FALSE);
1272 if (sortflags & SORT_FIRSTEXTENSION)
1273 WinCheckMenuItem(hwndMenu, IDM_SORTFIRST, TRUE);
1274 else if (sortflags & SORT_LASTEXTENSION)
1275 WinCheckMenuItem(hwndMenu, IDM_SORTLAST, TRUE);
1276 else if (sortflags & SORT_SIZE)
1277 WinCheckMenuItem(hwndMenu, IDM_SORTSIZE, TRUE);
1278 else if (sortflags & SORT_EASIZE)
1279 WinCheckMenuItem(hwndMenu, IDM_SORTEASIZE, TRUE);
1280 else if (sortflags & SORT_LWDATE)
1281 WinCheckMenuItem(hwndMenu, IDM_SORTLWDATE, TRUE);
1282 else if (sortflags & SORT_LADATE)
1283 WinCheckMenuItem(hwndMenu, IDM_SORTLADATE, TRUE);
1284 else if (sortflags & SORT_CRDATE)
1285 WinCheckMenuItem(hwndMenu, IDM_SORTCRDATE, TRUE);
1286 else if (sortflags & SORT_FILENAME)
1287 WinCheckMenuItem(hwndMenu, IDM_SORTFILENAME, TRUE);
1288 else if (sortflags & SORT_NOSORT)
1289 WinCheckMenuItem(hwndMenu, IDM_SORTNONE, TRUE);
1290 else if (sortflags & SORT_SUBJECT)
1291 WinCheckMenuItem(hwndMenu, IDM_SORTSUBJECT, TRUE);
1292 else
1293 WinCheckMenuItem(hwndMenu, IDM_SORTNAME, TRUE);
1294 if (sortflags & SORT_DIRSFIRST)
1295 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSFIRST, TRUE);
1296 else if (sortflags & SORT_DIRSLAST)
1297 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSLAST, TRUE);
1298 if (sortflags & SORT_REVERSE)
1299 WinCheckMenuItem(hwndMenu, IDM_SORTREVERSE, TRUE);
[2]1300}
1301
[231]1302VOID FcloseFile(FILE * fp)
1303{
[1673]1304 // for use by apps that don't use the DLLs runtime library
[397]1305 fclose(fp);
[2]1306}
1307
[231]1308VOID SetupCommandMenu(HWND hwndMenu, HWND hwndCnr)
1309{
[397]1310 MENUITEM mi, mit;
1311 INT x;
1312 SHORT numitems;
1313 LINKCMDS *info;
[2]1314
[397]1315 if (!cmdloaded)
1316 load_commands();
1317 mi.iPosition = MIT_END;
1318 mi.hwndSubMenu = (HWND) 0;
1319 mi.hItem = 0L;
1320 mi.afAttribute = 0;
1321 mi.afStyle = MIS_TEXT;
1322 memset(&mit, 0, sizeof(MENUITEM));
1323 if (WinQueryWindowUShort(hwndMenu, QWS_ID) == IDM_COMMANDSMENU)
1324 mit.hwndSubMenu = hwndMenu;
1325 else
1326 WinSendMsg(hwndMenu, MM_QUERYITEM,
[1394]1327 MPFROM2SHORT(IDM_COMMANDSMENU, TRUE), MPFROMP(&mit));
[397]1328 if (mit.hwndSubMenu) {
1329 numitems = (SHORT) WinSendMsg(mit.hwndSubMenu, MM_QUERYITEMCOUNT,
[1394]1330 MPVOID, MPVOID);
[397]1331 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM, MPFROMSHORT(-1), MPVOID);
[1486]1332 info = cmdhead;
1333 while (info) {
[397]1334 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM,
[1486]1335 MPFROMSHORT((SHORT) (info->ID)), MPVOID);
[1488]1336 x++;
[1486]1337 info = info->next;
1338 }
[1488]1339 while (numitems != MIT_ERROR) { // Delete items that were deleted from commands since the ID is gone
1340 numitems = (SHORT) WinSendMsg(mit.hwndSubMenu, MM_ITEMIDFROMPOSITION,
1341 MPFROMSHORT((SHORT) 1), MPVOID);
1342 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM,
1343 MPFROMSHORT(numitems), MPVOID);
1344 }
[397]1345 if (hwndCnr && cmdhead) {
1346 x = 0;
1347 info = cmdhead;
1348 while (info) {
[2]1349
[1488]1350 CHAR s[CCHMAXPATH + 24];
[2]1351
[1394]1352 sprintf(s,
[1488]1353 "%s {%i} %s%s%s",
[1486]1354 info->title, info->ID,
[1488]1355 info->HotKeyID && info->HotKeyID < IDM_COMMANDNUM20 ? "\tCtrl + " : NullStr,
1356 info->HotKeyID && info->HotKeyID > IDM_COMMANDNUM19 ? "\tAlt + " : NullStr,
1357 info->HotKeyID && ((info->HotKeyID > IDM_COMMANDNUM9 &&
1358 info->HotKeyID < IDM_COMMANDNUM20) ||
1359 info->HotKeyID > IDM_COMMANDNUM29) ? "Shift + " : NullStr);
[1486]1360 if (info->HotKeyID)
[1394]1361 sprintf(&s[strlen(s)], "%d",
[1488]1362 (((info->HotKeyID - IDM_COMMANDNUM0) % 10) + 1) == 10 ? 0 :
1363 ((info->HotKeyID - IDM_COMMANDNUM0) % 10) + 1);
[1533]1364 mi.id = (USHORT) info->ID;
[1394]1365 mi.afAttribute = (info->flags & ONCE ? MIA_CHECKED : 0) |
1366 (info->flags & PROMPT ? MIA_FRAMED : 0);
1367 mi.afStyle = MIS_TEXT;
[1488]1368 if (!(x % 20) && x && info->next)
[1394]1369 mi.afStyle |= MIS_BREAK;
1370 WinSendMsg(mit.hwndSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s));
1371 x++;
1372 info = info->next;
[397]1373 }
[2]1374 }
[397]1375 }
[2]1376}
1377
[1409]1378/**
1379 * Loads all the detail switches from the ini file
1380 * state if TRUE skips global only settings
1381 * keyroot shouldn't pass trailing dot
1382 */
1383VOID LoadDetailsSwitches(PCSZ keyroot, DETAILS_SETTINGS *pds, BOOL state)
[231]1384{
[397]1385 ULONG size;
1386 CHAR s[CCHMAXPATH], *eos = s;
[2]1387
[997]1388 strcpy(s, keyroot);
1389 strcat(s, ".");
1390 eos = &s[strlen(s)];
[1065]1391 strcpy(eos, "DetailsLongname");
1392 pds->detailslongname = dsDirCnrDefault.detailslongname;
[397]1393 size = sizeof(BOOL);
[1065]1394 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslongname, &size);
[1030]1395 strcpy(eos, "DetailsSubject");
[1065]1396 pds->detailssubject = dsDirCnrDefault.detailssubject;
[397]1397 size = sizeof(BOOL);
[1065]1398 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailssubject, &size);
[1030]1399 strcpy(eos, "DetailsEA");
[1065]1400 pds->detailsea = dsDirCnrDefault.detailsea;
[397]1401 size = sizeof(BOOL);
[1065]1402 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsea, &size);
[1030]1403 strcpy(eos, "DetailsSize");
[1065]1404 pds->detailssize = dsDirCnrDefault.detailssize;
[397]1405 size = sizeof(BOOL);
[1065]1406 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailssize, &size);
[1030]1407 strcpy(eos, "DetailsIcon");
[1065]1408 pds->detailsicon = dsDirCnrDefault.detailsicon;
[397]1409 size = sizeof(BOOL);
[1065]1410 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsicon, &size);
[1030]1411 strcpy(eos, "DetailsAttr");
[1065]1412 pds->detailsattr = dsDirCnrDefault.detailsattr;
[397]1413 size = sizeof(BOOL);
[1065]1414 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsattr, &size);
[1030]1415 strcpy(eos, "DetailsCRDate");
[1065]1416 pds->detailscrdate = dsDirCnrDefault.detailscrdate;
[397]1417 size = sizeof(BOOL);
[1065]1418 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailscrdate, &size);
[1030]1419 strcpy(eos, "DetailsCRTime");
[1065]1420 pds->detailscrtime = dsDirCnrDefault.detailscrtime;
[397]1421 size = sizeof(BOOL);
[1065]1422 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailscrtime, &size);
[1030]1423 strcpy(eos, "DetailsLWDate");
[1065]1424 pds->detailslwdate = dsDirCnrDefault.detailslwdate;
[397]1425 size = sizeof(BOOL);
[1065]1426 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslwdate, &size);
[1030]1427 strcpy(eos, "DetailsLWTime");
[1065]1428 pds->detailslwtime = dsDirCnrDefault.detailslwtime;
[397]1429 size = sizeof(BOOL);
[1065]1430 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslwtime, &size);
[1030]1431 strcpy(eos, "DetailsLADate");
[1065]1432 pds->detailsladate = dsDirCnrDefault.detailsladate;
[397]1433 size = sizeof(BOOL);
[1065]1434 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsladate, &size);
[1030]1435 strcpy(eos, "DetailsLATime");
[1065]1436 pds->detailslatime = dsDirCnrDefault.detailslatime;
[397]1437 size = sizeof(BOOL);
[1065]1438 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslatime, &size);
[1409]1439 if (!state) {
1440 strcpy(eos, "SubjectInLeftPane");
1441 pds->fSubjectInLeftPane = dsDirCnrDefault.fSubjectInLeftPane;
1442 size = sizeof(BOOL);
1443 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->fSubjectInLeftPane, &size);
1444 strcpy(eos, "SubjectLengthMax");
1445 pds->fSubjectLengthMax = dsDirCnrDefault.fSubjectLengthMax;
1446 size = sizeof(BOOL);
1447 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->fSubjectLengthMax, &size);
1448 if (pds->fSubjectLengthMax)
[1065]1449 pds->SubjectDisplayWidth = 0;
[1409]1450 else {
1451 strcpy(eos, "SubjectDisplayWidth");
1452 pds->SubjectDisplayWidth = dsDirCnrDefault.SubjectDisplayWidth;
1453 size = sizeof(ULONG);
1454 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->SubjectDisplayWidth, &size);
1455 if (pds->SubjectDisplayWidth < 50)
1456 pds->SubjectDisplayWidth = 0;
1457 else if (pds->SubjectDisplayWidth > 1000)
1458 pds->SubjectDisplayWidth = 1000;
1459 }
[922]1460 }
[2]1461}
1462
[1409]1463/**
1464 * Writes all the detail switches to the ini file
1465 * state if TRUE skips global only settings
1466 * keyroot shouldn't pass trailing dot
1467 */
1468VOID WriteDetailsSwitches(PCSZ keyroot, DETAILS_SETTINGS *pds, BOOL state)
[1400]1469{
1470 CHAR s[CCHMAXPATH], *eos = s;
1471
1472 strcpy(s, keyroot);
1473 strcat(s, ".");
1474 eos = &s[strlen(s)];
1475 strcpy(eos, "DetailsLongname");
[1409]1476 PrfWriteProfileData(fmprof, appname, s, &pds->detailslongname, sizeof(BOOL));
[1400]1477 strcpy(eos, "DetailsSubject");
[1409]1478 PrfWriteProfileData(fmprof, appname, s, &pds->detailssubject, sizeof(BOOL));
[1400]1479 strcpy(eos, "DetailsEA");
[1409]1480 PrfWriteProfileData(fmprof, appname, s, &pds->detailsea, sizeof(BOOL));
[1400]1481 strcpy(eos, "DetailsSize");
[1409]1482 PrfWriteProfileData(fmprof, appname, s, &pds->detailssize, sizeof(BOOL));
[1400]1483 strcpy(eos, "DetailsIcon");
[1409]1484 PrfWriteProfileData(fmprof, appname, s, &pds->detailsicon, sizeof(BOOL));
[1400]1485 strcpy(eos, "DetailsAttr");
[1409]1486 PrfWriteProfileData(fmprof, appname, s, &pds->detailsattr, sizeof(BOOL));
[1400]1487 strcpy(eos, "DetailsCRDate");
[1409]1488 PrfWriteProfileData(fmprof, appname, s, &pds->detailscrdate, sizeof(BOOL));
[1400]1489 strcpy(eos, "DetailsCRTime");
[1409]1490 PrfWriteProfileData(fmprof, appname, s, &pds->detailscrtime, sizeof(BOOL));
[1400]1491 strcpy(eos, "DetailsLWDate");
[1409]1492 PrfWriteProfileData(fmprof, appname, s, &pds->detailslwdate, sizeof(BOOL));
[1400]1493 strcpy(eos, "DetailsLWTime");
[1409]1494 PrfWriteProfileData(fmprof, appname, s, &pds->detailslwtime, sizeof(BOOL));
[1400]1495 strcpy(eos, "DetailsLADate");
[1409]1496 PrfWriteProfileData(fmprof, appname, s, &pds->detailsladate, sizeof(BOOL));
[1400]1497 strcpy(eos, "DetailsLATime");
[1409]1498 PrfWriteProfileData(fmprof, appname, s, &pds->detailslatime, sizeof(BOOL));
1499 if (!state) {
1500 strcpy(eos, "SubjectInLeftPane");
1501 PrfWriteProfileData(fmprof, appname, s, &pds->fSubjectInLeftPane, sizeof(BOOL));
1502 strcpy(eos, "SubjectLengthMax");
1503 PrfWriteProfileData(fmprof, appname, s, &pds->fSubjectLengthMax, sizeof(BOOL));
1504 strcpy(eos, "SubjectDisplayWidth");
1505 PrfWriteProfileData(fmprof, appname, s, &pds->SubjectDisplayWidth, sizeof(ULONG));
1506 }
1507}
1508
1509/**
1510 * Removes the ini entries when a state is deleted
1511 * statename should be NULL for the shutdown state
1512 * (avoids removing global state settings like toolbar)
1513 * keyroot shouldn't pass the trailing dot
1514 */
1515VOID RemoveCnrSwitches(PCSZ keyroot, PCSZ statename)
1516{
1517 CHAR s[CCHMAXPATH], *eos = s;
1518
1519 strcpy(s, keyroot);
1520 strcat(s, ".");
1521 eos = &s[strlen(s)];
1522 DeletePresParams(s);
1523 strcpy(eos, "DetailsLongname");
1524 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1525 strcpy(eos, "DetailsSubject");
1526 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1527 strcpy(eos, "DetailsEA");
1528 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1529 strcpy(eos, "DetailsSize");
1530 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1531 strcpy(eos, "DetailsIcon");
1532 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1533 strcpy(eos, "DetailsAttr");
1534 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1535 strcpy(eos, "DetailsCRDate");
1536 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1537 strcpy(eos, "DetailsCRTime");
1538 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1539 strcpy(eos, "DetailsLWDate");
1540 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1541 strcpy(eos, "DetailsLWTime");
1542 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1543 strcpy(eos, "DetailsLADate");
1544 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
1545 strcpy(eos, "DetailsLATime");
1546 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
[1410]1547
1548#ifdef NEVER
1549 // activate this code if we ever allow setting of subject location/length per container GKY 3-28-09
[1400]1550 strcpy(eos, "SubjectInLeftPane");
[1409]1551 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
[1400]1552 strcpy(eos, "SubjectLengthMax");
[1409]1553 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
[1400]1554 strcpy(eos, "SubjectDisplayWidth");
[1409]1555 PrfWriteProfileData(fmprof, appname, s, NULL, 0);
[1410]1556#endif
1557
[1409]1558 strcpy(eos, "Pos");;
[1505]1559 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
[1409]1560 strcpy(eos, "Sort");
[1505]1561 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
[1409]1562 strcpy(eos, "Filter");
[1505]1563 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
[1409]1564 strcpy(eos, "View");
[1505]1565 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
[1409]1566 strcpy(eos, "Dir");
[1505]1567 PrfWriteProfileString(fmprof, FM3Str, s, NULL);
[1409]1568 if (statename && strstr(s, ".0.")) {
1569 strcpy(s, statename);
1570 strcat(s, ".");
1571 eos = &s[strlen(s)];
1572 strcpy(eos, "LastTreePos");
[1505]1573 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
[1409]1574 strcpy(eos, "MySizeLastTime");
[1505]1575 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
[1409]1576 strcpy(eos, "Toolbar");
[1505]1577 PrfWriteProfileString(fmprof, FM3Str, s, NULL);
[1409]1578 strcpy(eos, "TargetDir");
[1505]1579 PrfWriteProfileString(fmprof, FM3Str, s, NULL);
[1409]1580 }
1581
[1400]1582}
1583
[1410]1584/**
1585 * Removes the pre 3.16 style ini entries when a state is deleted
1586 */
1587VOID RemoveOldCnrSwitches(PCSZ szPrefix, ULONG ulTemp)
1588{
1589 CHAR szKey[STATE_NAME_MAX_BYTES + 80];
1590
1591 sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, ulTemp);
[1505]1592 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0);
[1410]1593 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, ulTemp);
[1505]1594 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0);
[1410]1595 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, ulTemp);
[1505]1596 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0);
[1410]1597 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, ulTemp);
[1505]1598 PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0);
[1410]1599 sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, ulTemp);
[1505]1600 PrfWriteProfileString(fmprof, FM3Str, szKey, NULL);
[1410]1601 sprintf(szKey, "%sDirCnr.%lu.", szPrefix, ulTemp);
1602}
1603
[231]1604HWND FindDirCnr(HWND hwndParent)
1605{
[397]1606 HWND found, hwndDir = (HWND) 0;
1607 HENUM henum;
[2]1608
[397]1609 henum = WinBeginEnumWindows(hwndParent);
1610 while ((found = WinGetNextWindow(henum)) != NULLHANDLE) {
1611 hwndDir = WinWindowFromID(found, FID_CLIENT);
1612 if (hwndDir) {
1613 hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
1614 if (hwndDir)
[1394]1615 break;
[397]1616 hwndDir = (HWND) 0;
[2]1617 }
[397]1618 }
1619 WinEndEnumWindows(henum);
[2]1620
[397]1621 return hwndDir;
[2]1622}
1623
[231]1624VOID HeapThread(VOID * dummy)
1625{
[397]1626 ULONG postcount;
1627 APIRET rc;
[2]1628
[397]1629 rc = DosCreateEventSem(NULL, &CompactSem, 0L, FALSE);
1630 if (rc)
1631 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1394]1632 "DosCreateEventSem");
[397]1633 else {
1634 priority_normal();
1635 for (;;) {
1636 if (DosWaitEventSem(CompactSem, SEM_INDEFINITE_WAIT))
[1394]1637 break;
[397]1638 _heapmin();
1639 DosResetEventSem(CompactSem, &postcount);
[2]1640 }
[397]1641 }
[2]1642}
1643
[1394]1644VOID FixSwitchList(HWND hwnd, PCSZ text)
[231]1645{
[397]1646 HSWITCH hswitch;
1647 SWCNTRL swctl;
[2]1648
[397]1649 hswitch = WinQuerySwitchHandle(hwnd, 0);
1650 if (hswitch) {
1651 if (!WinQuerySwitchEntry(hswitch, &swctl)) {
1652 strcpy(swctl.szSwtitle, "FM/2");
1653 WinChangeSwitchEntry(hswitch, &swctl);
[2]1654 }
[397]1655 }
[2]1656}
1657
[231]1658VOID QuickPopup(HWND hwnd, DIRCNRDATA * dcd, HWND hwndMenu, USHORT id)
1659{
[397]1660 dcd->hwndLastMenu = hwndMenu;
1661 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
1662 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
[1394]1663 MPFROM2SHORT(TRUE, CRA_SOURCE));
[397]1664 dcd->cnremphasized = TRUE;
1665 }
1666 if (dcd->flWindowAttr & CV_MINI)
1667 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
1668 if (!WinPopupMenu(hwnd, hwnd, dcd->hwndLastMenu,
[1394]1669 8, 8, 0,
1670 PU_HCONSTRAIN | PU_VCONSTRAIN |
1671 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
[397]1672 if (dcd->cnremphasized) {
1673 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
[1394]1674 MPFROM2SHORT(FALSE, CRA_SOURCE));
[397]1675 dcd->cnremphasized = FALSE;
[2]1676 }
[397]1677 }
1678 else
1679 WinSendMsg(dcd->hwndLastMenu, MM_SELECTITEM,
[1394]1680 MPFROM2SHORT(id, TRUE), MPFROM2SHORT(0, FALSE));
[2]1681}
1682
[231]1683PMINIRECORDCORE CurrentRecord(HWND hwndCnr)
1684{
[787]1685 SHORT attrib = fSelectedAlways ? CRA_SELECTED : CRA_CURSORED;
[397]1686 PMINIRECORDCORE pmi;
[2]1687
[397]1688 for (;;) {
1689 pmi = (PMINIRECORDCORE) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
[1394]1690 MPFROMLONG(CMA_FIRST),
1691 MPFROMSHORT(attrib));
[1673]1692 if ((!pmi || (INT) pmi == -1) && attrib == CRA_SELECTED) // punt
[397]1693 attrib = CRA_CURSORED;
1694 else
1695 break;
1696 }
[787]1697 return ((INT)pmi == -1) ? NULL : pmi;
[2]1698}
1699
[231]1700BOOL PostMsg(HWND h, ULONG msg, MPARAM mp1, MPARAM mp2)
1701{
[397]1702 BOOL rc = WinPostMsg(h, msg, mp1, mp2);
[2]1703
[397]1704 if (!rc) {
[2]1705
[882]1706 // If window owned by some other process or some other thread?
1707 if (!IsFm2Window(h, 1)) {
1708 QMSG qmsg;
1709 for (;;) {
[1394]1710 DosSleep(1);
1711 rc = WinPostMsg(h, msg, mp1, mp2);
1712 if (rc)
1713 break; // OK
1714 if (!WinIsWindow((HAB) 0, h))
1715 break; // Window gone
1716 if (WinPeekMsg((HAB) 0, &qmsg, (HWND) 0, 0, 0, PM_NOREMOVE))
1717 break; // Queue has message(s)
[1159]1718 } // for
[2]1719 }
[882]1720 }
[397]1721 return rc;
[2]1722}
1723
[231]1724VOID OpenEdit(HWND hwnd)
1725{
[397]1726 CNREDITDATA ced;
1727 PCNRITEM pci;
1728 PFIELDINFO pfi;
[2]1729
[397]1730 pci = (PCNRITEM) WinSendMsg(hwnd,
[1394]1731 CM_QUERYRECORDEMPHASIS,
1732 MPFROMLONG(CMA_FIRST),
1733 MPFROMSHORT(CRA_CURSORED));
[397]1734 if (pci && (INT) pci != -1) {
1735 memset(&ced, 0, sizeof(ced));
1736 ced.cb = sizeof(ced);
1737 ced.hwndCnr = hwnd;
1738 ced.id = WinQueryWindowUShort(hwnd, QWS_ID);
1739 ced.pRecord = (PRECORDCORE) pci;
1740 pfi = (PFIELDINFO) WinSendMsg(hwnd,
[1394]1741 CM_QUERYDETAILFIELDINFO,
1742 MPVOID, MPFROMSHORT(CMA_FIRST));
[397]1743 if (!pfi)
1744 WinSendMsg(hwnd, CM_OPENEDIT, MPFROMP(&ced), MPVOID);
1745 else {
1746 while (pfi && (INT) pfi != -1 &&
[1394]1747 pfi->offStruct != FIELDOFFSET(CNRITEM, pszFileName))
1748 pfi = (PFIELDINFO) WinSendMsg(hwnd,
1749 CM_QUERYDETAILFIELDINFO,
1750 MPFROMP(pfi), MPFROMSHORT(CMA_NEXT));
[397]1751 if (pfi && (INT) pfi != -1) {
[1394]1752 ced.pFieldInfo = pfi;
1753 {
1754 CNRINFO cnri;
[2]1755
[1394]1756 memset(&cnri, 0, sizeof(CNRINFO));
1757 cnri.cb = sizeof(CNRINFO);
1758 WinSendMsg(hwnd,
1759 CM_QUERYCNRINFO,
1760 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1761 if (cnri.flWindowAttr & CV_DETAIL)
1762 ced.id = CID_LEFTDVWND;
1763 }
1764 WinSendMsg(hwnd, CM_OPENEDIT, MPFROMP(&ced), MPVOID);
[397]1765 }
[2]1766 }
[397]1767 }
[2]1768}
1769
1770#ifdef NEVER
[1394]1771VOID QuickView(HWND hwnd, PCSZ filename)
[231]1772{
[397]1773 if (filename && IsFile(filename) == 1) {
1774 if (TestBinary(filename) && *binview) {
[2]1775
[397]1776 CHAR *list[2];
[2]1777
[397]1778 list[0] = filename;
1779 list[1] = NULL;
[1497]1780 ExecOnList(hwnd, binview, WINDOWED | SEPARATE, NULL, NULL, list, NULL,
[1394]1781 pszSrcFile, __LINE__);
[397]1782 return;
1783 }
1784 else if (*viewer) {
[2]1785
[397]1786 CHAR *list[2];
[2]1787
[397]1788 list[0] = filename;
1789 list[1] = NULL;
[787]1790 ExecOnList(hwnd, viewer,
[1394]1791 WINDOWED | SEPARATE | (fViewChild ? CHILD : 0),
[1497]1792 NULL, NULL, list, NULL, pszSrcFile, __LINE__);
[397]1793 return;
[2]1794 }
[397]1795 StartMLEEditor(HWND_DESKTOP, 5, filename, (HWND) 0);
1796 }
[2]1797}
1798
[231]1799VOID QuickEdit(HWND hwnd, CHAR * filename)
1800{
[397]1801 if (filename && IsFile(filename) == 1) {
1802 if (TestBinary(filename) && *bined) {
[2]1803
[397]1804 CHAR *list[2];
[2]1805
[397]1806 list[0] = filename;
1807 list[1] = NULL;
[1497]1808 ExecOnList(hwnd, bined, WINDOWED | SEPARATE, NULL, NULL, list, NULL,
[1394]1809 pszSrcFile, __LINE__);
[397]1810 return;
1811 }
1812 else if (*editor) {
[2]1813
[397]1814 CHAR *list[2];
[2]1815
[397]1816 list[0] = filename;
1817 list[1] = NULL;
[1497]1818 ExecOnList(hwnd, editor, WINDOWED | SEPARATE, NULL, NULL, list, NULL,
[1394]1819 pszSrcFile, __LINE__);
[397]1820 return;
[2]1821 }
[397]1822 StartMLEEditor(HWND_DESKTOP, 4, filename, (HWND) 0);
1823 }
[2]1824}
1825#endif
1826
[231]1827VOID PortholeInit(HWND hwndNew, MPARAM mp1, MPARAM mp2)
1828{
[397]1829 static HWND DefMenu = (HWND) 0;
1830 HWND hwndMenu = (HWND) mp2;
[2]1831
[397]1832 {
1833 ULONG style;
1834
1835 style = WinQueryWindowULong(hwndMenu, QWL_STYLE);
1836 if (!(style & MS_ACTIONBAR))
1837 return;
1838 }
1839
1840 switch (SHORT1FROMMP(mp1)) {
1841 case 0:
[231]1842 {
[397]1843 HWND hwndNow;
1844 MENUITEM mi;
1845 ULONG ulStyle;
[2]1846
[397]1847 memset(&mi, 0, sizeof(mi));
1848 mi.iPosition = MIT_END;
1849 mi.afStyle = MIS_TEXT;
1850 WinSendMsg(hwndMenu, MM_QUERYITEM,
[1394]1851 MPFROM2SHORT(IDM_FILESMENU, TRUE), MPFROMP(&mi));
[397]1852 if (!DefMenu)
[1394]1853 DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
[397]1854 hwndNow = mi.hwndSubMenu;
1855 mi.hwndSubMenu = hwndNew;
1856 if (!mi.hwndSubMenu)
[1394]1857 mi.hwndSubMenu = DefMenu;
[397]1858 WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
1859 WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
1860 WinSetOwner(mi.hwndSubMenu, hwndMenu);
1861 WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
1862 WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_FILESMENU);
1863 mi.afStyle = MIS_SUBMENU;
1864 ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
1865 ulStyle &= -WS_SAVEBITS;
1866 ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
1867 WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
1868 WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
[231]1869 }
[397]1870 break;
[2]1871
[397]1872 case 1:
[231]1873 {
[397]1874 HWND hwndNow;
1875 MENUITEM mi;
1876 ULONG ulStyle;
[2]1877
[397]1878 memset(&mi, 0, sizeof(mi));
1879 mi.iPosition = MIT_END;
1880 mi.afStyle = MIS_TEXT;
1881 WinSendMsg(hwndMenu, MM_QUERYITEM,
[1394]1882 MPFROM2SHORT(IDM_VIEWSMENU, TRUE), MPFROMP(&mi));
[397]1883 if (!DefMenu)
[1394]1884 DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
[397]1885 hwndNow = mi.hwndSubMenu;
1886 mi.hwndSubMenu = hwndNew;
1887 if (!mi.hwndSubMenu)
[1394]1888 mi.hwndSubMenu = DefMenu;
[397]1889 WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
1890 WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
1891 WinSetOwner(mi.hwndSubMenu, hwndMenu);
1892 WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
1893 WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_VIEWSMENU);
1894 mi.afStyle = MIS_SUBMENU;
1895 ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
1896 ulStyle &= -WS_SAVEBITS;
1897 ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
1898 WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
1899 WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
[231]1900 }
[397]1901 break;
1902 }
[2]1903}
1904
[872]1905HWND CheckMenu(HWND hwnd, HWND * hwndMenu, USHORT id)
[231]1906{
[1673]1907 // load and adjust menus as required
[397]1908 if (!*hwndMenu || !WinIsWindow((HAB) 0, *hwndMenu)) {
1909 *hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
[877]1910 CopyPresParams(*hwndMenu, hwnd);
[397]1911 if (hwndMenu == &DirMenu) {
1912 WinSetWindowUShort(DirMenu, QWS_ID, IDM_FILESMENU);
1913 SetConditionalCascade(DirMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1914 SetConditionalCascade(DirMenu, IDM_COPYMENU, IDM_COPY);
1915 SetConditionalCascade(DirMenu, IDM_MOVEMENU, IDM_MOVE);
1916 SetConditionalCascade(DirMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1917 SetConditionalCascade(DirMenu, IDM_VIEWSUBMENU, IDM_INFO);
1918 SetConditionalCascade(DirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1919 SetConditionalCascade(DirMenu, IDM_DELETESUBMENU,
[1394]1920 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1921 SetConditionalCascade(DirMenu, IDM_MISCSUBMENU, IDM_SIZES);
1922 SetConditionalCascade(DirMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
1923 if (fWorkPlace) {
[1394]1924 WinSendMsg(DirMenu, MM_DELETEITEM,
1925 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1926 WinSendMsg(DirMenu, MM_DELETEITEM,
1927 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]1928 }
[2]1929 }
[397]1930 else if (hwndMenu == &TreeMenu) {
1931 WinSetWindowUShort(TreeMenu, QWS_ID, IDM_FILESMENU);
1932 SetConditionalCascade(TreeMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1933 SetConditionalCascade(TreeMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1934 SetConditionalCascade(TreeMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1935 SetConditionalCascade(TreeMenu, IDM_EXPANDSUBMENU, IDM_EXPAND);
1936 SetConditionalCascade(TreeMenu, IDM_MISCSUBMENU, IDM_SIZES);
1937 SetConditionalCascade(TreeMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
1938 if (fWorkPlace) {
[1394]1939 WinSendMsg(TreeMenu, MM_DELETEITEM,
1940 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1941 WinSendMsg(TreeMenu, MM_DELETEITEM,
1942 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]1943 }
[1360]1944 if (!fLVM)
[1394]1945 WinSendMsg(TreeMenu, MM_DELETEITEM,
1946 MPFROM2SHORT(IDM_REFRESHREMOVABLES, TRUE), MPVOID);
[397]1947 }
1948 else if (hwndMenu == &ArcMenu) {
1949 WinSetWindowUShort(ArcMenu, QWS_ID, IDM_FILESMENU);
1950 SetConditionalCascade(ArcMenu, IDM_EXTRACTSUBMENU, IDM_EXTRACT);
1951 SetConditionalCascade(ArcMenu, IDM_EDITSUBMENU, IDM_EDIT);
1952 SetConditionalCascade(ArcMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1953 if (fWorkPlace)
[1394]1954 WinSendMsg(ArcMenu, MM_DELETEITEM,
1955 MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
[397]1956 }
1957 else if (hwndMenu == &FileMenu) {
1958 WinSetWindowUShort(FileMenu, QWS_ID, IDM_FILESMENU);
1959 SetConditionalCascade(FileMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1960 SetConditionalCascade(FileMenu, IDM_COPYMENU, IDM_COPY);
1961 SetConditionalCascade(FileMenu, IDM_MOVEMENU, IDM_MOVE);
1962 SetConditionalCascade(FileMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1963 SetConditionalCascade(FileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1964 SetConditionalCascade(FileMenu, IDM_EDITSUBMENU, IDM_EDIT);
1965 SetConditionalCascade(FileMenu, IDM_COLLECTMENU, IDM_COLLECT);
1966 SetConditionalCascade(FileMenu, IDM_DELETESUBMENU,
[1394]1967 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1968 SetConditionalCascade(FileMenu, IDM_OPENSUBMENU, IDM_OPENDEFAULT);
1969 SetConditionalCascade(FileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
1970 if (fWorkPlace) {
[1394]1971 WinSendMsg(FileMenu, MM_DELETEITEM,
1972 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1973 WinSendMsg(FileMenu, MM_DELETEITEM,
1974 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]1975 }
[1360]1976 if (!fLVM)
[1394]1977 WinSendMsg(FileMenu, MM_DELETEITEM,
1978 MPFROM2SHORT(IDM_REFRESHREMOVABLES, TRUE), MPVOID);
[397]1979 }
1980 else if (hwndMenu == &DirCnrMenu) {
1981 WinSetWindowUShort(DirCnrMenu, QWS_ID, IDM_VIEWSMENU);
1982 SetConditionalCascade(DirCnrMenu, IDM_MISCSUBMENU, IDM_SIZES);
1983 SetConditionalCascade(DirCnrMenu, IDM_OPENSUBMENU, IDM_OPENSETTINGSME);
1984 if (fWorkPlace)
[1394]1985 WinSendMsg(DirCnrMenu, MM_DELETEITEM,
1986 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
[397]1987 }
[489]1988 else if (hwndMenu == &TreeCnrMenu) {
[397]1989 WinSetWindowUShort(TreeCnrMenu, QWS_ID, IDM_VIEWSMENU);
[1360]1990 if (!fLVM)
[1394]1991 WinSendMsg(TreeCnrMenu, MM_DELETEITEM,
1992 MPFROM2SHORT(IDM_REFRESHREMOVABLES, TRUE), MPVOID);
[468]1993 }
[397]1994 else if (hwndMenu == &ArcCnrMenu) {
1995 WinSetWindowUShort(ArcCnrMenu, QWS_ID, IDM_VIEWSMENU);
1996 SetConditionalCascade(ArcCnrMenu, IDM_EXTRACTSUBMENU, IDM_ARCEXTRACT);
1997 if (fWorkPlace)
[1394]1998 WinSendMsg(ArcCnrMenu, MM_DELETEITEM,
1999 MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
[397]2000 }
2001 else if (hwndMenu == &CollectorCnrMenu) {
2002 WinSetWindowUShort(CollectorCnrMenu, QWS_ID, IDM_VIEWSMENU);
2003 SetConditionalCascade(CollectorCnrMenu, IDM_COLLECTMENU,
[1394]2004 IDM_COLLECTFROMCLIP);
[397]2005 }
2006 else if (hwndMenu == &CollectorFileMenu) {
2007 WinSetWindowUShort(CollectorFileMenu, QWS_ID, IDM_FILESMENU);
2008 SetConditionalCascade(CollectorFileMenu, IDM_COMMANDSMENU,
[1394]2009 IDM_DOITYOURSELF);
[397]2010 SetConditionalCascade(CollectorFileMenu, IDM_COPYMENU, IDM_COPY);
2011 SetConditionalCascade(CollectorFileMenu, IDM_MOVEMENU, IDM_MOVE);
2012 SetConditionalCascade(CollectorFileMenu, IDM_SAVESUBMENU,
[1394]2013 IDM_SAVETOCLIP);
[397]2014 SetConditionalCascade(CollectorFileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
2015 SetConditionalCascade(CollectorFileMenu, IDM_EDITSUBMENU, IDM_EDIT);
2016 SetConditionalCascade(CollectorFileMenu, IDM_DELETESUBMENU,
[1394]2017 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]2018 SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBMENU,
[1546]2019 IDM_OPENDEFAULT);
2020 SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBCNRMENU,
2021 IDM_OPENWINDOW);
[397]2022 SetConditionalCascade(CollectorFileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
2023 if (fWorkPlace) {
[1394]2024 WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
2025 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
2026 WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
2027 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]2028 }
2029 }
2030 else if (hwndMenu == &CollectorDirMenu) {
2031 WinSetWindowUShort(CollectorDirMenu, QWS_ID, IDM_FILESMENU);
2032 SetConditionalCascade(CollectorDirMenu, IDM_COMMANDSMENU,
[1394]2033 IDM_DOITYOURSELF);
[397]2034 SetConditionalCascade(CollectorDirMenu, IDM_COPYMENU, IDM_COPY);
2035 SetConditionalCascade(CollectorDirMenu, IDM_MOVEMENU, IDM_MOVE);
2036 SetConditionalCascade(CollectorDirMenu, IDM_SAVESUBMENU,
[1394]2037 IDM_SAVETOCLIP);
[397]2038 SetConditionalCascade(CollectorDirMenu, IDM_VIEWSUBMENU, IDM_INFO);
2039 SetConditionalCascade(CollectorDirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
2040 SetConditionalCascade(CollectorDirMenu, IDM_DELETESUBMENU,
[1394]2041 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]2042 SetConditionalCascade(CollectorDirMenu, IDM_MISCSUBMENU, IDM_SIZES);
2043 SetConditionalCascade(CollectorDirMenu, IDM_OPENSUBMENU,
[1394]2044 IDM_OPENWINDOW);
[397]2045 if (fWorkPlace) {
[1394]2046 WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
2047 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
2048 WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
2049 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
[397]2050 }
2051 }
2052 else if (hwndMenu == &MainPopupMenu) {
2053 WinSetWindowUShort(MainPopupMenu, QWS_ID, IDM_MAINPOPUP);
2054 SetConditionalCascade(MainPopupMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
2055 SetConditionalCascade(MainPopupMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW);
2056 }
2057 }
[877]2058 CopyPresParams(*hwndMenu, hwnd);
[397]2059 return *hwndMenu;
[2]2060}
2061
[1394]2062SHORT AddToListboxBottom(HWND hwnd, PCSZ str)
[231]2063{
[397]2064 SHORT ln;
[2]2065
[397]2066 ln = (SHORT) WinSendMsg(hwnd, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
[1394]2067 MPFROMP(str));
[397]2068 if (ln)
2069 WinSendMsg(hwnd, LM_SELECTITEM, MPFROM2SHORT(ln, 0), MPVOID);
2070 return ln;
[2]2071}
2072
[231]2073VOID SetSysMenu(HWND hwndSysMenu)
2074{
[397]2075 CHAR s[128], *p;
[2]2076
[397]2077 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1394]2078 MPFROM2SHORT(SC_RESTORE, 128), MPFROMP(s))) {
[397]2079 p = strchr(s, '\t');
2080 if (p) {
2081 p++;
2082 strcpy(p, "Ctrl+Alt+F5");
2083 WinSetMenuItemText(hwndSysMenu, SC_RESTORE, s);
[2]2084 }
[397]2085 }
2086 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1394]2087 MPFROM2SHORT(SC_CLOSE, 128), MPFROMP(s))) {
[397]2088 p = strchr(s, '\t');
2089 if (p) {
2090 p++;
2091 strcpy(p, "Ctrl+Alt+F4");
2092 WinSetMenuItemText(hwndSysMenu, SC_CLOSE, s);
[2]2093 }
[397]2094 }
2095 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1394]2096 MPFROM2SHORT(SC_MOVE, 128), MPFROMP(s))) {
[397]2097 p = strchr(s, '\t');
2098 if (p) {
2099 p++;
2100 strcpy(p, "Ctrl+Alt+F7");
2101 WinSetMenuItemText(hwndSysMenu, SC_MOVE, s);
[2]2102 }
[397]2103 }
2104 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1394]2105 MPFROM2SHORT(SC_SIZE, 128), MPFROMP(s))) {
[397]2106 p = strchr(s, '\t');
2107 if (p) {
2108 p++;
2109 strcpy(p, "Ctrl+Alt+F8");
2110 WinSetMenuItemText(hwndSysMenu, SC_SIZE, s);
[2]2111 }
[397]2112 }
2113 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
[1394]2114 MPFROM2SHORT(SC_MINIMIZE, 128), MPFROMP(s))) {
[397]2115 p = strchr(s, '\t');
2116 if (p) {
2117 p++;
2118 strcpy(p, "Ctrl+Alt+F9");
2119 WinSetMenuItemText(hwndSysMenu, SC_MINIMIZE, s);
[2]2120 }
[397]2121 }
2122 if (WinSendMsg(hwndSysMenu,
[1394]2123 MM_QUERYITEMTEXT,
2124 MPFROM2SHORT(SC_MAXIMIZE, 128), MPFROMP(s))) {
[397]2125 p = strchr(s, '\t');
2126 if (p) {
2127 p++;
2128 strcpy(p, "Ctrl+Alt+F10");
2129 WinSetMenuItemText(hwndSysMenu, SC_MAXIMIZE, s);
[2]2130 }
[397]2131 }
2132 if (WinSendMsg(hwndSysMenu,
[1394]2133 MM_QUERYITEMTEXT, MPFROM2SHORT(SC_HIDE, 128), MPFROMP(s))) {
[397]2134 p = strchr(s, '\t');
2135 if (p) {
2136 p++;
2137 strcpy(p, "Ctrl+Alt+F11");
2138 WinSetMenuItemText(hwndSysMenu, SC_HIDE, s);
[2]2139 }
[397]2140 }
[2]2141}
2142
[1394]2143VOID LoadLibPath(PSZ str, LONG len)
[231]2144{
[397]2145 ULONG ver[2];
2146 CHAR configsys[] = "C:\\CONFIG.SYS";
2147 static CHAR var[8192], beg[16384], end[16384];
2148 BOOL warp;
2149 FILE *fp;
2150 PFN DQELIBPATH = NULL;
2151 HMODULE hmod;
[1544]2152 CHAR *moder = "r";
[2]2153
[397]2154 if (str && len) {
2155 *str = 0;
2156 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
[1394]2157 QSV_BOOT_DRIVE, (PVOID) ver, (ULONG) sizeof(ULONG)))
[397]2158 ver[0] = 3L;
2159 *configsys = (CHAR) ver[0] + '@';
2160 if (!DosQuerySysInfo(QSV_VERSION_MAJOR,
[1394]2161 QSV_VERSION_MINOR,
2162 (PVOID) ver, (ULONG) sizeof(ver)) && ver[1] >= 30)
[397]2163 warp = TRUE;
2164 *var = *beg = *end = 0;
2165 if (warp) {
2166 if (!DosLoadModule(var, sizeof(var), "DOSCALL1.DLL", &hmod)) {
[1394]2167 if (!DosQueryProcAddr(hmod,
2168 ORD_DOS32QUERYEXTLIBPATH,
[1498]2169 NULL, (PFN *) &DQELIBPATH)) {
[1394]2170 DQELIBPATH(beg, BEGIN_LIBPATH);
2171 DQELIBPATH(end, END_LIBPATH);
2172 }
2173 DosFreeModule(hmod);
[397]2174 }
2175 *var = 0;
2176 }
[1544]2177 fp = xfopen(configsys, moder, pszSrcFile, __LINE__, FALSE);
[397]2178 if (fp) {
2179 while (!feof(fp)) {
[1394]2180 if (!xfgets_bstripcr(var, sizeof(var), fp, pszSrcFile, __LINE__))
2181 break;
2182 if (!strnicmp(var, "LIBPATH=", 8)) {
2183 memmove(var, var + 8, strlen(var + 8) + 1);
2184 lstrip(var);
2185 break;
2186 }
[397]2187 }
2188 fclose(fp);
[2]2189 }
[397]2190 strncpy(str, beg, len);
2191 strncat(str, var, len - strlen(str));
2192 strncat(str, end, len - strlen(str));
2193 str[len - 1] = 0;
2194 }
[2]2195}
2196
[231]2197void SetViewMenu(HWND hwndMenu, ULONG flWindowAttr)
2198{
[397]2199 WinCheckMenuItem(hwndMenu, IDM_MINIICONS, ((flWindowAttr & CV_MINI)));
2200 WinCheckMenuItem(hwndMenu, IDM_TEXT, ((flWindowAttr & CV_TEXT)));
2201 WinCheckMenuItem(hwndMenu, IDM_ICON, ((flWindowAttr & CV_ICON) &&
[1394]2202 !(flWindowAttr & CV_TREE)));
[397]2203 WinCheckMenuItem(hwndMenu, IDM_TREEVIEW, ((flWindowAttr & CV_TREE)));
2204 WinCheckMenuItem(hwndMenu, IDM_DETAILS, ((flWindowAttr & CV_DETAIL)));
2205 WinCheckMenuItem(hwndMenu, IDM_NAME, ((flWindowAttr & CV_NAME)));
[2]2206}
2207
[231]2208void SaySort(HWND hwnd, INT sortflags, BOOL archive)
2209{
[397]2210 char *s = NULL;
[2]2211
[397]2212 s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
2213 if (s) {
2214 sprintf(s, "S:%s%s",
[1394]2215 sortflags & SORT_REVERSE ? "^" : NullStr,
2216 (sortflags & SORT_FIRSTEXTENSION) ?
2217 GetPString(IDS_FIRSTX) : (sortflags & SORT_LASTEXTENSION) ?
2218 GetPString(IDS_LASTX) : (sortflags & SORT_SIZE) ?
2219 "Size" : (sortflags & SORT_EASIZE) ?
2220 (archive == 0) ?
2221 GetPString(IDS_EASIZE) : GetPString(IDS_CSIZE) :
2222 (sortflags & SORT_LWDATE) ?
2223 (archive == 0) ?
2224 GetPString(IDS_LWDATE) : GetPString(IDS_DATE) :
2225 (sortflags & SORT_LADATE) ?
2226 GetPString(IDS_LADATE) : (sortflags & SORT_CRDATE) ?
2227 GetPString(IDS_CRDATE) :
2228 (sortflags & SORT_PATHNAME) ?
2229 GetPString(IDS_PATH) : (sortflags & SORT_NOSORT) ?
2230 GetPString(IDS_NONE) : (sortflags & SORT_SUBJECT) ?
2231 GetPString(IDS_SUBJ) : GetPString(IDS_NAME));
[397]2232 WinSetWindowText(hwnd, s);
[1039]2233 free(s);
[397]2234 }
[2]2235}
2236
[231]2237void SayView(HWND hwnd, ULONG flWindowAttr)
2238{
[397]2239 char *s = NULL;
[2]2240
[397]2241 s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
2242 if (s) {
2243 sprintf(s, "V:%s%s",
[1394]2244 (flWindowAttr & CV_TREE) ? GetPString(IDS_TREE) :
2245 (flWindowAttr & CV_NAME) ? GetPString(IDS_NAME) :
2246 (flWindowAttr & CV_DETAIL) ? GetPString(IDS_DETAIL) :
2247 (flWindowAttr & CV_TEXT) ? GetPString(IDS_TEXT) :
2248 GetPString(IDS_ICON),
2249 ((flWindowAttr & CV_MINI) &&
2250 !(flWindowAttr & CV_TEXT)) ? GetPString(IDS_MINI) : NullStr);
[397]2251 WinSetWindowText(hwnd, s);
[1039]2252 free(s);
[397]2253 }
[2]2254}
2255
[231]2256void SayFilter(HWND hwnd, MASK * mask, BOOL archive)
2257{
[397]2258 char *s = NULL;
[2]2259
[397]2260 s = xmalloc(CCHMAXPATH * 2, pszSrcFile, __LINE__);
2261 if (s) {
2262 sprintf(s, "F:%s%s",
[1394]2263 mask->szMask,
2264 (!archive && (mask->attrFile != ALLATTRS ||
2265 mask->antiattr != 0)) ? " " : NullStr,
2266 (!archive && (mask->attrFile != ALLATTRS ||
2267 mask->antiattr !=
2268 0)) ? GetPString(IDS_ATTRTEXT) : NullStr);
[397]2269 if (!s[2])
2270 sprintf(s, "F:%s", GetPString(IDS_ALLTEXT));
2271 WinSetWindowText(hwnd, s);
[1039]2272 free(s);
[397]2273 }
[2]2274}
2275
[231]2276char *GetCmdSpec(BOOL dos)
2277{
[397]2278 char *cmspec;
[2]2279
[397]2280 if (!dos) {
2281 cmspec = getenv("OS2_SHELL");
2282 if (!cmspec)
2283 cmspec = getenv("COMSPEC");
2284 if (!cmspec)
2285 cmspec = "CMD.EXE";
2286 }
2287 else {
2288 cmspec = getenv("DOS_SHELL");
2289 if (!cmspec)
2290 cmspec = "COMMAND.COM";
2291 }
2292 return cmspec;
[2]2293}
2294
[231]2295void Broadcast(HAB hab, HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2296{
[397]2297 if (hwndMain)
2298 WinBroadcastMsg(hwndMain, msg, mp1, mp2, BMSG_SEND | BMSG_FRAMEONLY);
2299 if (hwnd &&
2300 hwnd != HWND_DESKTOP &&
2301 hwnd != hwndMain &&
2302 hwnd != WinQueryDesktopWindow(hab, NULLHANDLE) &&
2303 WinIsWindow(hab, hwnd) && (!hwndMain || !WinIsChild(hwnd, hwndMain)))
2304 WinSendMsg(hwnd, msg, mp1, mp2);
[2]2305}
2306
[231]2307void SetupWinList(HWND hwndMenu, HWND hwndTop, HWND hwndFrame)
2308{
[1673]2309 /**
[397]2310 * add switchlist entries to end of pulldown menu
2311 */
[2]2312
[397]2313 SHORT sItemCount, x = 0, y = 0;
2314 MENUITEM mi;
[2]2315
[397]2316 sItemCount = (SHORT) WinSendMsg(hwndMenu,
[1394]2317 MM_QUERYITEMCOUNT, MPVOID, MPVOID);
[2]2318
[1673]2319 // clean out old additions
[397]2320 while ((SHORT) WinSendMsg(hwndMenu,
[1394]2321 MM_DELETEITEM,
2322 MPFROM2SHORT(IDM_SWITCHSTART + x++,
2323 TRUE), MPVOID) < sItemCount)
[397]2324 sItemCount--;
2325 x = 0;
2326 while ((SHORT) WinSendMsg(hwndMenu,
[1394]2327 MM_DELETEITEM,
2328 MPFROM2SHORT(IDM_WINDOWSTART + x++,
2329 TRUE), MPVOID) < sItemCount)
[397]2330 sItemCount--;
[2]2331
[397]2332 x = 0;
2333 if (hwndTop) {
[2]2334
[397]2335 char wtext[CCHMAXPATH + 8];
2336 HENUM henum;
2337 HWND hwndChild;
[2]2338
[1673]2339 // add children of the main FM/2 client
[397]2340 henum = WinBeginEnumWindows(hwndTop);
2341 memset(&mi, 0, sizeof(mi));
2342 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2343 if (WinQueryWindowUShort(hwndChild, QWS_ID) && hwndChild != hwndFrame) {
[1394]2344 *wtext = 0;
2345 WinQueryWindowText(hwndChild, CCHMAXPATH + 8, wtext);
2346 if (*wtext) {
2347 wtext[CCHMAXPATH + 7] = 0;
2348 mi.afStyle = MIS_TEXT;
2349 if (!((x + sItemCount) % 28))
2350 mi.afStyle |= MIS_BREAK;
2351 mi.id = IDM_WINDOWSTART + x;
2352 mi.iPosition = MIT_END;
2353 if ((SHORT) WinSendMsg(hwndMenu,
2354 MM_INSERTITEM,
2355 MPFROMP(&mi), MPFROMP(wtext)) >= 0)
2356 x++;
2357 }
[397]2358 }
[2]2359 }
[397]2360 WinEndEnumWindows(henum);
2361 }
[2]2362
[1673]2363 // add external FM/2 windows
[397]2364 {
2365 PSWBLOCK pswb;
2366 ULONG ulSize, ulcEntries;
2367 HWND hwndTopFrame;
2368 register INT i;
[2]2369
[787]2370 hwndTopFrame = hwndTop ? WinQueryWindow(hwndTop, QW_PARENT) : (HWND)0;
[1673]2371 // Get the switch list information
[397]2372 x = 0;
2373 ulcEntries = WinQuerySwitchList(0, NULL, 0);
2374 ulSize = sizeof(SWBLOCK) + sizeof(HSWITCH) + (ulcEntries + 4L) *
2375 (LONG) sizeof(SWENTRY);
[1673]2376 // Allocate memory for list
[397]2377 pswb = xmalloc(ulSize, pszSrcFile, __LINE__);
2378 if (pswb) {
[1673]2379 // Put the info in the list
[397]2380 ulcEntries = WinQuerySwitchList(0, pswb, ulSize - sizeof(SWENTRY));
[1673]2381 // do the dirty deed
[397]2382 memset(&mi, 0, sizeof(mi));
2383 for (i = 0; i < pswb->cswentry; i++) {
[1394]2384 if (pswb->aswentry[i].swctl.uchVisibility == SWL_VISIBLE &&
2385 pswb->aswentry[i].swctl.fbJump == SWL_JUMPABLE &&
2386 (pswb->aswentry[i].swctl.idProcess != mypid ||
2387 !hwndFrame ||
2388 pswb->aswentry[i].swctl.hwnd != hwndFrame) &&
2389 (pswb->aswentry[i].swctl.idProcess != mypid ||
2390 !hwndTopFrame ||
2391 pswb->aswentry[i].swctl.hwnd != hwndTopFrame ||
2392 !WinIsChild(hwndFrame, hwndTop))) {
2393 if (!strnicmp(pswb->aswentry[i].swctl.szSwtitle, "AV/2", 4)
2394 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "File Manager/2")
[1400]2395 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, PCSZ_COLLECTOR)
[1394]2396 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VTree", 5)
2397 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VDir", 4)
2398 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, FM2Str, 4)) {
2399 mi.afStyle = MIS_TEXT;
2400 if (x && !(x % 28))
2401 mi.afStyle |= MIS_BREAK;
2402 mi.id = IDM_SWITCHSTART + y;
2403 mi.iPosition = MIT_END;
2404 switches[y] = pswb->aswentry[i].hswitch;
2405 if ((SHORT) WinSendMsg(hwndMenu,
2406 MM_INSERTITEM,
2407 MPFROMP(&mi),
2408 MPFROMP(pswb->aswentry[i].
2409 swctl.szSwtitle)) >= 0) {
2410 y++;
2411 x++;
2412 }
2413 }
2414 }
[397]2415 }
2416 numswitches = y;
[1039]2417 free(pswb);
[397]2418 DosPostEventSem(CompactSem);
[2]2419 }
[397]2420 }
[2]2421}
2422
[231]2423BOOL SwitchCommand(HWND hwndMenu, USHORT cmd)
2424{
[397]2425 BOOL ret = FALSE;
[2]2426
[397]2427 if (hwndMain && hwndMenu && cmd >= IDM_WINDOWSTART && cmd < IDM_SWITCHSTART) {
[1673]2428 // select a child window (of client)
[2]2429
[397]2430 MENUITEM mi;
2431 HWND hwndSubMenu = (HWND) 0, hwndChild;
2432 CHAR s[CCHMAXPATH + 8];
[2]2433
[397]2434 if (WinQueryWindowUShort(hwndMenu, QWS_ID) != IDM_WINDOWSMENU) {
2435 memset(&mi, 0, sizeof(mi));
2436 mi.iPosition = MIT_END;
2437 mi.afStyle = MIS_TEXT;
2438 if (WinSendMsg(hwndMenu,
[1394]2439 MM_QUERYITEM,
2440 MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
2441 hwndSubMenu = mi.hwndSubMenu;
[397]2442 }
2443 else
2444 hwndSubMenu = hwndMenu;
2445 if (hwndSubMenu) {
2446 *s = 0;
2447 if (WinSendMsg(hwndSubMenu,
[1394]2448 MM_QUERYITEMTEXT,
2449 MPFROM2SHORT(cmd, CCHMAXPATH + 8), MPFROMP(s)) && *s) {
[2]2450
[1394]2451 HENUM henum;
2452 CHAR checkText[CCHMAXPATH + 8];
2453 SWP swp;
[2]2454
[1394]2455 s[CCHMAXPATH + 7] = 0;
2456 henum = WinBeginEnumWindows(hwndMain);
2457 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2458 if (WinQueryWindowUShort(hwndChild, QWS_ID)) {
2459 *checkText = 0;
2460 WinQueryWindowText(hwndChild, CCHMAXPATH + 8, checkText);
2461 checkText[CCHMAXPATH + 7] = 0;
2462 if (!stricmp(checkText, s)) {
2463 if (WinQueryWindowPos(hwndChild, &swp)) {
2464 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE))
2465 WinSetWindowPos(hwndChild,
2466 HWND_TOP,
2467 0, 0, 0, 0, SWP_RESTORE | SWP_ZORDER);
2468 }
2469 WinSetActiveWindow(HWND_DESKTOP, hwndChild);
2470 ret = TRUE;
2471 break;
2472 }
2473 }
2474 }
2475 WinEndEnumWindows(henum);
[397]2476 }
[2]2477 }
[397]2478 }
2479 else if (cmd >= IDM_SWITCHSTART && cmd < IDM_SWITCHSTART + 499) {
2480 if (cmd - IDM_SWITCHSTART < numswitches) {
2481 WinSwitchToProgram(switches[cmd - IDM_SWITCHSTART]);
2482 ret = TRUE;
[2]2483 }
[397]2484 }
[2]2485
[397]2486 return ret;
[2]2487}
[787]2488
[1112]2489/** CheckDriveSpaceAvail
2490 * Take space needed and checks that drive has at least 1000 bits in excess of the required space.
2491 * Returns 0 if sufficient space is available; 1 if the drive is full & 2 on abort of operation
2492 * when the drive would have less than ullFreeSpaceWhenComplete remaining or has insufficient space.
2493 */
2494
[1394]2495INT CheckDriveSpaceAvail(PCSZ pTargetPath, ULONGLONG ullSpaceNeeded,
2496 ULONGLONG ullFreeSpaceWhenComplete)
[1112]2497{
2498 FSALLOCATE fsa;
2499 ULONGLONG ullFreeQty;
2500 APIRET ret;
2501
2502 DosQueryFSInfo(toupper(*pTargetPath) - 'A' + 1, FSIL_ALLOC, &fsa, sizeof(FSALLOCATE));
2503 ullFreeQty = (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector);
2504 if (ullFreeQty > ullSpaceNeeded + ullFreeSpaceWhenComplete)
2505 return 0;
2506 else if (ullFreeQty < ullSpaceNeeded + 1024) {
2507 CHAR szKB[20];
2508
[1120]2509 CommaFmtULL(szKB, sizeof(szKB),
[1394]2510 ullFreeQty - ullSpaceNeeded, ' ');
[1112]2511 if (ullFreeSpaceWhenComplete == 0) {
2512 saymsg(MB_OK,
[1394]2513 HWND_DESKTOP,
2514 NullStr,
2515 GetPString(IDS_DRIVESPACELIMITEDTMPSAVE),
2516 pTargetPath);
[1112]2517 return 0;
2518 }
2519 else {
[1118]2520 if (ullFreeQty > ullSpaceNeeded) {
[1394]2521 ret = saymsg(MB_YESNO,
2522 HWND_DESKTOP,
2523 NullStr,
2524 GetPString(IDS_DRIVESPACELIMITED),
2525 pTargetPath,
2526 szKB);
2527 if (ret == MBID_YES)
2528 return 0;
2529 else
2530 return 2;
[1112]2531 }
2532 else {
[1394]2533 saymsg(MB_OK,
2534 HWND_DESKTOP,
2535 NullStr,
2536 GetPString(IDS_DRIVESPACEEXCEEDED),
2537 pTargetPath);
2538 return 2;
[1112]2539 }
2540 }
2541 }
2542 else
2543 return 1;
2544}
2545
[787]2546#pragma alloc_text(MAINWND5,SetSysMenu)
2547#pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
2548#pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
[1112]2549#pragma alloc_text(MISC1,CheckDriveSpaceAvail)
[1077]2550
2551#ifdef FORTIFY
2552#pragma alloc_text(MISC1,GetTidForWindow)
2553#endif // FORTIFY
2554
[787]2555#pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
2556#pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
2557#pragma alloc_text(CNR_MISC2,CnrDirectEdit,OpenEdit)
2558#pragma alloc_text(MISC2,SetMenuCheck,disable_menuitem,SetSortChecks)
2559#pragma alloc_text(MISC2,SetDetailsSwitches,SetViewMenu)
2560#pragma alloc_text(MISC3,SetupCommandMenu,AdjustDetailsSwitches)
2561#pragma alloc_text(MISC3,ViewHelp,GetCmdSpec)
[1400]2562#pragma alloc_text(MISC3,ExecFile,SetConditionalCascade,LoadDetailsSwitches,WriteDetailsSwitches)
[787]2563#pragma alloc_text(MISC4,PortholeInit,CheckMenu,Broadcast,SetupWinList,SwitchCommand)
2564#pragma alloc_text(MISC6,DrawTargetEmphasis,EmphasizeButton)
2565#pragma alloc_text(MISC_LIBPATH,LoadLibPath)
2566#pragma alloc_text(MISC_SAY,SayView,SaySort,SayFilter)
2567
Note: See TracBrowser for help on using the repository browser.