source: trunk/dll/misc.c@ 856

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

Use CommaFmtULL to display large file sizes (Ticket 41). Remove autoset of to no large file support.

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