source: trunk/dll/misc.c@ 986

Last change on this file since 986 was 985, checked in by Gregg Young, 18 years ago

Update sizes dialog (ticket 44); Make max command line length user settable (ticket 199); use xfree for free in most cases (ticket 212); initial code to check for valid ini file (ticket 102); Some additional refactoring and structure rework; Some documentation updates;

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