source: trunk/dll/misc.c@ 933

Last change on this file since 933 was 930, checked in by John Small, 18 years ago

Some code "cleanup" for ticket 150.

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