source: trunk/dll/misc.c@ 1833

Last change on this file since 1833 was 1833, checked in by Gregg Young, 10 years ago

A correct (I hope as always) fix for the direct edits. I don't need to reallocate pci-pszFileName or repoint pci->pszDisplayName because updatecnritems does it for me. I also got the tree container to update without using removecnritems. Ticket [557]

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