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