source: trunk/dll/misc.c@ 775

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

Minor clean up add comments re recent changes

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