source: trunk/dll/misc.c@ 1544

Last change on this file since 1544 was 1544, checked in by Gregg Young, 15 years ago

Changes to fopen and _fsopen to allow FM2 to be loaded in high memory

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