source: trunk/dll/misc.c@ 1182

Last change on this file since 1182 was 1182, checked in by John Small, 17 years ago

Ticket 187: Draft 2: Move remaining function declarations

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