source: trunk/dll/misc.c@ 1065

Last change on this file since 1065 was 1065, checked in by John Small, 17 years ago

Ticket 230: Simplified code and eliminated some local variables by incorporating
all the details view settings (both the global variables and those in the
DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.

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