source: trunk/dll/misc.c@ 790

Last change on this file since 790 was 787, checked in by Steven Levine, 18 years ago

Rework UM_FILLSETUPLIST IDM_SAVEDIRCNRSTATE and ..._setups() logic for ticket# 109 and #31
Add GetMSecTimer()
Use GetMSecTimer in DbgMsg
Tweak notebook.ipf scanning page
Move more #pragma alloc_text statements to end of files for OpenWatcom
Delete obsoletes
Revert ExpandAll() ShowTreeRec() DosSleeps to 0 - DosSleep(1) was slowing down inner loops
Drop afFilesToGet - use FilesToGet directly
Optimze ShowTreeRec() collapse logic - was really slow

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