source: trunk/dll/misc.c@ 896

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

Additional argument quoting checks

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