source: branches/ticket_150/dll/misc.c@ 868

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

Use the thousand separator from NLS Country info for file sizes. Repalce dir.ico & pmap.bmp with new versions from David

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