source: trunk/dll/misc.c@ 890

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

runemf2 now quotes executable strings if needed (Ticket 180); it also reports where it was called from on errors

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 64.2 KB
RevLine 
[70]1
2/***********************************************************************
3
4 $Id: misc.c 888 2007-12-22 22:02: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];
903 FILE *fp;
904 INT ret = -1;
[2]905
[397]906 fp = _fsopen(filename, "rb", SH_DENYNO);
907 if (fp) {
908 *s = 0;
909 fread(s, 1, 3, fp);
910 if (*s != 'H' || s[1] != 'S' || s[2] != 'P') {
911 fclose(fp);
912 return FALSE;
[2]913 }
[397]914 fclose(fp);
[888]915 ret = runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
916 NULL, NULL,
[397]917 "VIEW.EXE \"%s\"", filename);
918 }
[2]919
[397]920 return (ret != -1);
[2]921}
922
[451]923//== ExecFile() run file, return 1 if OK 0 if skipped -1 if can't run ==
924
[231]925INT ExecFile(HWND hwnd, CHAR * filename)
926{
[397]927 EXECARGS ex;
928 CHAR cl[1001], path[CCHMAXPATH], *p;
929 APIRET ret;
930 static INT lastflags = 0;
[2]931
[397]932 strcpy(path, filename);
933 p = strrchr(path, '\\');
934 if (!p)
935 p = strrchr(path, ':');
936 if (p) {
937 if (*p == ':') {
938 p++;
939 *p = '\\';
940 p++;
[2]941 }
[397]942 *p = 0;
943 }
944 else
945 *path = 0;
946 *cl = 0;
[773]947 BldQuotedFileName(cl, filename);
[397]948 memset(&ex, 0, sizeof(ex));
949 ex.flags = lastflags;
950 ex.commandline = cl;
951 *ex.path = 0;
952 *ex.environment = 0;
953 ret = WinDlgBox(HWND_DESKTOP, hwnd, CmdLineDlgProc, FM3ModHandle,
954 EXEC_FRAME, &ex);
955 if (ret == 1) {
956 lastflags = ex.flags;
[888]957 return runemf2(ex.flags, hwnd, pszSrcFile, __LINE__, path,
[787]958 *ex.environment ? ex.environment : NULL,
959 "%s", cl) != -1;
[397]960 }
961 else if (ret != 0)
962 return -1;
963 return 0;
[2]964}
965
[231]966VOID SetDetailsSwitches(HWND hwnd, DIRCNRDATA * dcd)
967{
[397]968 WinCheckMenuItem(hwnd, IDM_SHOWLNAMES,
[751]969 dcd ? dcd->detailslongname : detailslongname);
[397]970 WinCheckMenuItem(hwnd, IDM_SHOWSUBJECT,
[751]971 dcd ? dcd->detailssubject : detailssubject);
972 WinCheckMenuItem(hwnd, IDM_SHOWEAS, dcd ? dcd->detailsea : detailsea);
[397]973 WinCheckMenuItem(hwnd, IDM_SHOWSIZE,
[751]974 dcd ? dcd->detailssize : detailssize);
[397]975 WinCheckMenuItem(hwnd, IDM_SHOWICON,
[751]976 dcd ? dcd->detailsicon : detailsicon);
[397]977 WinCheckMenuItem(hwnd, IDM_SHOWLWDATE,
[751]978 dcd ? dcd->detailslwdate : detailslwdate);
[397]979 WinCheckMenuItem(hwnd, IDM_SHOWLWTIME,
[751]980 dcd ? dcd->detailslwtime : detailslwtime);
[397]981 WinCheckMenuItem(hwnd, IDM_SHOWLADATE,
[751]982 dcd ? dcd->detailsladate : detailsladate);
[397]983 WinCheckMenuItem(hwnd, IDM_SHOWLATIME,
[751]984 dcd ? dcd->detailslatime : detailslatime);
[397]985 WinCheckMenuItem(hwnd, IDM_SHOWCRDATE,
[751]986 dcd ? dcd->detailscrdate : detailscrdate);
[397]987 WinCheckMenuItem(hwnd, IDM_SHOWCRTIME,
[751]988 dcd ? dcd->detailscrtime : detailscrtime);
[397]989 WinCheckMenuItem(hwnd, IDM_SHOWATTR,
[751]990 dcd ? dcd->detailsattr : detailsattr);
[2]991}
992
[231]993VOID AdjustDetailsSwitches(HWND hwnd, HWND hwndMenu, USHORT cmd,
994 CHAR * directory, CHAR * keyroot,
995 DIRCNRDATA * dcd, BOOL compare)
996{
[397]997 CHAR s[CCHMAXPATH], *eos = s;
998 BOOL *bool = NULL;
[2]999
[397]1000 *s = 0;
1001 if (keyroot) {
1002 strcpy(s, keyroot);
1003 strcat(s, ".");
1004 eos = &s[strlen(s)];
1005 }
1006 switch (cmd) {
1007 case IDM_SHOWLNAMES:
[751]1008 bool = dcd ? &dcd->detailslongname : &detailslongname;
[397]1009 strcpy(eos, "DetailsLongname");
1010 break;
1011 case IDM_SHOWSUBJECT:
[751]1012 bool = dcd ? &dcd->detailssubject : &detailssubject;
[397]1013 strcpy(eos, "DetailsSubject");
1014 break;
1015 case IDM_SHOWEAS:
[751]1016 bool = dcd ? &dcd->detailsea : &detailsea;
[397]1017 strcpy(eos, "DetailsEA");
1018 break;
1019 case IDM_SHOWSIZE:
[751]1020 bool = dcd ? &dcd->detailssize : &detailssize;
[397]1021 strcpy(eos, "DetailsSize");
1022 break;
1023 case IDM_SHOWICON:
[751]1024 bool = dcd ? &dcd->detailsicon : &detailsicon;
[397]1025 strcpy(eos, "DetailsIcon");
1026 break;
1027 case IDM_SHOWLWDATE:
[751]1028 bool = dcd ? &dcd->detailslwdate : &detailslwdate;
[397]1029 strcpy(eos, "DetailsLWDate");
1030 break;
1031 case IDM_SHOWLWTIME:
[751]1032 bool = dcd ? &dcd->detailslwtime : &detailslwtime;
[397]1033 strcpy(eos, "DetailsLWTime");
1034 break;
1035 case IDM_SHOWLADATE:
[751]1036 bool = dcd ? &dcd->detailsladate : &detailsladate;
[397]1037 strcpy(eos, "DetailsLADate");
1038 break;
1039 case IDM_SHOWLATIME:
[751]1040 bool = dcd ? &dcd->detailslatime : &detailslatime;
[397]1041 strcpy(eos, "DetailsLATime");
1042 break;
1043 case IDM_SHOWCRDATE:
[751]1044 bool = dcd ? &dcd->detailscrdate : &detailscrdate;
[397]1045 strcpy(eos, "DetailsCRDate");
1046 break;
1047 case IDM_SHOWCRTIME:
[751]1048 bool = dcd ? &dcd->detailscrtime : &detailscrtime;
[397]1049 strcpy(eos, "DetailsCRTime");
1050 break;
1051 case IDM_SHOWATTR:
[751]1052 bool = dcd ? &dcd->detailsattr : &detailsattr;
[397]1053 strcpy(eos, "DetailsAttr");
1054 break;
1055 default:
[231]1056 if (hwndMenu)
[397]1057 SetDetailsSwitches(hwndMenu, dcd);
1058 return;
1059 }
1060 if (bool)
[787]1061 *bool = *bool ? FALSE : TRUE;
[397]1062 if (*s && bool)
1063 PrfWriteProfileData(fmprof, appname, s, bool, sizeof(BOOL));
1064 if (hwnd)
1065 AdjustCnrColsForPref(hwnd, directory, dcd, compare);
1066 if (hwndMenu)
1067 SetDetailsSwitches(hwndMenu, dcd);
[2]1068}
1069
[231]1070VOID SetConditionalCascade(HWND hwndMenu, USHORT id, USHORT def)
1071{
[397]1072 MENUITEM mi;
[2]1073
[397]1074 mi.iPosition = MIT_END;
1075 mi.hItem = 0L;
1076 mi.hwndSubMenu = (HWND) 0;
1077 mi.afAttribute = 0;
1078 mi.afStyle = MIS_TEXT;
1079 if (WinSendMsg
1080 (hwndMenu, MM_QUERYITEM, MPFROM2SHORT(id, TRUE), MPFROMP(&mi))) {
1081 WinSetWindowBits(mi.hwndSubMenu, QWL_STYLE, MS_CONDITIONALCASCADE,
1082 MS_CONDITIONALCASCADE);
1083 WinSendMsg(mi.hwndSubMenu, MM_SETDEFAULTITEMID, MPFROMSHORT(def), MPVOID);
1084 WinCheckMenuItem(mi.hwndSubMenu, def, TRUE);
1085 }
[2]1086}
1087
[231]1088VOID SetSortChecks(HWND hwndMenu, INT sortflags)
1089{
[397]1090 WinCheckMenuItem(hwndMenu, IDM_SORTNONE, FALSE);
1091 WinCheckMenuItem(hwndMenu, IDM_SORTFIRST, FALSE);
1092 WinCheckMenuItem(hwndMenu, IDM_SORTLAST, FALSE);
1093 WinCheckMenuItem(hwndMenu, IDM_SORTSIZE, FALSE);
1094 WinCheckMenuItem(hwndMenu, IDM_SORTEASIZE, FALSE);
1095 WinCheckMenuItem(hwndMenu, IDM_SORTLWDATE, FALSE);
1096 WinCheckMenuItem(hwndMenu, IDM_SORTLADATE, FALSE);
1097 WinCheckMenuItem(hwndMenu, IDM_SORTCRDATE, FALSE);
1098 WinCheckMenuItem(hwndMenu, IDM_SORTFILENAME, FALSE);
1099 WinCheckMenuItem(hwndMenu, IDM_SORTNAME, FALSE);
1100 WinCheckMenuItem(hwndMenu, IDM_SORTSUBJECT, FALSE);
1101 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSFIRST, FALSE);
1102 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSLAST, FALSE);
1103 WinCheckMenuItem(hwndMenu, IDM_SORTREVERSE, FALSE);
1104 if (sortflags & SORT_FIRSTEXTENSION)
1105 WinCheckMenuItem(hwndMenu, IDM_SORTFIRST, TRUE);
1106 else if (sortflags & SORT_LASTEXTENSION)
1107 WinCheckMenuItem(hwndMenu, IDM_SORTLAST, TRUE);
1108 else if (sortflags & SORT_SIZE)
1109 WinCheckMenuItem(hwndMenu, IDM_SORTSIZE, TRUE);
1110 else if (sortflags & SORT_EASIZE)
1111 WinCheckMenuItem(hwndMenu, IDM_SORTEASIZE, TRUE);
1112 else if (sortflags & SORT_LWDATE)
1113 WinCheckMenuItem(hwndMenu, IDM_SORTLWDATE, TRUE);
1114 else if (sortflags & SORT_LADATE)
1115 WinCheckMenuItem(hwndMenu, IDM_SORTLADATE, TRUE);
1116 else if (sortflags & SORT_CRDATE)
1117 WinCheckMenuItem(hwndMenu, IDM_SORTCRDATE, TRUE);
1118 else if (sortflags & SORT_FILENAME)
1119 WinCheckMenuItem(hwndMenu, IDM_SORTFILENAME, TRUE);
1120 else if (sortflags & SORT_NOSORT)
1121 WinCheckMenuItem(hwndMenu, IDM_SORTNONE, TRUE);
1122 else if (sortflags & SORT_SUBJECT)
1123 WinCheckMenuItem(hwndMenu, IDM_SORTSUBJECT, TRUE);
1124 else
1125 WinCheckMenuItem(hwndMenu, IDM_SORTNAME, TRUE);
1126 if (sortflags & SORT_DIRSFIRST)
1127 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSFIRST, TRUE);
1128 else if (sortflags & SORT_DIRSLAST)
1129 WinCheckMenuItem(hwndMenu, IDM_SORTDIRSLAST, TRUE);
1130 if (sortflags & SORT_REVERSE)
1131 WinCheckMenuItem(hwndMenu, IDM_SORTREVERSE, TRUE);
[2]1132}
1133
[231]1134VOID FcloseFile(FILE * fp)
1135{
[397]1136 /* for use by apps that don't use the DLLs runtime library */
1137 fclose(fp);
[2]1138}
1139
[231]1140VOID SetupCommandMenu(HWND hwndMenu, HWND hwndCnr)
1141{
[397]1142 MENUITEM mi, mit;
1143 INT x;
1144 SHORT numitems;
1145 LINKCMDS *info;
[2]1146
[397]1147 if (!cmdloaded)
1148 load_commands();
1149 mi.iPosition = MIT_END;
1150 mi.hwndSubMenu = (HWND) 0;
1151 mi.hItem = 0L;
1152 mi.afAttribute = 0;
1153 mi.afStyle = MIS_TEXT;
1154 memset(&mit, 0, sizeof(MENUITEM));
1155 if (WinQueryWindowUShort(hwndMenu, QWS_ID) == IDM_COMMANDSMENU)
1156 mit.hwndSubMenu = hwndMenu;
1157 else
1158 WinSendMsg(hwndMenu, MM_QUERYITEM,
1159 MPFROM2SHORT(IDM_COMMANDSMENU, TRUE), MPFROMP(&mit));
1160 if (mit.hwndSubMenu) {
1161 numitems = (SHORT) WinSendMsg(mit.hwndSubMenu, MM_QUERYITEMCOUNT,
1162 MPVOID, MPVOID);
1163 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM, MPFROMSHORT(-1), MPVOID);
1164 for (x = 0; x < numitems; x++)
1165 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM,
1166 MPFROMSHORT((SHORT) (x + IDM_COMMANDSTART)), MPVOID);
1167 if (hwndCnr && cmdhead) {
1168 x = 0;
1169 info = cmdhead;
1170 while (info) {
[2]1171
[397]1172 CHAR s[CCHMAXPATH + 24];
[2]1173
[397]1174 sprintf(s,
1175 "%s%s%s",
1176 info->title,
[787]1177 x < 20 ? "\tCtrl + " : NullStr,
1178 x < 20 && x > 9 ? "Shift + " : NullStr);
[397]1179 if (x < 20)
1180 sprintf(&s[strlen(s)], "%d",
[787]1181 ((x % 10) + 1) == 10 ? 0 : (x % 10) + 1);
[397]1182 mi.id = IDM_COMMANDSTART + x;
[787]1183 mi.afAttribute = (info->flags & ONCE ? MIA_CHECKED : 0) |
1184 (info->flags & PROMPT ? MIA_FRAMED : 0);
[397]1185 mi.afStyle = MIS_TEXT;
1186 if (!(x % 24) && x && info->next)
1187 mi.afStyle |= MIS_BREAK;
1188 WinSendMsg(mit.hwndSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s));
1189 x++;
1190 info = info->next;
1191 }
[2]1192 }
[397]1193 }
[2]1194}
1195
[231]1196VOID LoadDetailsSwitches(CHAR * keyroot, DIRCNRDATA * dcd)
1197{
[397]1198 ULONG size;
1199 CHAR s[CCHMAXPATH], *eos = s;
1200 BOOL *bool;
[2]1201
[397]1202 *s = 0;
1203 if (keyroot) {
1204 strcpy(s, keyroot);
1205 strcat(s, ".");
1206 eos = &s[strlen(s)];
1207 }
1208 strcpy(eos, "DetailsLongname");
1209 if (dcd)
1210 bool = &dcd->detailslongname;
1211 else
1212 bool = &detailslongname;
1213 *bool = detailslongname;
1214 size = sizeof(BOOL);
1215 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1216 strcpy(eos, "DetailsSubject");
1217 if (dcd)
1218 bool = &dcd->detailssubject;
1219 else
1220 bool = &detailssubject;
1221 *bool = detailssubject;
1222 size = sizeof(BOOL);
1223 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1224 strcpy(eos, "DetailsEA");
1225 if (dcd)
1226 bool = &dcd->detailsea;
1227 else
1228 bool = &detailsea;
1229 *bool = detailsea;
1230 size = sizeof(BOOL);
1231 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1232 strcpy(eos, "DetailsSize");
1233 if (dcd)
1234 bool = &dcd->detailssize;
1235 else
1236 bool = &detailssize;
1237 *bool = detailssize;
1238 size = sizeof(BOOL);
1239 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1240 strcpy(eos, "DetailsIcon");
1241 if (dcd)
1242 bool = &dcd->detailsicon;
1243 else
1244 bool = &detailsicon;
1245 *bool = detailsicon;
1246 size = sizeof(BOOL);
1247 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1248 strcpy(eos, "DetailsAttr");
1249 if (dcd)
1250 bool = &dcd->detailsattr;
1251 else
1252 bool = &detailsattr;
1253 *bool = detailsattr;
1254 size = sizeof(BOOL);
1255 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1256 strcpy(eos, "DetailsCRDate");
1257 if (dcd)
1258 bool = &dcd->detailscrdate;
1259 else
1260 bool = &detailscrdate;
1261 *bool = detailscrdate;
1262 size = sizeof(BOOL);
1263 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1264 strcpy(eos, "DetailsCRTime");
1265 if (dcd)
1266 bool = &dcd->detailscrtime;
1267 else
1268 bool = &detailscrtime;
1269 *bool = detailscrtime;
1270 size = sizeof(BOOL);
1271 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1272 strcpy(eos, "DetailsLWDate");
1273 if (dcd)
1274 bool = &dcd->detailslwdate;
1275 else
1276 bool = &detailslwdate;
1277 *bool = detailslwdate;
1278 size = sizeof(BOOL);
1279 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1280 strcpy(eos, "DetailsLWTime");
1281 if (dcd)
1282 bool = &dcd->detailslwtime;
1283 else
1284 bool = &detailslwtime;
1285 *bool = detailslwtime;
1286 size = sizeof(BOOL);
1287 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1288 strcpy(eos, "DetailsLADate");
1289 if (dcd)
1290 bool = &dcd->detailsladate;
1291 else
1292 bool = &detailsladate;
1293 *bool = detailsladate;
1294 size = sizeof(BOOL);
1295 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
1296 strcpy(eos, "DetailsLATime");
1297 if (dcd)
1298 bool = &dcd->detailslatime;
1299 else
1300 bool = &detailslatime;
1301 *bool = detailslatime;
1302 size = sizeof(BOOL);
1303 PrfQueryProfileData(fmprof, appname, s, (PVOID) bool, &size);
[2]1304}
1305
[231]1306HWND FindDirCnr(HWND hwndParent)
1307{
[397]1308 HWND found, hwndDir = (HWND) 0;
1309 HENUM henum;
[2]1310
[397]1311 henum = WinBeginEnumWindows(hwndParent);
1312 while ((found = WinGetNextWindow(henum)) != NULLHANDLE) {
1313 hwndDir = WinWindowFromID(found, FID_CLIENT);
1314 if (hwndDir) {
1315 hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
1316 if (hwndDir)
1317 break;
1318 hwndDir = (HWND) 0;
[2]1319 }
[397]1320 }
1321 WinEndEnumWindows(henum);
[2]1322
[397]1323 return hwndDir;
[2]1324}
1325
[231]1326VOID HeapThread(VOID * dummy)
1327{
[397]1328 ULONG postcount;
1329 APIRET rc;
[2]1330
[397]1331 rc = DosCreateEventSem(NULL, &CompactSem, 0L, FALSE);
1332 if (rc)
1333 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
1334 "DosCreateEventSem");
1335 else {
1336 priority_normal();
1337 for (;;) {
1338 if (DosWaitEventSem(CompactSem, SEM_INDEFINITE_WAIT))
1339 break;
1340 _heapmin();
1341 DosResetEventSem(CompactSem, &postcount);
[2]1342 }
[397]1343 }
[2]1344}
1345
[231]1346VOID FixSwitchList(HWND hwnd, CHAR * text)
1347{
[397]1348 HSWITCH hswitch;
1349 SWCNTRL swctl;
[2]1350
[397]1351 hswitch = WinQuerySwitchHandle(hwnd, 0);
1352 if (hswitch) {
1353 if (!WinQuerySwitchEntry(hswitch, &swctl)) {
1354 strcpy(swctl.szSwtitle, "FM/2");
1355 WinChangeSwitchEntry(hswitch, &swctl);
[2]1356 }
[397]1357 }
[2]1358}
1359
[231]1360VOID QuickPopup(HWND hwnd, DIRCNRDATA * dcd, HWND hwndMenu, USHORT id)
1361{
[397]1362 dcd->hwndLastMenu = hwndMenu;
1363 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
1364 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1365 MPFROM2SHORT(TRUE, CRA_SOURCE));
1366 dcd->cnremphasized = TRUE;
1367 }
1368 if (dcd->flWindowAttr & CV_MINI)
1369 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
1370 if (!WinPopupMenu(hwnd, hwnd, dcd->hwndLastMenu,
1371 8, 8, 0,
1372 PU_HCONSTRAIN | PU_VCONSTRAIN |
1373 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
1374 if (dcd->cnremphasized) {
1375 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1376 MPFROM2SHORT(FALSE, CRA_SOURCE));
1377 dcd->cnremphasized = FALSE;
[2]1378 }
[397]1379 }
1380 else
1381 WinSendMsg(dcd->hwndLastMenu, MM_SELECTITEM,
1382 MPFROM2SHORT(id, TRUE), MPFROM2SHORT(0, FALSE));
[2]1383}
1384
[231]1385PMINIRECORDCORE CurrentRecord(HWND hwndCnr)
1386{
[787]1387 SHORT attrib = fSelectedAlways ? CRA_SELECTED : CRA_CURSORED;
[397]1388 PMINIRECORDCORE pmi;
[2]1389
[397]1390 for (;;) {
1391 pmi = (PMINIRECORDCORE) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
1392 MPFROMLONG(CMA_FIRST),
1393 MPFROMSHORT(attrib));
1394 if ((!pmi || (INT) pmi == -1) && attrib == CRA_SELECTED) /* punt */
1395 attrib = CRA_CURSORED;
1396 else
1397 break;
1398 }
[787]1399 return ((INT)pmi == -1) ? NULL : pmi;
[2]1400}
1401
[231]1402BOOL PostMsg(HWND h, ULONG msg, MPARAM mp1, MPARAM mp2)
1403{
[397]1404 BOOL rc = WinPostMsg(h, msg, mp1, mp2);
[2]1405
[397]1406 if (!rc) {
[2]1407
[882]1408 // If window owned by some other process or some other thread?
1409 if (!IsFm2Window(h, 1)) {
1410 QMSG qmsg;
1411 for (;;) {
1412 DosSleep(1);
1413 rc = WinPostMsg(h, msg, mp1, mp2);
1414 if (rc)
1415 break; // OK
1416 if (!WinIsWindow((HAB) 0, h))
1417 break; // Window gone
1418 if (WinPeekMsg((HAB) 0, &qmsg, (HWND) 0, 0, 0, PM_NOREMOVE))
1419 break; // Queue has message(s)
1420 } // for
[2]1421 }
[882]1422 }
[397]1423 return rc;
[2]1424}
1425
[231]1426VOID OpenEdit(HWND hwnd)
1427{
[397]1428 CNREDITDATA ced;
1429 PCNRITEM pci;
1430 PFIELDINFO pfi;
[2]1431
[397]1432 pci = (PCNRITEM) WinSendMsg(hwnd,
1433 CM_QUERYRECORDEMPHASIS,
1434 MPFROMLONG(CMA_FIRST),
1435 MPFROMSHORT(CRA_CURSORED));
1436 if (pci && (INT) pci != -1) {
1437 memset(&ced, 0, sizeof(ced));
1438 ced.cb = sizeof(ced);
1439 ced.hwndCnr = hwnd;
1440 ced.id = WinQueryWindowUShort(hwnd, QWS_ID);
1441 ced.pRecord = (PRECORDCORE) pci;
1442 pfi = (PFIELDINFO) WinSendMsg(hwnd,
1443 CM_QUERYDETAILFIELDINFO,
1444 MPVOID, MPFROMSHORT(CMA_FIRST));
1445 if (!pfi)
1446 WinSendMsg(hwnd, CM_OPENEDIT, MPFROMP(&ced), MPVOID);
1447 else {
1448 while (pfi && (INT) pfi != -1 &&
1449 pfi->offStruct != FIELDOFFSET(CNRITEM, pszFileName))
[231]1450 pfi = (PFIELDINFO) WinSendMsg(hwnd,
1451 CM_QUERYDETAILFIELDINFO,
[397]1452 MPFROMP(pfi), MPFROMSHORT(CMA_NEXT));
1453 if (pfi && (INT) pfi != -1) {
1454 ced.pFieldInfo = pfi;
[231]1455 {
[397]1456 CNRINFO cnri;
[2]1457
[397]1458 memset(&cnri, 0, sizeof(CNRINFO));
1459 cnri.cb = sizeof(CNRINFO);
1460 WinSendMsg(hwnd,
1461 CM_QUERYCNRINFO,
1462 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1463 if (cnri.flWindowAttr & CV_DETAIL)
1464 ced.id = CID_LEFTDVWND;
[231]1465 }
[397]1466 WinSendMsg(hwnd, CM_OPENEDIT, MPFROMP(&ced), MPVOID);
1467 }
[2]1468 }
[397]1469 }
[2]1470}
1471
1472#ifdef NEVER
[231]1473VOID QuickView(HWND hwnd, CHAR * filename)
1474{
[397]1475 if (filename && IsFile(filename) == 1) {
1476 if (TestBinary(filename) && *binview) {
[2]1477
[397]1478 CHAR *list[2];
[2]1479
[397]1480 list[0] = filename;
1481 list[1] = NULL;
[888]1482 ExecOnList(hwnd, binview, WINDOWED | SEPARATE, NULL, list, NULL,
1483 pszSrcFile, __LINE__);
[397]1484 return;
1485 }
1486 else if (*viewer) {
[2]1487
[397]1488 CHAR *list[2];
[2]1489
[397]1490 list[0] = filename;
1491 list[1] = NULL;
[787]1492 ExecOnList(hwnd, viewer,
1493 WINDOWED | SEPARATE | (fViewChild ? CHILD : 0),
[888]1494 NULL, list, NULL, pszSrcFile, __LINE__);
[397]1495 return;
[2]1496 }
[397]1497 StartMLEEditor(HWND_DESKTOP, 5, filename, (HWND) 0);
1498 }
[2]1499}
1500
[231]1501VOID QuickEdit(HWND hwnd, CHAR * filename)
1502{
[397]1503 if (filename && IsFile(filename) == 1) {
1504 if (TestBinary(filename) && *bined) {
[2]1505
[397]1506 CHAR *list[2];
[2]1507
[397]1508 list[0] = filename;
1509 list[1] = NULL;
[888]1510 ExecOnList(hwnd, bined, WINDOWED | SEPARATE, NULL, list, NULL,
1511 pszSrcFile, __LINE__);
[397]1512 return;
1513 }
1514 else if (*editor) {
[2]1515
[397]1516 CHAR *list[2];
[2]1517
[397]1518 list[0] = filename;
1519 list[1] = NULL;
[888]1520 ExecOnList(hwnd, editor, WINDOWED | SEPARATE, NULL, list, NULL,
1521 pszSrcFile, __LINE__);
[397]1522 return;
[2]1523 }
[397]1524 StartMLEEditor(HWND_DESKTOP, 4, filename, (HWND) 0);
1525 }
[2]1526}
1527#endif
1528
[231]1529VOID PortholeInit(HWND hwndNew, MPARAM mp1, MPARAM mp2)
1530{
[397]1531 static HWND DefMenu = (HWND) 0;
1532 HWND hwndMenu = (HWND) mp2;
[2]1533
[397]1534 {
1535 ULONG style;
1536
1537 style = WinQueryWindowULong(hwndMenu, QWL_STYLE);
1538 if (!(style & MS_ACTIONBAR))
1539 return;
1540 }
1541
1542 switch (SHORT1FROMMP(mp1)) {
1543 case 0:
[231]1544 {
[397]1545 HWND hwndNow;
1546 MENUITEM mi;
1547 ULONG ulStyle;
[2]1548
[397]1549 memset(&mi, 0, sizeof(mi));
1550 mi.iPosition = MIT_END;
1551 mi.afStyle = MIS_TEXT;
1552 WinSendMsg(hwndMenu, MM_QUERYITEM,
1553 MPFROM2SHORT(IDM_FILESMENU, TRUE), MPFROMP(&mi));
1554 if (!DefMenu)
1555 DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
1556 hwndNow = mi.hwndSubMenu;
1557 mi.hwndSubMenu = hwndNew;
1558 if (!mi.hwndSubMenu)
1559 mi.hwndSubMenu = DefMenu;
1560 WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
1561 WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
1562 WinSetOwner(mi.hwndSubMenu, hwndMenu);
1563 WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
1564 WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_FILESMENU);
1565 mi.afStyle = MIS_SUBMENU;
1566 ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
1567 ulStyle &= -WS_SAVEBITS;
1568 ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
1569 WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
1570 WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
[231]1571 }
[397]1572 break;
[2]1573
[397]1574 case 1:
[231]1575 {
[397]1576 HWND hwndNow;
1577 MENUITEM mi;
1578 ULONG ulStyle;
[2]1579
[397]1580 memset(&mi, 0, sizeof(mi));
1581 mi.iPosition = MIT_END;
1582 mi.afStyle = MIS_TEXT;
1583 WinSendMsg(hwndMenu, MM_QUERYITEM,
1584 MPFROM2SHORT(IDM_VIEWSMENU, TRUE), MPFROMP(&mi));
1585 if (!DefMenu)
1586 DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
1587 hwndNow = mi.hwndSubMenu;
1588 mi.hwndSubMenu = hwndNew;
1589 if (!mi.hwndSubMenu)
1590 mi.hwndSubMenu = DefMenu;
1591 WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
1592 WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
1593 WinSetOwner(mi.hwndSubMenu, hwndMenu);
1594 WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
1595 WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_VIEWSMENU);
1596 mi.afStyle = MIS_SUBMENU;
1597 ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
1598 ulStyle &= -WS_SAVEBITS;
1599 ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
1600 WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
1601 WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
[231]1602 }
[397]1603 break;
1604 }
[2]1605}
1606
[872]1607HWND CheckMenu(HWND hwnd, HWND * hwndMenu, USHORT id)
[231]1608{
[397]1609 /* load and adjust menus as required */
1610 if (!*hwndMenu || !WinIsWindow((HAB) 0, *hwndMenu)) {
1611 *hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
[877]1612 CopyPresParams(*hwndMenu, hwnd);
[397]1613 if (hwndMenu == &DirMenu) {
1614 WinSetWindowUShort(DirMenu, QWS_ID, IDM_FILESMENU);
1615 SetConditionalCascade(DirMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1616 SetConditionalCascade(DirMenu, IDM_COPYMENU, IDM_COPY);
1617 SetConditionalCascade(DirMenu, IDM_MOVEMENU, IDM_MOVE);
1618 SetConditionalCascade(DirMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1619 SetConditionalCascade(DirMenu, IDM_VIEWSUBMENU, IDM_INFO);
1620 SetConditionalCascade(DirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1621 SetConditionalCascade(DirMenu, IDM_DELETESUBMENU,
[787]1622 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1623 SetConditionalCascade(DirMenu, IDM_MISCSUBMENU, IDM_SIZES);
1624 SetConditionalCascade(DirMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
1625 if (fWorkPlace) {
1626 WinSendMsg(DirMenu, MM_DELETEITEM,
1627 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1628 WinSendMsg(DirMenu, MM_DELETEITEM,
1629 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1630 }
[2]1631 }
[397]1632 else if (hwndMenu == &TreeMenu) {
1633 WinSetWindowUShort(TreeMenu, QWS_ID, IDM_FILESMENU);
1634 SetConditionalCascade(TreeMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1635 SetConditionalCascade(TreeMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1636 SetConditionalCascade(TreeMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1637 SetConditionalCascade(TreeMenu, IDM_EXPANDSUBMENU, IDM_EXPAND);
1638 SetConditionalCascade(TreeMenu, IDM_MISCSUBMENU, IDM_SIZES);
1639 SetConditionalCascade(TreeMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
1640 if (fWorkPlace) {
1641 WinSendMsg(TreeMenu, MM_DELETEITEM,
1642 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1643 WinSendMsg(TreeMenu, MM_DELETEITEM,
1644 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1645 }
1646 }
1647 else if (hwndMenu == &ArcMenu) {
1648 WinSetWindowUShort(ArcMenu, QWS_ID, IDM_FILESMENU);
1649 SetConditionalCascade(ArcMenu, IDM_EXTRACTSUBMENU, IDM_EXTRACT);
1650 SetConditionalCascade(ArcMenu, IDM_EDITSUBMENU, IDM_EDIT);
1651 SetConditionalCascade(ArcMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1652 if (fWorkPlace)
1653 WinSendMsg(ArcMenu, MM_DELETEITEM,
1654 MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
1655 }
1656 else if (hwndMenu == &FileMenu) {
1657 WinSetWindowUShort(FileMenu, QWS_ID, IDM_FILESMENU);
1658 SetConditionalCascade(FileMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
1659 SetConditionalCascade(FileMenu, IDM_COPYMENU, IDM_COPY);
1660 SetConditionalCascade(FileMenu, IDM_MOVEMENU, IDM_MOVE);
1661 SetConditionalCascade(FileMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
1662 SetConditionalCascade(FileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1663 SetConditionalCascade(FileMenu, IDM_EDITSUBMENU, IDM_EDIT);
1664 SetConditionalCascade(FileMenu, IDM_COLLECTMENU, IDM_COLLECT);
1665 SetConditionalCascade(FileMenu, IDM_DELETESUBMENU,
[787]1666 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1667 SetConditionalCascade(FileMenu, IDM_OPENSUBMENU, IDM_OPENDEFAULT);
1668 SetConditionalCascade(FileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
1669 if (fWorkPlace) {
1670 WinSendMsg(FileMenu, MM_DELETEITEM,
1671 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1672 WinSendMsg(FileMenu, MM_DELETEITEM,
1673 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1674 }
1675 }
1676 else if (hwndMenu == &DirCnrMenu) {
1677 WinSetWindowUShort(DirCnrMenu, QWS_ID, IDM_VIEWSMENU);
1678 SetConditionalCascade(DirCnrMenu, IDM_MISCSUBMENU, IDM_SIZES);
1679 SetConditionalCascade(DirCnrMenu, IDM_OPENSUBMENU, IDM_OPENSETTINGSME);
1680 if (fWorkPlace)
1681 WinSendMsg(DirCnrMenu, MM_DELETEITEM,
1682 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1683 }
[489]1684 else if (hwndMenu == &TreeCnrMenu) {
[397]1685 WinSetWindowUShort(TreeCnrMenu, QWS_ID, IDM_VIEWSMENU);
[468]1686 SetConditionalCascade(TreeCnrMenu, IDM_PARTITIONSMENU, IDM_PARTITION);
1687 }
[397]1688 else if (hwndMenu == &ArcCnrMenu) {
1689 WinSetWindowUShort(ArcCnrMenu, QWS_ID, IDM_VIEWSMENU);
1690 SetConditionalCascade(ArcCnrMenu, IDM_EXTRACTSUBMENU, IDM_ARCEXTRACT);
1691 if (fWorkPlace)
1692 WinSendMsg(ArcCnrMenu, MM_DELETEITEM,
1693 MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
1694 }
1695 else if (hwndMenu == &CollectorCnrMenu) {
1696 WinSetWindowUShort(CollectorCnrMenu, QWS_ID, IDM_VIEWSMENU);
1697 SetConditionalCascade(CollectorCnrMenu, IDM_COLLECTMENU,
1698 IDM_COLLECTFROMCLIP);
1699 }
1700 else if (hwndMenu == &CollectorFileMenu) {
1701 WinSetWindowUShort(CollectorFileMenu, QWS_ID, IDM_FILESMENU);
1702 SetConditionalCascade(CollectorFileMenu, IDM_COMMANDSMENU,
1703 IDM_DOITYOURSELF);
1704 SetConditionalCascade(CollectorFileMenu, IDM_COPYMENU, IDM_COPY);
1705 SetConditionalCascade(CollectorFileMenu, IDM_MOVEMENU, IDM_MOVE);
1706 SetConditionalCascade(CollectorFileMenu, IDM_SAVESUBMENU,
1707 IDM_SAVETOCLIP);
1708 SetConditionalCascade(CollectorFileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
1709 SetConditionalCascade(CollectorFileMenu, IDM_EDITSUBMENU, IDM_EDIT);
1710 SetConditionalCascade(CollectorFileMenu, IDM_DELETESUBMENU,
[787]1711 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1712 SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBMENU,
1713 IDM_OPENDEFAULT);
1714 SetConditionalCascade(CollectorFileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
1715 if (fWorkPlace) {
1716 WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
1717 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1718 WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
1719 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1720 }
1721 }
1722 else if (hwndMenu == &CollectorDirMenu) {
1723 WinSetWindowUShort(CollectorDirMenu, QWS_ID, IDM_FILESMENU);
1724 SetConditionalCascade(CollectorDirMenu, IDM_COMMANDSMENU,
1725 IDM_DOITYOURSELF);
1726 SetConditionalCascade(CollectorDirMenu, IDM_COPYMENU, IDM_COPY);
1727 SetConditionalCascade(CollectorDirMenu, IDM_MOVEMENU, IDM_MOVE);
1728 SetConditionalCascade(CollectorDirMenu, IDM_SAVESUBMENU,
1729 IDM_SAVETOCLIP);
1730 SetConditionalCascade(CollectorDirMenu, IDM_VIEWSUBMENU, IDM_INFO);
1731 SetConditionalCascade(CollectorDirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
1732 SetConditionalCascade(CollectorDirMenu, IDM_DELETESUBMENU,
[787]1733 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
[397]1734 SetConditionalCascade(CollectorDirMenu, IDM_MISCSUBMENU, IDM_SIZES);
1735 SetConditionalCascade(CollectorDirMenu, IDM_OPENSUBMENU,
1736 IDM_OPENWINDOW);
1737 if (fWorkPlace) {
1738 WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
1739 MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
1740 WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
1741 MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
1742 }
1743 }
1744 else if (hwndMenu == &MainPopupMenu) {
1745 WinSetWindowUShort(MainPopupMenu, QWS_ID, IDM_MAINPOPUP);
1746 SetConditionalCascade(MainPopupMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
1747 SetConditionalCascade(MainPopupMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW);
1748 }
1749 }
[877]1750 CopyPresParams(*hwndMenu, hwnd);
[397]1751 return *hwndMenu;
[2]1752}
1753
[231]1754SHORT AddToListboxBottom(HWND hwnd, CHAR * str)
1755{
[397]1756 SHORT ln;
[2]1757
[397]1758 ln = (SHORT) WinSendMsg(hwnd, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
1759 MPFROMP(str));
1760 if (ln)
1761 WinSendMsg(hwnd, LM_SELECTITEM, MPFROM2SHORT(ln, 0), MPVOID);
1762 return ln;
[2]1763}
1764
[231]1765VOID SetSysMenu(HWND hwndSysMenu)
1766{
[397]1767 CHAR s[128], *p;
[2]1768
[397]1769 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1770 MPFROM2SHORT(SC_RESTORE, 128), MPFROMP(s))) {
1771 p = strchr(s, '\t');
1772 if (p) {
1773 p++;
1774 strcpy(p, "Ctrl+Alt+F5");
1775 WinSetMenuItemText(hwndSysMenu, SC_RESTORE, s);
[2]1776 }
[397]1777 }
1778 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1779 MPFROM2SHORT(SC_CLOSE, 128), MPFROMP(s))) {
1780 p = strchr(s, '\t');
1781 if (p) {
1782 p++;
1783 strcpy(p, "Ctrl+Alt+F4");
1784 WinSetMenuItemText(hwndSysMenu, SC_CLOSE, s);
[2]1785 }
[397]1786 }
1787 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1788 MPFROM2SHORT(SC_MOVE, 128), MPFROMP(s))) {
1789 p = strchr(s, '\t');
1790 if (p) {
1791 p++;
1792 strcpy(p, "Ctrl+Alt+F7");
1793 WinSetMenuItemText(hwndSysMenu, SC_MOVE, s);
[2]1794 }
[397]1795 }
1796 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1797 MPFROM2SHORT(SC_SIZE, 128), MPFROMP(s))) {
1798 p = strchr(s, '\t');
1799 if (p) {
1800 p++;
1801 strcpy(p, "Ctrl+Alt+F8");
1802 WinSetMenuItemText(hwndSysMenu, SC_SIZE, s);
[2]1803 }
[397]1804 }
1805 if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
1806 MPFROM2SHORT(SC_MINIMIZE, 128), MPFROMP(s))) {
1807 p = strchr(s, '\t');
1808 if (p) {
1809 p++;
1810 strcpy(p, "Ctrl+Alt+F9");
1811 WinSetMenuItemText(hwndSysMenu, SC_MINIMIZE, s);
[2]1812 }
[397]1813 }
1814 if (WinSendMsg(hwndSysMenu,
1815 MM_QUERYITEMTEXT,
1816 MPFROM2SHORT(SC_MAXIMIZE, 128), MPFROMP(s))) {
1817 p = strchr(s, '\t');
1818 if (p) {
1819 p++;
1820 strcpy(p, "Ctrl+Alt+F10");
1821 WinSetMenuItemText(hwndSysMenu, SC_MAXIMIZE, s);
[2]1822 }
[397]1823 }
1824 if (WinSendMsg(hwndSysMenu,
1825 MM_QUERYITEMTEXT, MPFROM2SHORT(SC_HIDE, 128), MPFROMP(s))) {
1826 p = strchr(s, '\t');
1827 if (p) {
1828 p++;
1829 strcpy(p, "Ctrl+Alt+F11");
1830 WinSetMenuItemText(hwndSysMenu, SC_HIDE, s);
[2]1831 }
[397]1832 }
[2]1833}
1834
[231]1835VOID LoadLibPath(CHAR * str, LONG len)
1836{
[397]1837 ULONG ver[2];
1838 CHAR configsys[] = "C:\\CONFIG.SYS";
1839 static CHAR var[8192], beg[16384], end[16384];
1840 BOOL warp;
1841 FILE *fp;
1842 PFN DQELIBPATH = NULL;
1843 HMODULE hmod;
[2]1844
[397]1845 if (str && len) {
1846 *str = 0;
1847 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
1848 QSV_BOOT_DRIVE, (PVOID) ver, (ULONG) sizeof(ULONG)))
1849 ver[0] = 3L;
1850 *configsys = (CHAR) ver[0] + '@';
1851 if (!DosQuerySysInfo(QSV_VERSION_MAJOR,
1852 QSV_VERSION_MINOR,
1853 (PVOID) ver, (ULONG) sizeof(ver)) && ver[1] >= 30)
1854 warp = TRUE;
1855 *var = *beg = *end = 0;
1856 if (warp) {
1857 if (!DosLoadModule(var, sizeof(var), "DOSCALL1.DLL", &hmod)) {
1858 if (!DosQueryProcAddr(hmod,
1859 ORD_DOS32QUERYEXTLIBPATH,
1860 NULL, (PFN *) & DQELIBPATH)) {
1861 DQELIBPATH(beg, BEGIN_LIBPATH);
1862 DQELIBPATH(end, END_LIBPATH);
[231]1863 }
[397]1864 DosFreeModule(hmod);
1865 }
1866 *var = 0;
1867 }
1868 fp = xfopen(configsys, "r", pszSrcFile, __LINE__);
1869 if (fp) {
1870 while (!feof(fp)) {
[551]1871 if (!xfgets_bstripcr(var, sizeof(var), fp, pszSrcFile, __LINE__))
[397]1872 break;
1873 if (!strnicmp(var, "LIBPATH=", 8)) {
1874 memmove(var, var + 8, strlen(var + 8) + 1);
1875 lstrip(var);
1876 break;
[231]1877 }
[397]1878 }
1879 fclose(fp);
[2]1880 }
[397]1881 strncpy(str, beg, len);
1882 strncat(str, var, len - strlen(str));
1883 strncat(str, end, len - strlen(str));
1884 str[len - 1] = 0;
1885 }
[2]1886}
1887
[231]1888void SetViewMenu(HWND hwndMenu, ULONG flWindowAttr)
1889{
[397]1890 WinCheckMenuItem(hwndMenu, IDM_MINIICONS, ((flWindowAttr & CV_MINI)));
1891 WinCheckMenuItem(hwndMenu, IDM_TEXT, ((flWindowAttr & CV_TEXT)));
1892 WinCheckMenuItem(hwndMenu, IDM_ICON, ((flWindowAttr & CV_ICON) &&
1893 !(flWindowAttr & CV_TREE)));
1894 WinCheckMenuItem(hwndMenu, IDM_TREEVIEW, ((flWindowAttr & CV_TREE)));
1895 WinCheckMenuItem(hwndMenu, IDM_DETAILS, ((flWindowAttr & CV_DETAIL)));
1896 WinCheckMenuItem(hwndMenu, IDM_NAME, ((flWindowAttr & CV_NAME)));
[2]1897}
1898
[231]1899void SaySort(HWND hwnd, INT sortflags, BOOL archive)
1900{
[397]1901 char *s = NULL;
[2]1902
[397]1903 s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
1904 if (s) {
1905 sprintf(s, "S:%s%s",
[787]1906 sortflags & SORT_REVERSE ? "^" : NullStr,
1907 (sortflags & SORT_FIRSTEXTENSION) ?
1908 GetPString(IDS_FIRSTX) : (sortflags & SORT_LASTEXTENSION) ?
1909 GetPString(IDS_LASTX) : (sortflags & SORT_SIZE) ?
1910 "Size" : (sortflags & SORT_EASIZE) ?
1911 (archive == 0) ?
1912 GetPString(IDS_EASIZE) : GetPString(IDS_CSIZE) :
1913 (sortflags & SORT_LWDATE) ?
1914 (archive == 0) ?
1915 GetPString(IDS_LWDATE) : GetPString(IDS_DATE) :
1916 (sortflags & SORT_LADATE) ?
1917 GetPString(IDS_LADATE) : (sortflags & SORT_CRDATE) ?
1918 GetPString(IDS_CRDATE) :
1919 (sortflags & SORT_PATHNAME) ?
1920 GetPString(IDS_PATH) : (sortflags & SORT_NOSORT) ?
1921 GetPString(IDS_NONE) : (sortflags & SORT_SUBJECT) ?
1922 GetPString(IDS_SUBJ) : GetPString(IDS_NAME));
[397]1923 WinSetWindowText(hwnd, s);
1924 free(s);
1925 }
[2]1926}
1927
[231]1928void SayView(HWND hwnd, ULONG flWindowAttr)
1929{
[397]1930 char *s = NULL;
[2]1931
[397]1932 s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
1933 if (s) {
1934 sprintf(s, "V:%s%s",
1935 (flWindowAttr & CV_TREE) ? GetPString(IDS_TREE) :
1936 (flWindowAttr & CV_NAME) ? GetPString(IDS_NAME) :
1937 (flWindowAttr & CV_DETAIL) ? GetPString(IDS_DETAIL) :
1938 (flWindowAttr & CV_TEXT) ? GetPString(IDS_TEXT) :
1939 GetPString(IDS_ICON),
1940 ((flWindowAttr & CV_MINI) &&
1941 !(flWindowAttr & CV_TEXT)) ? GetPString(IDS_MINI) : NullStr);
1942 WinSetWindowText(hwnd, s);
1943 free(s);
1944 }
[2]1945}
1946
[231]1947void SayFilter(HWND hwnd, MASK * mask, BOOL archive)
1948{
[397]1949 char *s = NULL;
[2]1950
[397]1951 s = xmalloc(CCHMAXPATH * 2, pszSrcFile, __LINE__);
1952 if (s) {
1953 sprintf(s, "F:%s%s",
1954 mask->szMask,
1955 (!archive && (mask->attrFile != ALLATTRS ||
1956 mask->antiattr != 0)) ? " " : NullStr,
1957 (!archive && (mask->attrFile != ALLATTRS ||
1958 mask->antiattr !=
1959 0)) ? GetPString(IDS_ATTRTEXT) : NullStr);
1960 if (!s[2])
1961 sprintf(s, "F:%s", GetPString(IDS_ALLTEXT));
1962 WinSetWindowText(hwnd, s);
1963 free(s);
1964 }
[2]1965}
1966
[231]1967char *GetCmdSpec(BOOL dos)
1968{
[397]1969 char *cmspec;
[2]1970
[397]1971 if (!dos) {
1972 cmspec = getenv("OS2_SHELL");
1973 if (!cmspec)
1974 cmspec = getenv("COMSPEC");
1975 if (!cmspec)
1976 cmspec = "CMD.EXE";
1977 }
1978 else {
1979 cmspec = getenv("DOS_SHELL");
1980 if (!cmspec)
1981 cmspec = "COMMAND.COM";
1982 }
1983 return cmspec;
[2]1984}
1985
[231]1986void Broadcast(HAB hab, HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1987{
[397]1988 if (hwndMain)
1989 WinBroadcastMsg(hwndMain, msg, mp1, mp2, BMSG_SEND | BMSG_FRAMEONLY);
1990 if (hwnd &&
1991 hwnd != HWND_DESKTOP &&
1992 hwnd != hwndMain &&
1993 hwnd != WinQueryDesktopWindow(hab, NULLHANDLE) &&
1994 WinIsWindow(hab, hwnd) && (!hwndMain || !WinIsChild(hwnd, hwndMain)))
1995 WinSendMsg(hwnd, msg, mp1, mp2);
[2]1996}
1997
[231]1998void SetupWinList(HWND hwndMenu, HWND hwndTop, HWND hwndFrame)
1999{
[397]2000 /*
2001 * add switchlist entries to end of pulldown menu
2002 */
[2]2003
[397]2004 SHORT sItemCount, x = 0, y = 0;
2005 MENUITEM mi;
[2]2006
[397]2007 sItemCount = (SHORT) WinSendMsg(hwndMenu,
2008 MM_QUERYITEMCOUNT, MPVOID, MPVOID);
[2]2009
[397]2010 /* clean out old additions */
2011 while ((SHORT) WinSendMsg(hwndMenu,
2012 MM_DELETEITEM,
2013 MPFROM2SHORT(IDM_SWITCHSTART + x++,
2014 TRUE), MPVOID) < sItemCount)
2015 sItemCount--;
2016 x = 0;
2017 while ((SHORT) WinSendMsg(hwndMenu,
2018 MM_DELETEITEM,
2019 MPFROM2SHORT(IDM_WINDOWSTART + x++,
2020 TRUE), MPVOID) < sItemCount)
2021 sItemCount--;
[2]2022
[397]2023 x = 0;
2024 if (hwndTop) {
[2]2025
[397]2026 char wtext[CCHMAXPATH + 8];
2027 HENUM henum;
2028 HWND hwndChild;
[2]2029
[397]2030 /* add children of the main FM/2 client */
2031 henum = WinBeginEnumWindows(hwndTop);
2032 memset(&mi, 0, sizeof(mi));
2033 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2034 if (WinQueryWindowUShort(hwndChild, QWS_ID) && hwndChild != hwndFrame) {
2035 *wtext = 0;
2036 WinQueryWindowText(hwndChild, CCHMAXPATH + 8, wtext);
2037 if (*wtext) {
2038 wtext[CCHMAXPATH + 7] = 0;
2039 mi.afStyle = MIS_TEXT;
2040 if (!((x + sItemCount) % 28))
2041 mi.afStyle |= MIS_BREAK;
2042 mi.id = IDM_WINDOWSTART + x;
2043 mi.iPosition = MIT_END;
2044 if ((SHORT) WinSendMsg(hwndMenu,
2045 MM_INSERTITEM,
2046 MPFROMP(&mi), MPFROMP(wtext)) >= 0)
2047 x++;
[231]2048 }
[397]2049 }
[2]2050 }
[397]2051 WinEndEnumWindows(henum);
2052 }
[2]2053
[397]2054 /* add external FM/2 windows */
2055 {
2056 PSWBLOCK pswb;
2057 ULONG ulSize, ulcEntries;
2058 HWND hwndTopFrame;
2059 register INT i;
[2]2060
[787]2061 hwndTopFrame = hwndTop ? WinQueryWindow(hwndTop, QW_PARENT) : (HWND)0;
[397]2062 /* Get the switch list information */
2063 x = 0;
2064 ulcEntries = WinQuerySwitchList(0, NULL, 0);
2065 ulSize = sizeof(SWBLOCK) + sizeof(HSWITCH) + (ulcEntries + 4L) *
2066 (LONG) sizeof(SWENTRY);
2067 /* Allocate memory for list */
2068 pswb = xmalloc(ulSize, pszSrcFile, __LINE__);
2069 if (pswb) {
2070 /* Put the info in the list */
2071 ulcEntries = WinQuerySwitchList(0, pswb, ulSize - sizeof(SWENTRY));
2072 /* do the dirty deed */
2073 memset(&mi, 0, sizeof(mi));
2074 for (i = 0; i < pswb->cswentry; i++) {
2075 if (pswb->aswentry[i].swctl.uchVisibility == SWL_VISIBLE &&
2076 pswb->aswentry[i].swctl.fbJump == SWL_JUMPABLE &&
2077 (pswb->aswentry[i].swctl.idProcess != mypid ||
2078 !hwndFrame ||
2079 pswb->aswentry[i].swctl.hwnd != hwndFrame) &&
2080 (pswb->aswentry[i].swctl.idProcess != mypid ||
2081 !hwndTopFrame ||
2082 pswb->aswentry[i].swctl.hwnd != hwndTopFrame ||
2083 !WinIsChild(hwndFrame, hwndTop))) {
2084 if (!strnicmp(pswb->aswentry[i].swctl.szSwtitle, "AV/2", 4)
2085 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "File Manager/2")
2086 || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "Collector")
2087 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VTree", 5)
2088 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VDir", 4)
2089 || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, FM2Str, 4)) {
2090 mi.afStyle = MIS_TEXT;
2091 if (x && !(x % 28))
2092 mi.afStyle |= MIS_BREAK;
2093 mi.id = IDM_SWITCHSTART + y;
2094 mi.iPosition = MIT_END;
2095 switches[y] = pswb->aswentry[i].hswitch;
2096 if ((SHORT) WinSendMsg(hwndMenu,
2097 MM_INSERTITEM,
2098 MPFROMP(&mi),
2099 MPFROMP(pswb->aswentry[i].
2100 swctl.szSwtitle)) >= 0) {
2101 y++;
2102 x++;
[231]2103 }
[397]2104 }
[231]2105 }
[397]2106 }
2107 numswitches = y;
2108 free(pswb);
2109 DosPostEventSem(CompactSem);
[2]2110 }
[397]2111 }
[2]2112}
2113
[231]2114BOOL SwitchCommand(HWND hwndMenu, USHORT cmd)
2115{
[397]2116 BOOL ret = FALSE;
[2]2117
[397]2118 if (hwndMain && hwndMenu && cmd >= IDM_WINDOWSTART && cmd < IDM_SWITCHSTART) {
2119 /*
2120 * select a child window (of client)
2121 */
[2]2122
[397]2123 MENUITEM mi;
2124 HWND hwndSubMenu = (HWND) 0, hwndChild;
2125 CHAR s[CCHMAXPATH + 8];
[2]2126
[397]2127 if (WinQueryWindowUShort(hwndMenu, QWS_ID) != IDM_WINDOWSMENU) {
2128 memset(&mi, 0, sizeof(mi));
2129 mi.iPosition = MIT_END;
2130 mi.afStyle = MIS_TEXT;
2131 if (WinSendMsg(hwndMenu,
2132 MM_QUERYITEM,
2133 MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
2134 hwndSubMenu = mi.hwndSubMenu;
2135 }
2136 else
2137 hwndSubMenu = hwndMenu;
2138 if (hwndSubMenu) {
2139 *s = 0;
2140 if (WinSendMsg(hwndSubMenu,
2141 MM_QUERYITEMTEXT,
2142 MPFROM2SHORT(cmd, CCHMAXPATH + 8), MPFROMP(s)) && *s) {
[2]2143
[397]2144 HENUM henum;
2145 CHAR checkText[CCHMAXPATH + 8];
2146 SWP swp;
[2]2147
[397]2148 s[CCHMAXPATH + 7] = 0;
2149 henum = WinBeginEnumWindows(hwndMain);
2150 while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
2151 if (WinQueryWindowUShort(hwndChild, QWS_ID)) {
2152 *checkText = 0;
2153 WinQueryWindowText(hwndChild, CCHMAXPATH + 8, checkText);
2154 checkText[CCHMAXPATH + 7] = 0;
2155 if (!stricmp(checkText, s)) {
2156 if (WinQueryWindowPos(hwndChild, &swp)) {
2157 if (swp.fl & (SWP_MINIMIZE | SWP_HIDE))
2158 WinSetWindowPos(hwndChild,
2159 HWND_TOP,
2160 0, 0, 0, 0, SWP_RESTORE | SWP_ZORDER);
2161 }
2162 WinSetActiveWindow(HWND_DESKTOP, hwndChild);
2163 ret = TRUE;
2164 break;
[231]2165 }
[397]2166 }
[231]2167 }
[397]2168 WinEndEnumWindows(henum);
2169 }
[2]2170 }
[397]2171 }
2172 else if (cmd >= IDM_SWITCHSTART && cmd < IDM_SWITCHSTART + 499) {
2173 if (cmd - IDM_SWITCHSTART < numswitches) {
2174 WinSwitchToProgram(switches[cmd - IDM_SWITCHSTART]);
2175 ret = TRUE;
[2]2176 }
[397]2177 }
[2]2178
[397]2179 return ret;
[2]2180}
[787]2181
2182#pragma alloc_text(MAINWND5,SetSysMenu)
2183#pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
2184#pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
2185#pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
2186#pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
2187#pragma alloc_text(CNR_MISC2,CnrDirectEdit,OpenEdit)
2188#pragma alloc_text(MISC2,SetMenuCheck,disable_menuitem,SetSortChecks)
2189#pragma alloc_text(MISC2,SetDetailsSwitches,SetViewMenu)
2190#pragma alloc_text(MISC3,SetupCommandMenu,AdjustDetailsSwitches)
2191#pragma alloc_text(MISC3,ViewHelp,GetCmdSpec)
2192#pragma alloc_text(MISC3,ExecFile,SetConditionalCascade,LoadDetailsSwitches)
2193#pragma alloc_text(MISC4,PortholeInit,CheckMenu,Broadcast,SetupWinList,SwitchCommand)
2194#pragma alloc_text(MISC6,DrawTargetEmphasis,EmphasizeButton)
2195#pragma alloc_text(MISC_LIBPATH,LoadLibPath)
2196#pragma alloc_text(MISC_SAY,SayView,SaySort,SayFilter)
2197
Note: See TracBrowser for help on using the repository browser.