source: trunk/dll/misc.c@ 844

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

This implements large file support; The wrappers to allow WARP3 compatibility are not done so this will not run on Warp3or Warp 4 pre fixpack 12(?)

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