1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: info.c 1223 2008-09-13 23:11:11Z jbs $
|
---|
5 |
|
---|
6 | Info windows
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2001, 2008 Steven H. Levine
|
---|
10 |
|
---|
11 | 16 Oct 02 SHL Handle large partitions
|
---|
12 | 12 Feb 03 SHL FileInfoProc: standardize EA math
|
---|
13 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
14 | 23 May 05 SHL Use QWL_USER
|
---|
15 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL
|
---|
16 | 05 Jun 05 SHL Use QWL_USER
|
---|
17 | 14 Jul 06 SHL Use Runtime_Error
|
---|
18 | 24 Mar 07 SHL Correct FileInfoProc binary file detect
|
---|
19 | 24 Mar 07 SHL Correct FileInfoProc/IconProc race crash
|
---|
20 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
|
---|
21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
22 | 25 Aug 07 SHL Drop list from FILESTUF - data not static
|
---|
23 | 25 Aug 07 SHL IconProc: do not use freed memory - random bad things happen
|
---|
24 | 27 Sep 07 SHL Correct ULONGLONG size formatting
|
---|
25 | 30 Dec 07 GKY Use CommaFmtULL
|
---|
26 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
27 |
|
---|
28 | ***********************************************************************/
|
---|
29 |
|
---|
30 | #include <stdlib.h>
|
---|
31 | #include <string.h>
|
---|
32 | #include <ctype.h>
|
---|
33 | #include <share.h>
|
---|
34 |
|
---|
35 | #define INCL_DOS
|
---|
36 | #define INCL_WIN
|
---|
37 | #define INCL_GPI
|
---|
38 | #define INCL_LONGLONG
|
---|
39 |
|
---|
40 | #include "fm3dll.h"
|
---|
41 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
42 | #include "draglist.h" // Data declaration(s)
|
---|
43 | #include "notebook.h" // Data declaration(s)
|
---|
44 | #include "inis.h" // Data declaration(s)
|
---|
45 | #include "init.h" // Data declaration(s)
|
---|
46 | #include "mainwnd.h" // Data declaration(s)
|
---|
47 | #include "fm3dlg.h"
|
---|
48 | #include "fm3str.h"
|
---|
49 | #include "makelist.h" // AddToList
|
---|
50 | #include "errutil.h" // Dos_Error...
|
---|
51 | #include "strutil.h" // GetPString
|
---|
52 | #include "attribs.h" // AttrListDlgProc
|
---|
53 | #include "defview.h" // DefaultView
|
---|
54 | #include "info.h"
|
---|
55 | #include "valid.h" // CheckDrive, IsBinary
|
---|
56 | #include "seticon.h" // SetIconDlgProc
|
---|
57 | #include "droplist.h" // AcceptOneDrop, DropHelp, GetOneDrop
|
---|
58 | #include "eas.h" // DisplayEAsProc
|
---|
59 | #include "misc.h" // DrawTargetEmphasis
|
---|
60 | #include "notify.h" // Notify
|
---|
61 | #include "shadow.h" // OpenObject
|
---|
62 | #include "chklist.h" // PopupMenu
|
---|
63 | #include "presparm.h" // SetPresParams
|
---|
64 | #include "strips.h" // bstrip
|
---|
65 | #include "commafmt.h" // CommaFmtULL
|
---|
66 | #include "wrappers.h" // xDosFindFirst
|
---|
67 | #include "fortify.h"
|
---|
68 |
|
---|
69 | // Data definitions
|
---|
70 | #pragma data_seg(DATA1)
|
---|
71 | static PSZ pszSrcFile = __FILE__;
|
---|
72 |
|
---|
73 | #pragma data_seg(GLOBAL1)
|
---|
74 | INT driveflags[26];
|
---|
75 |
|
---|
76 | CHAR *FlagMsg(CHAR drive, CHAR * buffer)
|
---|
77 | {
|
---|
78 | ULONG x;
|
---|
79 | BOOL once = FALSE;
|
---|
80 | register CHAR *p;
|
---|
81 |
|
---|
82 | if (buffer) {
|
---|
83 | *buffer = 0;
|
---|
84 | p = buffer;
|
---|
85 | if (isalpha(drive)) {
|
---|
86 | if (driveflags[toupper(drive) - 'A']) {
|
---|
87 | for (x = IDS_FLREMOVABLETEXT; x < IDS_FLRAMDISKTEXT + 1; x++) {
|
---|
88 | if (driveflags[toupper(drive) - 'A'] &
|
---|
89 | (1 << (x - IDS_FLREMOVABLETEXT))) {
|
---|
90 | if (once) {
|
---|
91 | *p = ' ';
|
---|
92 | p++;
|
---|
93 | }
|
---|
94 | else
|
---|
95 | once = TRUE;
|
---|
96 | *p = '[';
|
---|
97 | p++;
|
---|
98 | strcpy(p, GetPString(x));
|
---|
99 | p += strlen(p);
|
---|
100 | *p = ']';
|
---|
101 | p++;
|
---|
102 | *p = 0;
|
---|
103 | }
|
---|
104 | }
|
---|
105 | }
|
---|
106 | else
|
---|
107 | strcpy(buffer, "[None]");
|
---|
108 | }
|
---|
109 | }
|
---|
110 | return buffer;
|
---|
111 | }
|
---|
112 |
|
---|
113 | MRESULT EXPENTRY DrvInfoProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
114 | {
|
---|
115 | CHAR *pszFileName;
|
---|
116 | CHAR szMB[20];
|
---|
117 | CHAR szKB[20];
|
---|
118 | CHAR szUnits[20];
|
---|
119 | APIRET rc;
|
---|
120 |
|
---|
121 | switch (msg) {
|
---|
122 | case WM_INITDLG:
|
---|
123 | if (mp2) {
|
---|
124 |
|
---|
125 | CHAR s[CCHMAXPATH * 2];
|
---|
126 | ULONG type;
|
---|
127 |
|
---|
128 | pszFileName = (CHAR *)mp2;
|
---|
129 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) pszFileName);
|
---|
130 | WinSendDlgItemMsg(hwnd,
|
---|
131 | INFO_LABEL,
|
---|
132 | EM_SETTEXTLIMIT,
|
---|
133 | MPFROM2SHORT(CCHMAXPATHCOMP, 0), MPVOID);
|
---|
134 | if (!(driveflags[toupper(*pszFileName) - 'A'] & DRIVE_NOSTATS)){
|
---|
135 | WinSendDlgItemMsg(hwnd,
|
---|
136 | INFO_FREE,
|
---|
137 | SLM_SETSLIDERINFO,
|
---|
138 | MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS, 0),
|
---|
139 | MPFROM2SHORT(0, 0));
|
---|
140 | WinSendDlgItemMsg(hwnd,
|
---|
141 | INFO_USED,
|
---|
142 | SLM_SETSLIDERINFO,
|
---|
143 | MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS, 0),
|
---|
144 | MPFROM2SHORT(0, 0));
|
---|
145 | }
|
---|
146 | if (driveflags[toupper(*pszFileName) - 'A'] & DRIVE_NOTWRITEABLE) {
|
---|
147 | WinSendDlgItemMsg(hwnd,
|
---|
148 | INFO_LABEL,
|
---|
149 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
|
---|
150 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, DID_OK));
|
---|
151 | }
|
---|
152 | if (IsFullName(pszFileName)) {
|
---|
153 |
|
---|
154 | CHAR FileSystem[CCHMAXPATH * 2];
|
---|
155 |
|
---|
156 | sprintf(FileSystem,
|
---|
157 | GetPString(IDS_DRIVEINFOTITLETEXT), toupper(*pszFileName));
|
---|
158 | WinSetWindowText(hwnd, FileSystem);
|
---|
159 | if (CheckDrive(toupper(*pszFileName), FileSystem, &type) != -1){
|
---|
160 |
|
---|
161 | FSALLOCATE fsa;
|
---|
162 |
|
---|
163 | if (type & (DRIVE_REMOTE | DRIVE_ZIPSTREAM | DRIVE_VIRTUAL)) {
|
---|
164 |
|
---|
165 | CHAR Path[3], *pfsn, *pfsd;
|
---|
166 | ULONG Size;
|
---|
167 | APIRET rc;
|
---|
168 | PFSQBUFFER2 pfsq;
|
---|
169 |
|
---|
170 | Path[0] = toupper(*pszFileName);
|
---|
171 | Path[1] = ':';
|
---|
172 | Path[2] = 0;
|
---|
173 | Size = sizeof(s);
|
---|
174 | DosError(FERR_DISABLEHARDERR);
|
---|
175 | rc = DosQueryFSAttach(Path,
|
---|
176 | 0, FSAIL_QUERYNAME, (PFSQBUFFER2) s, &Size);
|
---|
177 | if (!rc) {
|
---|
178 | pfsq = (PFSQBUFFER2) s;
|
---|
179 | pfsn = (PCHAR)(pfsq->szName) + pfsq->cbName + 1;
|
---|
180 | pfsd = pfsn + pfsq->cbFSDName + 1;
|
---|
181 | if (pfsq->cbFSAData && pfsd && *pfsd) {
|
---|
182 | sprintf(s, " (%s)", pfsd);
|
---|
183 | WinSetDlgItemText(hwnd, INFO_REALPATH, s);
|
---|
184 | }
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 | DosError(FERR_DISABLEHARDERR);
|
---|
189 | if (!DosQueryFSInfo(toupper(*pszFileName) - '@',
|
---|
190 | FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
|
---|
191 |
|
---|
192 | struct
|
---|
193 | {
|
---|
194 | ULONG serial;
|
---|
195 | CHAR volumelength;
|
---|
196 | CHAR volumelabel[CCHMAXPATH];
|
---|
197 | }
|
---|
198 | volser;
|
---|
199 | USHORT percentfree, percentused;
|
---|
200 |
|
---|
201 | memset(&volser, 0, sizeof(volser));
|
---|
202 | DosError(FERR_DISABLEHARDERR);
|
---|
203 | if (!DosQueryFSInfo(toupper(*pszFileName) - '@',
|
---|
204 | FSIL_VOLSER,
|
---|
205 | &volser, (ULONG) sizeof(volser))) {
|
---|
206 | WinSetDlgItemText(hwnd, INFO_FS, FileSystem);
|
---|
207 | WinSetDlgItemText(hwnd, INFO_LABEL, volser.volumelabel);
|
---|
208 | sprintf(s, "%lx", volser.serial);
|
---|
209 | WinSetDlgItemText(hwnd, INFO_SERIAL, s);
|
---|
210 | FlagMsg(*pszFileName, s);
|
---|
211 | WinSetDlgItemText(hwnd, INFO_FLAGS, s);
|
---|
212 | if (!(driveflags[toupper(*pszFileName) - 'A'] & DRIVE_NOSTATS)){
|
---|
213 | CommaFmtULL(szMB, sizeof(szMB),
|
---|
214 | (ULONGLONG) fsa.cUnit *
|
---|
215 | (fsa.cSectorUnit * fsa.cbSector), 'M');
|
---|
216 | CommaFmtULL(szKB, sizeof(szKB),
|
---|
217 | (ULONGLONG) fsa.cUnit *
|
---|
218 | (fsa.cSectorUnit * fsa.cbSector), 'K');
|
---|
219 | CommaFmtULL(szUnits, sizeof(szUnits),
|
---|
220 | (ULONGLONG) fsa.cUnit, ' ');
|
---|
221 | sprintf(s, "%s, %s, %s %s%s", szMB, szKB, szUnits, GetPString(IDS_UNITTEXT), &"s"[fsa.cUnit == 1L]); // hack cough
|
---|
222 | WinSetDlgItemText(hwnd, INFO_TOTAL, s);
|
---|
223 |
|
---|
224 | CommaFmtULL(szMB, sizeof(szMB),
|
---|
225 | (ULONGLONG) fsa.cUnitAvail *
|
---|
226 | (fsa.cSectorUnit * fsa.cbSector), 'M');
|
---|
227 | CommaFmtULL(szKB, sizeof(szKB),
|
---|
228 | (ULONGLONG) fsa.cUnitAvail *
|
---|
229 | (fsa.cSectorUnit * fsa.cbSector), 'K');
|
---|
230 | CommaFmtULL(szUnits, sizeof(szUnits),
|
---|
231 | (ULONGLONG) fsa.cUnitAvail, ' ');
|
---|
232 | sprintf(s,
|
---|
233 | "%s, %s, %s %s%s",
|
---|
234 | szMB, szKB, szUnits,
|
---|
235 | GetPString(IDS_UNITTEXT), &"s"[fsa.cUnitAvail == 1L]);
|
---|
236 | WinSetDlgItemText(hwnd, INFO_AVAILABLE, s);
|
---|
237 | sprintf(s,
|
---|
238 | GetPString(IDS_SECTORSTEXT),
|
---|
239 | fsa.cbSector,
|
---|
240 | fsa.cSectorUnit, &"s"[fsa.cSectorUnit == 1L]);
|
---|
241 | WinSetDlgItemText(hwnd, INFO_ALLOCUNITS, s);
|
---|
242 |
|
---|
243 | percentfree = (fsa.cUnitAvail && fsa.cUnit) ?
|
---|
244 | (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
|
---|
245 | if (!percentfree && fsa.cUnitAvail)
|
---|
246 | percentfree = 1;
|
---|
247 | percentused = 100 - percentfree;
|
---|
248 | WinSendDlgItemMsg(hwnd,
|
---|
249 | INFO_USED,
|
---|
250 | SLM_SETSLIDERINFO,
|
---|
251 | MPFROM2SHORT(SMA_SLIDERARMPOSITION,
|
---|
252 | SMA_INCREMENTVALUE),
|
---|
253 | MPFROMSHORT(percentused));
|
---|
254 | WinSendDlgItemMsg(hwnd,
|
---|
255 | INFO_FREE,
|
---|
256 | SLM_SETSLIDERINFO,
|
---|
257 | MPFROM2SHORT(SMA_SLIDERARMPOSITION,
|
---|
258 | SMA_INCREMENTVALUE),
|
---|
259 | MPFROMSHORT(percentfree));
|
---|
260 | sprintf(s, "%u%%", percentused);
|
---|
261 | WinSetDlgItemText(hwnd, INFO_USEDPERCENT, s);
|
---|
262 | sprintf(s, "%u%%", percentfree);
|
---|
263 | WinSetDlgItemText(hwnd, INFO_FREEPERCENT, s);
|
---|
264 | }
|
---|
265 | else
|
---|
266 | WinSetDlgItemText(hwnd, INFO_AVAILABLE, GetPString(IDS_STATSMEANINGLESSTEXT));
|
---|
267 | }
|
---|
268 | else {
|
---|
269 | sprintf(FileSystem,
|
---|
270 | GetPString(IDS_CANTQUERYVOLTEXT),
|
---|
271 | toupper(*pszFileName));
|
---|
272 | Notify(FileSystem);
|
---|
273 | WinDismissDlg(hwnd, 0);
|
---|
274 | }
|
---|
275 | }
|
---|
276 | else {
|
---|
277 | sprintf(FileSystem,
|
---|
278 | GetPString(IDS_CANTQUERYALLOCTEXT),
|
---|
279 | toupper(*pszFileName));
|
---|
280 | Notify(FileSystem);
|
---|
281 | WinDismissDlg(hwnd, 0);
|
---|
282 | }
|
---|
283 | }
|
---|
284 | else {
|
---|
285 | FlagMsg(*pszFileName, s);
|
---|
286 | sprintf(FileSystem,
|
---|
287 | GetPString(IDS_DRIVEINACCESSIBLETEXT),
|
---|
288 | toupper(*pszFileName), s);
|
---|
289 | Notify(FileSystem);
|
---|
290 | WinDismissDlg(hwnd, 0);
|
---|
291 | }
|
---|
292 | }
|
---|
293 | else {
|
---|
294 | WinDismissDlg(hwnd, 0);
|
---|
295 | }
|
---|
296 | }
|
---|
297 | else
|
---|
298 | WinDismissDlg(hwnd, 0);
|
---|
299 | break;
|
---|
300 |
|
---|
301 | case WM_CONTROL:
|
---|
302 | return 0;
|
---|
303 |
|
---|
304 | case WM_COMMAND:
|
---|
305 | switch (SHORT1FROMMP(mp1)) {
|
---|
306 | case DID_CANCEL:
|
---|
307 | WinDismissDlg(hwnd, 0);
|
---|
308 | break;
|
---|
309 |
|
---|
310 | case IDM_HELP:
|
---|
311 | if (hwndHelp)
|
---|
312 | WinSendMsg(hwndHelp,
|
---|
313 | HM_DISPLAY_HELP,
|
---|
314 | MPFROM2SHORT(HELP_DRVINFO, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
315 | break;
|
---|
316 |
|
---|
317 | case DID_OK:
|
---|
318 | pszFileName = INSTDATA(hwnd);
|
---|
319 | if (!(driveflags[toupper(*pszFileName) - 'A'] & DRIVE_NOTWRITEABLE)) {
|
---|
320 |
|
---|
321 | CHAR s[CCHMAXPATHCOMP + 3];
|
---|
322 |
|
---|
323 | *s = 0;
|
---|
324 | WinQueryDlgItemText(hwnd, INFO_LABEL, CCHMAXPATHCOMP, s);
|
---|
325 | bstrip(s);
|
---|
326 | if (*s) {
|
---|
327 | struct
|
---|
328 | {
|
---|
329 | ULONG serial;
|
---|
330 | CHAR volumelength;
|
---|
331 | CHAR volumelabel[CCHMAXPATH];
|
---|
332 | }
|
---|
333 | volser;
|
---|
334 |
|
---|
335 | memset(&volser, 0, sizeof(volser));
|
---|
336 | DosError(FERR_DISABLEHARDERR);
|
---|
337 | if (!DosQueryFSInfo(toupper(*pszFileName) - '@',
|
---|
338 | FSIL_VOLSER,
|
---|
339 | &volser,
|
---|
340 | (ULONG) sizeof(volser)) &&
|
---|
341 | stricmp(s, volser.volumelabel)) {
|
---|
342 | memmove(s + 1, s, strlen(s) + 1);
|
---|
343 | *s = strlen(s + 1);
|
---|
344 | DosError(FERR_DISABLEHARDERR);
|
---|
345 | rc = DosSetFSInfo(toupper(*pszFileName) - '@',
|
---|
346 | 2L, (PVOID) s, (ULONG) sizeof(s));
|
---|
347 | if (rc) {
|
---|
348 | Dos_Error(MB_CANCEL, rc, hwnd, __FILE__, __LINE__,
|
---|
349 | "DosSetFSInfo failed");
|
---|
350 | }
|
---|
351 | }
|
---|
352 | }
|
---|
353 | }
|
---|
354 | WinDismissDlg(hwnd, 1);
|
---|
355 | break;
|
---|
356 | }
|
---|
357 | return 0;
|
---|
358 | }
|
---|
359 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
360 | }
|
---|
361 |
|
---|
362 | typedef struct {
|
---|
363 | USHORT size;
|
---|
364 | CHAR szFileName[CCHMAXPATH];
|
---|
365 | BOOL madechanges;
|
---|
366 | } FILESTUF;
|
---|
367 |
|
---|
368 | typedef struct {
|
---|
369 | USHORT size;
|
---|
370 | PFNWP oldproc;
|
---|
371 | FILESTUF *pfs;
|
---|
372 | HWND lasthwndMenu;
|
---|
373 | } ICONSTUF;
|
---|
374 |
|
---|
375 | /*
|
---|
376 | * subclass routine to allow changing a program's icon
|
---|
377 | */
|
---|
378 |
|
---|
379 | MRESULT EXPENTRY IconProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
380 | {
|
---|
381 | ICONSTUF *pis = (ICONSTUF *)WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
382 | MRESULT mr;
|
---|
383 | CHAR *p;
|
---|
384 |
|
---|
385 | static BOOL emphasized = FALSE;
|
---|
386 |
|
---|
387 | if (!pis) {
|
---|
388 | Runtime_Error(pszSrcFile, __LINE__, "no data");
|
---|
389 | if (msg != WM_DESTROY)
|
---|
390 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
391 | }
|
---|
392 |
|
---|
393 | switch (msg) {
|
---|
394 | case DM_DRAGOVER:
|
---|
395 | if (!emphasized) {
|
---|
396 | emphasized = TRUE;
|
---|
397 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
398 | }
|
---|
399 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
400 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
401 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
402 |
|
---|
403 | case DM_DRAGLEAVE:
|
---|
404 | emphasized = FALSE;
|
---|
405 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
406 | break;
|
---|
407 |
|
---|
408 | case DM_DROPHELP:
|
---|
409 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_DROPCHGICONHELPTEXT));
|
---|
410 | return 0;
|
---|
411 |
|
---|
412 | case DM_DROP:
|
---|
413 | {
|
---|
414 | HPOINTER hptr;
|
---|
415 | CHAR szFrom[CCHMAXPATH + 2];
|
---|
416 | ICONINFO ici;
|
---|
417 |
|
---|
418 | emphasized = FALSE;
|
---|
419 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
420 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
|
---|
421 | memset(&ici, 0, sizeof(ICONINFO));
|
---|
422 | ici.cb = sizeof(ICONINFO);
|
---|
423 | ici.fFormat = ICON_FILE;
|
---|
424 | ici.pszFileName = szFrom;
|
---|
425 | if (!WinSetFileIcon((PSZ) pis->pfs->szFileName, (PICONINFO) & ici)) {
|
---|
426 | ici.fFormat = ICON_CLEAR;
|
---|
427 | WinSetFileIcon((PSZ) pis->pfs->szFileName, (PICONINFO) & ici);
|
---|
428 | }
|
---|
429 | hptr = WinLoadFileIcon(pis->pfs->szFileName, FALSE);
|
---|
430 | if (!hptr)
|
---|
431 | hptr = (!IsFile(pis->pfs->szFileName)) ? hptrDir : hptrFile;
|
---|
432 | if (pis && pis->oldproc) {
|
---|
433 | WinShowWindow(hwnd, FALSE);
|
---|
434 | pis->oldproc(hwnd, SM_SETHANDLE, MPFROMLONG(hptr), MPVOID);
|
---|
435 | WinShowWindow(hwnd, TRUE);
|
---|
436 | WinInvalidateRect(WinQueryWindow(hwnd, QW_PARENT), NULL, TRUE);
|
---|
437 | }
|
---|
438 | }
|
---|
439 | }
|
---|
440 | return 0;
|
---|
441 |
|
---|
442 | case WM_PAINT:
|
---|
443 | mr = pis->oldproc(hwnd, msg, mp1, mp2);
|
---|
444 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
|
---|
445 | return mr;
|
---|
446 | break;
|
---|
447 |
|
---|
448 | case WM_MENUEND:
|
---|
449 | if (pis->lasthwndMenu == (HWND)mp2)
|
---|
450 | WinDestroyWindow(pis->lasthwndMenu);
|
---|
451 | pis->lasthwndMenu = (HWND) 0;
|
---|
452 | break;
|
---|
453 |
|
---|
454 | case WM_CONTEXTMENU:
|
---|
455 | if (pis->lasthwndMenu)
|
---|
456 | WinDestroyWindow(pis->lasthwndMenu);
|
---|
457 | pis->lasthwndMenu = WinLoadMenu(hwnd, FM3ModHandle, FLE_FRAME);
|
---|
458 | if (pis->lasthwndMenu) {
|
---|
459 | p = strrchr(pis->pfs->szFileName, '.');
|
---|
460 | if (!p || (stricmp(p, ".ICO") && stricmp(p, ".PTR")))
|
---|
461 | WinSendMsg(pis->lasthwndMenu,
|
---|
462 | MM_DELETEITEM,
|
---|
463 | MPFROM2SHORT(IDM_SELECTALL, TRUE), MPVOID);
|
---|
464 | PopupMenu(hwnd, hwnd, pis->lasthwndMenu);
|
---|
465 | }
|
---|
466 | break;
|
---|
467 |
|
---|
468 | case WM_COMMAND:
|
---|
469 | switch (SHORT1FROMMP(mp1)) {
|
---|
470 | case IDM_SELECTALL:
|
---|
471 | case IDM_DESELECTALL:
|
---|
472 | WinDlgBox(HWND_DESKTOP,
|
---|
473 | hwnd,
|
---|
474 | SetIconDlgProc,
|
---|
475 | FM3ModHandle,
|
---|
476 | SETICON_FRAME,
|
---|
477 | (PVOID) ((SHORT1FROMMP(mp1) == IDM_SELECTALL) ?
|
---|
478 | pis->pfs->szFileName : NULL));
|
---|
479 | break;
|
---|
480 | }
|
---|
481 | return 0;
|
---|
482 |
|
---|
483 | case WM_DESTROY:
|
---|
484 | emphasized = FALSE;
|
---|
485 | if (!pis)
|
---|
486 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
487 | else {
|
---|
488 | PFNWP oldproc = pis->oldproc;
|
---|
489 | if (pis->lasthwndMenu)
|
---|
490 | WinDestroyWindow(pis->lasthwndMenu);
|
---|
491 | free(pis);
|
---|
492 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
493 | }
|
---|
494 | break;
|
---|
495 | }
|
---|
496 |
|
---|
497 | return pis->oldproc(hwnd, msg, mp1, mp2);
|
---|
498 | }
|
---|
499 |
|
---|
500 | MRESULT EXPENTRY FileInfoProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
501 | {
|
---|
502 | FILESTUF *pfs;
|
---|
503 | ICONSTUF *pis;
|
---|
504 | CHAR **ppsz;
|
---|
505 |
|
---|
506 | switch (msg) {
|
---|
507 | case WM_INITDLG:
|
---|
508 | if (!mp2) {
|
---|
509 | WinDismissDlg(hwnd, 1);
|
---|
510 | break;
|
---|
511 | }
|
---|
512 | pfs = xmallocz(sizeof(FILESTUF), pszSrcFile, __LINE__);
|
---|
513 | if (!pfs) {
|
---|
514 | WinDismissDlg(hwnd, 1);
|
---|
515 | break;
|
---|
516 | }
|
---|
517 | pfs->size = sizeof(FILESTUF);
|
---|
518 | WinSetWindowPtr(hwnd, QWL_USER, pfs);
|
---|
519 | {
|
---|
520 | USHORT ids[] = { FLE_SIZES, FLE_SLACK, FLE_LASTWRITE, FLE_CREATE,
|
---|
521 | FLE_LASTACCESS, 0
|
---|
522 | };
|
---|
523 | INT x;
|
---|
524 | CHAR s[CCHMAXPATH];
|
---|
525 |
|
---|
526 | ppsz = (CHAR **)mp2;
|
---|
527 | for (x = 0; ppsz[x]; x++) {
|
---|
528 | if (DosQueryPathInfo(ppsz[x], FIL_QUERYFULLNAME, s, sizeof(s)))
|
---|
529 | strcpy(s, ppsz[x]);
|
---|
530 | WinSendDlgItemMsg(hwnd,
|
---|
531 | FLE_NAME,
|
---|
532 | LM_INSERTITEM,
|
---|
533 | MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s));
|
---|
534 | }
|
---|
535 | if (!x) {
|
---|
536 | WinDismissDlg(hwnd, 1);
|
---|
537 | break;
|
---|
538 | }
|
---|
539 | WinSendDlgItemMsg(hwnd,
|
---|
540 | FLE_NAME,
|
---|
541 | LM_SELECTITEM, MPFROM2SHORT(0, 0), MPFROMSHORT(TRUE));
|
---|
542 | for (x = 0; ids[x]; x++)
|
---|
543 | SetPresParams(WinWindowFromID(hwnd, ids[x]),
|
---|
544 | &RGBGREY, &RGBBLACK, &RGBBLACK, NULL);
|
---|
545 | }
|
---|
546 | pis = xmallocz(sizeof(ICONSTUF), pszSrcFile, __LINE__);
|
---|
547 | if (!pis) {
|
---|
548 | WinDismissDlg(hwnd, 1);
|
---|
549 | break;
|
---|
550 | }
|
---|
551 | WinSetWindowPtr(WinWindowFromID(hwnd, FLE_ICON), QWL_USER, (PVOID) pis);
|
---|
552 | pis->size = sizeof(ICONSTUF);
|
---|
553 | pis->pfs = pfs;
|
---|
554 | pis->oldproc = WinSubclassWindow(WinWindowFromID(hwnd, FLE_ICON),
|
---|
555 | IconProc);
|
---|
556 | break;
|
---|
557 |
|
---|
558 | case WM_CONTROL:
|
---|
559 | switch (SHORT1FROMMP(mp1)) {
|
---|
560 | case FLE_READONLY:
|
---|
561 | case FLE_ARCHIVED:
|
---|
562 | case FLE_SYSTEM:
|
---|
563 | case FLE_HIDDEN:
|
---|
564 | switch (SHORT2FROMMP(mp1)) {
|
---|
565 | case BN_CLICKED:
|
---|
566 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
567 | if (pfs && *pfs->szFileName) {
|
---|
568 |
|
---|
569 | LISTINFO li;
|
---|
570 | UINT numfiles = 0, numalloc = 0;
|
---|
571 |
|
---|
572 | memset(&li, 0, sizeof(LISTINFO));
|
---|
573 | if (!AddToList(pfs->szFileName, &li.list, &numfiles, &numalloc)) {
|
---|
574 | if (WinDlgBox(HWND_DESKTOP,
|
---|
575 | hwnd,
|
---|
576 | AttrListDlgProc,
|
---|
577 | FM3ModHandle,
|
---|
578 | ATR_FRAME, MPFROMP(&li)) && li.list && li.list[0]) {
|
---|
579 | pfs->madechanges = TRUE;
|
---|
580 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
581 | }
|
---|
582 | FreeList(li.list);
|
---|
583 | }
|
---|
584 | }
|
---|
585 | break;
|
---|
586 | } // switch
|
---|
587 | break;
|
---|
588 | case FLE_NAME:
|
---|
589 | switch (SHORT2FROMMP(mp1)) {
|
---|
590 | case LN_ENTER:
|
---|
591 | case LN_SELECT:
|
---|
592 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
593 | if (!pfs) {
|
---|
594 | Runtime_Error(pszSrcFile, __LINE__, "no data");
|
---|
595 | WinDismissDlg(hwnd, 1);
|
---|
596 | }
|
---|
597 | else {
|
---|
598 |
|
---|
599 | SHORT sSelect;
|
---|
600 |
|
---|
601 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
602 | FLE_NAME,
|
---|
603 | LM_QUERYSELECTION,
|
---|
604 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
605 | if (sSelect >= 0) {
|
---|
606 | *pfs->szFileName = 0;
|
---|
607 | WinSendDlgItemMsg(hwnd,
|
---|
608 | FLE_NAME,
|
---|
609 | LM_QUERYITEMTEXT,
|
---|
610 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
---|
611 | MPFROMP(pfs->szFileName));
|
---|
612 | if (*pfs->szFileName) {
|
---|
613 | if (SHORT2FROMMP(mp1) == LN_SELECT)
|
---|
614 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
615 | else
|
---|
616 | DefaultView(hwnd,
|
---|
617 | (HWND) 0, (HWND) 0, NULL, 32, pfs->szFileName);
|
---|
618 | }
|
---|
619 | }
|
---|
620 | }
|
---|
621 | break;
|
---|
622 | }
|
---|
623 | break;
|
---|
624 | }
|
---|
625 | return 0;
|
---|
626 |
|
---|
627 | case UM_SETDIR:
|
---|
628 | WinCheckButton(hwnd, FLE_READONLY, FALSE);
|
---|
629 | WinCheckButton(hwnd, FLE_ARCHIVED, FALSE);
|
---|
630 | WinCheckButton(hwnd, FLE_SYSTEM, FALSE);
|
---|
631 | WinCheckButton(hwnd, FLE_HIDDEN, FALSE);
|
---|
632 | WinCheckButton(hwnd, FLE_DIRECTORY, FALSE);
|
---|
633 | WinCheckButton(hwnd, FLE_READABLE, FALSE);
|
---|
634 | WinCheckButton(hwnd, FLE_WRITEABLE, FALSE);
|
---|
635 | WinCheckButton(hwnd, FLE_OPEN, FALSE);
|
---|
636 | WinCheckButton(hwnd, FLE_BINARY, FALSE);
|
---|
637 | WinCheckButton(hwnd, FLE_ISARCHIVE, FALSE);
|
---|
638 | WinSetDlgItemText(hwnd, FLE_ARCNAME, NullStr);
|
---|
639 | WinCheckButton(hwnd, FLE_OS2FS, FALSE);
|
---|
640 | WinCheckButton(hwnd, FLE_OS2WIN, FALSE);
|
---|
641 | WinCheckButton(hwnd, FLE_OS2PM, FALSE);
|
---|
642 | WinCheckButton(hwnd, FLE_DOS, FALSE);
|
---|
643 | WinCheckButton(hwnd, FLE_32BIT, FALSE);
|
---|
644 | WinCheckButton(hwnd, FLE_WINREAL, FALSE);
|
---|
645 | WinCheckButton(hwnd, FLE_WINPROT, FALSE);
|
---|
646 | WinCheckButton(hwnd, FLE_WINENH, FALSE);
|
---|
647 | WinCheckButton(hwnd, FLE_DLL, FALSE);
|
---|
648 | WinCheckButton(hwnd, FLE_PHYSDRV, FALSE);
|
---|
649 | WinCheckButton(hwnd, FLE_VIRTDRV, FALSE);
|
---|
650 | WinCheckButton(hwnd, FLE_PROTDLL, FALSE);
|
---|
651 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
652 | if (pfs && *pfs->szFileName) {
|
---|
653 | CHAR s[97];
|
---|
654 | CHAR szCmmaFmtFileSize[81], szCmmaFmtEASize[81];
|
---|
655 | CHAR szCmmaFmtFileEASize[81], szCmmaFmtFileEASizeK[81];
|
---|
656 | FILEFINDBUF4L fs;
|
---|
657 | HDIR hdir = HDIR_CREATE;
|
---|
658 | ULONG apptype = 1;
|
---|
659 | FILE *fp;
|
---|
660 | HPOINTER hptr;
|
---|
661 | ARC_TYPE *info;
|
---|
662 |
|
---|
663 | DosError(FERR_DISABLEHARDERR);
|
---|
664 | if (xDosFindFirst(pfs->szFileName,
|
---|
665 | &hdir,
|
---|
666 | FILE_NORMAL | FILE_ARCHIVED |
|
---|
667 | FILE_DIRECTORY | FILE_READONLY | FILE_HIDDEN |
|
---|
668 | FILE_SYSTEM,
|
---|
669 | &fs, sizeof(fs), &apptype, FIL_QUERYEASIZEL)) {
|
---|
670 | // Not found
|
---|
671 | SHORT sSelect, numitems;
|
---|
672 |
|
---|
673 | DosBeep(250, 100); // Wake up user
|
---|
674 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
675 | FLE_NAME,
|
---|
676 | LM_QUERYSELECTION,
|
---|
677 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
678 | if (sSelect >= 0) {
|
---|
679 | WinSendDlgItemMsg(hwnd,
|
---|
680 | FLE_NAME,
|
---|
681 | LM_DELETEITEM, MPFROMSHORT(sSelect), MPVOID);
|
---|
682 | numitems = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
683 | FLE_NAME,
|
---|
684 | LM_QUERYITEMCOUNT,
|
---|
685 | MPVOID, MPVOID);
|
---|
686 | if (numitems)
|
---|
687 | PostMsg(WinWindowFromID(hwnd, FLE_NAME),
|
---|
688 | LM_SELECTITEM,
|
---|
689 | MPFROMSHORT(((sSelect) ? sSelect - 1 : 0)),
|
---|
690 | MPFROMSHORT(TRUE));
|
---|
691 | }
|
---|
692 | }
|
---|
693 | else {
|
---|
694 | DosFindClose(hdir);
|
---|
695 | sprintf(s,
|
---|
696 | "%04u/%02u/%02u %02u:%02u:%02u",
|
---|
697 | 1980 + fs.fdateLastWrite.year,
|
---|
698 | fs.fdateLastWrite.month,
|
---|
699 | fs.fdateLastWrite.day,
|
---|
700 | fs.ftimeLastWrite.hours,
|
---|
701 | fs.ftimeLastWrite.minutes, fs.ftimeLastWrite.twosecs * 2);
|
---|
702 | WinSetDlgItemText(hwnd, FLE_LASTWRITE, s);
|
---|
703 | if (fs.fdateCreation.year &&
|
---|
704 | fs.fdateCreation.month && fs.fdateCreation.day) {
|
---|
705 | sprintf(s,
|
---|
706 | "%04u/%02u/%02u %02u:%02u:%02u",
|
---|
707 | 1980 + fs.fdateCreation.year,
|
---|
708 | fs.fdateCreation.month,
|
---|
709 | fs.fdateCreation.day,
|
---|
710 | fs.ftimeCreation.hours,
|
---|
711 | fs.ftimeCreation.minutes, fs.ftimeCreation.twosecs * 2);
|
---|
712 | WinSetDlgItemText(hwnd, FLE_CREATE, s);
|
---|
713 | }
|
---|
714 | if (fs.fdateLastAccess.year &&
|
---|
715 | fs.fdateLastAccess.month && fs.fdateLastAccess.day) {
|
---|
716 | sprintf(s,
|
---|
717 | "%04u/%02u/%02u %02u:%02u:%02u",
|
---|
718 | 1980 + fs.fdateLastAccess.year,
|
---|
719 | fs.fdateLastAccess.month,
|
---|
720 | fs.fdateLastAccess.day,
|
---|
721 | fs.ftimeLastAccess.hours,
|
---|
722 | fs.ftimeLastAccess.minutes, fs.ftimeLastAccess.twosecs * 2);
|
---|
723 | WinSetDlgItemText(hwnd, FLE_LASTACCESS, s);
|
---|
724 | }
|
---|
725 | CommaFmtULL(szCmmaFmtFileSize,
|
---|
726 | sizeof(szCmmaFmtFileSize), fs.cbFile, ' ');
|
---|
727 | CommaFmtULL(szCmmaFmtEASize,
|
---|
728 | sizeof(szCmmaFmtEASize), CBLIST_TO_EASIZE(fs.cbList), ' ');
|
---|
729 | CommaFmtULL(szCmmaFmtFileEASize,
|
---|
730 | sizeof(szCmmaFmtFileEASize),
|
---|
731 | fs.cbFile + CBLIST_TO_EASIZE(fs.cbList),
|
---|
732 | ' ');
|
---|
733 | CommaFmtULL(szCmmaFmtFileEASizeK,
|
---|
734 | sizeof(szCmmaFmtFileEASizeK),
|
---|
735 | fs.cbFile + CBLIST_TO_EASIZE(fs.cbList),
|
---|
736 | 'K');
|
---|
737 | sprintf(s,
|
---|
738 | GetPString(IDS_SIZEINCLEASTEXT),
|
---|
739 | szCmmaFmtFileSize,
|
---|
740 | szCmmaFmtEASize,
|
---|
741 | szCmmaFmtFileEASize,
|
---|
742 | szCmmaFmtFileEASizeK);
|
---|
743 | WinSetDlgItemText(hwnd, FLE_SIZES, s);
|
---|
744 | CommaFmtULL(szCmmaFmtFileSize,
|
---|
745 | sizeof(szCmmaFmtFileSize), fs.cbFileAlloc - fs.cbFile, ' ');
|
---|
746 | sprintf(s, "%s", szCmmaFmtFileSize);
|
---|
747 | WinSetDlgItemText(hwnd, FLE_SLACK, s);
|
---|
748 | WinCheckButton(hwnd,
|
---|
749 | FLE_READONLY, ((fs.attrFile & FILE_READONLY) != 0));
|
---|
750 | WinCheckButton(hwnd,
|
---|
751 | FLE_ARCHIVED, ((fs.attrFile & FILE_ARCHIVED) != 0));
|
---|
752 | WinCheckButton(hwnd,
|
---|
753 | FLE_DIRECTORY, ((fs.attrFile & FILE_DIRECTORY) != 0));
|
---|
754 | WinCheckButton(hwnd, FLE_HIDDEN, ((fs.attrFile & FILE_HIDDEN) != 0));
|
---|
755 | WinCheckButton(hwnd, FLE_SYSTEM, ((fs.attrFile & FILE_SYSTEM) != 0));
|
---|
756 | DosError(FERR_DISABLEHARDERR);
|
---|
757 | if (!DosQueryAppType(pfs->szFileName, &apptype)) {
|
---|
758 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2FS), TRUE);
|
---|
759 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2WIN), TRUE);
|
---|
760 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2PM), TRUE);
|
---|
761 | WinEnableWindow(WinWindowFromID(hwnd, FLE_BOUND), TRUE);
|
---|
762 | WinEnableWindow(WinWindowFromID(hwnd, FLE_32BIT), TRUE);
|
---|
763 | WinEnableWindow(WinWindowFromID(hwnd, FLE_DOS), TRUE);
|
---|
764 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINPROT), TRUE);
|
---|
765 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINREAL), TRUE);
|
---|
766 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINENH), TRUE);
|
---|
767 | WinEnableWindow(WinWindowFromID(hwnd, FLE_DLL), TRUE);
|
---|
768 | WinEnableWindow(WinWindowFromID(hwnd, FLE_PHYSDRV), TRUE);
|
---|
769 | WinEnableWindow(WinWindowFromID(hwnd, FLE_VIRTDRV), TRUE);
|
---|
770 | WinEnableWindow(WinWindowFromID(hwnd, FLE_PROTDLL), TRUE);
|
---|
771 | WinCheckButton(hwnd, FLE_OS2FS,
|
---|
772 | ((apptype & FAPPTYP_NOTWINDOWCOMPAT) &&
|
---|
773 | !(apptype & FAPPTYP_WINDOWCOMPAT)));
|
---|
774 | WinCheckButton(hwnd, FLE_OS2WIN,
|
---|
775 | ((apptype & FAPPTYP_WINDOWCOMPAT) &&
|
---|
776 | !(apptype & FAPPTYP_NOTWINDOWCOMPAT)));
|
---|
777 | WinCheckButton(hwnd, FLE_OS2PM,
|
---|
778 | ((apptype & FAPPTYP_WINDOWAPI) ==
|
---|
779 | FAPPTYP_WINDOWAPI));
|
---|
780 | WinCheckButton(hwnd, FLE_BOUND, ((apptype & FAPPTYP_BOUND) != 0));
|
---|
781 | WinCheckButton(hwnd, FLE_DLL, ((apptype & FAPPTYP_DLL) != 0));
|
---|
782 | WinCheckButton(hwnd, FLE_DOS, ((apptype & FAPPTYP_DOS) != 0));
|
---|
783 | WinCheckButton(hwnd, FLE_PHYSDRV,
|
---|
784 | ((apptype & FAPPTYP_PHYSDRV) != 0));
|
---|
785 | WinCheckButton(hwnd, FLE_VIRTDRV,
|
---|
786 | ((apptype & FAPPTYP_VIRTDRV) != 0));
|
---|
787 | WinCheckButton(hwnd, FLE_PROTDLL,
|
---|
788 | ((apptype & FAPPTYP_PROTDLL) != 0));
|
---|
789 | WinCheckButton(hwnd, FLE_WINREAL,
|
---|
790 | ((apptype & FAPPTYP_WINDOWSREAL) != 0));
|
---|
791 | WinCheckButton(hwnd, FLE_WINPROT,
|
---|
792 | ((apptype & FAPPTYP_WINDOWSPROT) != 0));
|
---|
793 | WinCheckButton(hwnd, FLE_32BIT, ((apptype & FAPPTYP_32BIT) != 0));
|
---|
794 | WinCheckButton(hwnd, FLE_WINENH, ((apptype & 0x1000) != 0));
|
---|
795 | }
|
---|
796 | else {
|
---|
797 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2FS), FALSE);
|
---|
798 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2WIN), FALSE);
|
---|
799 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2PM), FALSE);
|
---|
800 | WinEnableWindow(WinWindowFromID(hwnd, FLE_BOUND), FALSE);
|
---|
801 | WinEnableWindow(WinWindowFromID(hwnd, FLE_32BIT), FALSE);
|
---|
802 | WinEnableWindow(WinWindowFromID(hwnd, FLE_DOS), FALSE);
|
---|
803 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINPROT), FALSE);
|
---|
804 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINREAL), FALSE);
|
---|
805 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINENH), FALSE);
|
---|
806 | WinEnableWindow(WinWindowFromID(hwnd, FLE_DLL), FALSE);
|
---|
807 | WinEnableWindow(WinWindowFromID(hwnd, FLE_PHYSDRV), FALSE);
|
---|
808 | WinEnableWindow(WinWindowFromID(hwnd, FLE_VIRTDRV), FALSE);
|
---|
809 | WinEnableWindow(WinWindowFromID(hwnd, FLE_PROTDLL), FALSE);
|
---|
810 | }
|
---|
811 | hptr = WinLoadFileIcon(pfs->szFileName, FALSE);
|
---|
812 | WinShowWindow(WinWindowFromID(hwnd, FLE_ICON), FALSE);
|
---|
813 | if (hptr) {
|
---|
814 | WinSendDlgItemMsg(hwnd,
|
---|
815 | FLE_ICON, SM_SETHANDLE, MPFROMLONG(hptr), MPVOID);
|
---|
816 | WinShowWindow(WinWindowFromID(hwnd, FLE_ICON), TRUE);
|
---|
817 | }
|
---|
818 | WinShowWindow(WinWindowFromID(hwnd, FLE_EAS), fs.cbList > 4);
|
---|
819 | if (!(fs.attrFile & FILE_DIRECTORY)) {
|
---|
820 | WinEnableWindow(WinWindowFromID(hwnd, FLE_READABLE), TRUE);
|
---|
821 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WRITEABLE), TRUE);
|
---|
822 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OPEN), TRUE);
|
---|
823 | WinEnableWindow(WinWindowFromID(hwnd, FLE_ISARCHIVE), TRUE);
|
---|
824 | WinEnableWindow(WinWindowFromID(hwnd, FLE_BINARY), TRUE);
|
---|
825 | fp = _fsopen(pfs->szFileName, "rb", SH_DENYNO);
|
---|
826 | if (fp) {
|
---|
827 | // char buff[512];
|
---|
828 | char buff[4096]; // 06 Oct 07 SHL protect against NTFS defect
|
---|
829 | ULONG len;
|
---|
830 | APIRET rc;
|
---|
831 |
|
---|
832 | len = 512;
|
---|
833 | rc = DosRead(fileno(fp), buff, len, &len);
|
---|
834 | fclose(fp);
|
---|
835 | WinCheckButton(hwnd,
|
---|
836 | FLE_BINARY,
|
---|
837 | ((len && rc) ? IsBinary(buff, len) : 2));
|
---|
838 | WinCheckButton(hwnd, FLE_READABLE, TRUE);
|
---|
839 | info = find_type(pfs->szFileName, NULL);
|
---|
840 | if (info) {
|
---|
841 | WinCheckButton(hwnd, FLE_ISARCHIVE, 1);
|
---|
842 | if (info->id)
|
---|
843 | WinSetDlgItemText(hwnd, FLE_ARCNAME, info->id);
|
---|
844 | }
|
---|
845 | }
|
---|
846 | else {
|
---|
847 | WinCheckButton(hwnd, FLE_ISARCHIVE, 2);
|
---|
848 | WinCheckButton(hwnd, FLE_BINARY, 2);
|
---|
849 | }
|
---|
850 | fp = _fsopen(pfs->szFileName, "ab", SH_DENYNO);
|
---|
851 | if (fp) {
|
---|
852 | WinCheckButton(hwnd, FLE_WRITEABLE, TRUE);
|
---|
853 | fclose(fp);
|
---|
854 | }
|
---|
855 | fp = _fsopen(pfs->szFileName, "rb", SH_DENYRW);
|
---|
856 | if (!fp)
|
---|
857 | WinCheckButton(hwnd, FLE_OPEN, TRUE);
|
---|
858 | else
|
---|
859 | fclose(fp);
|
---|
860 | }
|
---|
861 | else {
|
---|
862 | WinEnableWindow(WinWindowFromID(hwnd, FLE_READABLE), FALSE);
|
---|
863 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WRITEABLE), FALSE);
|
---|
864 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OPEN), FALSE);
|
---|
865 | WinEnableWindow(WinWindowFromID(hwnd, FLE_ISARCHIVE), FALSE);
|
---|
866 | WinEnableWindow(WinWindowFromID(hwnd, FLE_BINARY), FALSE);
|
---|
867 | }
|
---|
868 | }
|
---|
869 | }
|
---|
870 | return 0;
|
---|
871 |
|
---|
872 | case WM_COMMAND:
|
---|
873 | switch (SHORT1FROMMP(mp1)) {
|
---|
874 | case DID_OK:
|
---|
875 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
876 | WinDismissDlg(hwnd, (pfs && pfs->madechanges) ? 2 : 1);
|
---|
877 | break;
|
---|
878 | case IDM_HELP:
|
---|
879 | if (hwndHelp)
|
---|
880 | WinSendMsg(hwndHelp,
|
---|
881 | HM_DISPLAY_HELP,
|
---|
882 | MPFROM2SHORT(HELP_INFO, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
883 | break;
|
---|
884 | case FLE_SETTINGS:
|
---|
885 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
886 | if (pfs && *pfs->szFileName)
|
---|
887 | OpenObject(pfs->szFileName, Settings, hwnd);
|
---|
888 | break;
|
---|
889 | case FLE_EAS:
|
---|
890 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
891 | if (pfs && *pfs->szFileName) {
|
---|
892 |
|
---|
893 | CHAR *list[2];
|
---|
894 |
|
---|
895 | list[0] = pfs->szFileName;
|
---|
896 | list[1] = NULL;
|
---|
897 | WinDlgBox(HWND_DESKTOP,
|
---|
898 | hwnd, DisplayEAsProc, FM3ModHandle, EA_FRAME, (PVOID) list);
|
---|
899 | }
|
---|
900 | break;
|
---|
901 | case DID_CANCEL:
|
---|
902 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
903 | WinDismissDlg(hwnd, (pfs && pfs->madechanges) ? 2 : 0);
|
---|
904 | break;
|
---|
905 | }
|
---|
906 | return 0;
|
---|
907 |
|
---|
908 | case WM_DESTROY:
|
---|
909 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
910 | xfree(pfs, pszSrcFile, __LINE__);
|
---|
911 | break;
|
---|
912 | }
|
---|
913 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
914 | }
|
---|
915 |
|
---|
916 | MRESULT EXPENTRY SetDrvProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
917 | {
|
---|
918 | switch (msg) {
|
---|
919 | case WM_INITDLG:
|
---|
920 | if (!mp2 || !isalpha(*(CHAR *)mp2))
|
---|
921 | WinDismissDlg(hwnd, 0);
|
---|
922 | else {
|
---|
923 |
|
---|
924 | CHAR s[80];
|
---|
925 |
|
---|
926 | WinSetWindowULong(hwnd, QWL_USER, (toupper(*(CHAR *)mp2) - 'A'));
|
---|
927 | sprintf(s, GetPString(IDS_DRIVEFLAGSTITLETEXT), toupper(*(CHAR *)mp2));
|
---|
928 | WinSetWindowText(hwnd, s);
|
---|
929 | /*
|
---|
930 | WinEnableWindow(WinWindowFromID(hwnd,DVS_REMOVABLE),FALSE);
|
---|
931 | WinEnableWindow(WinWindowFromID(hwnd,DVS_NOTWRITEABLE),FALSE);
|
---|
932 | WinEnableWindow(WinWindowFromID(hwnd,DVS_IGNORE),FALSE);
|
---|
933 | WinEnableWindow(WinWindowFromID(hwnd,DVS_CDROM),FALSE);
|
---|
934 | WinEnableWindow(WinWindowFromID(hwnd,DVS_NOLONGNAMES),FALSE);
|
---|
935 | WinEnableWindow(WinWindowFromID(hwnd,DVS_REMOTE),FALSE);
|
---|
936 | WinEnableWindow(WinWindowFromID(hwnd,DVS_VIRTUAL),FALSE);
|
---|
937 | WinEnableWindow(WinWindowFromID(hwnd,DVS_RAMDISK),FALSE);
|
---|
938 | WinEnableWindow(WinWindowFromID(hwnd,DVS_BOOT),FALSE);
|
---|
939 | WinEnableWindow(WinWindowFromID(hwnd,DVS_INVALID),FALSE);
|
---|
940 | WinEnableWindow(WinWindowFromID(hwnd,DVS_ZIPSTREAM),FALSE);
|
---|
941 | WinEnableWindow(WinWindowFromID(hwnd,DVS_NOSTATS),FALSE);
|
---|
942 | */
|
---|
943 | PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
944 | }
|
---|
945 | break;
|
---|
946 |
|
---|
947 | case UM_UNDO:
|
---|
948 | {
|
---|
949 | ULONG drive = WinQueryWindowULong(hwnd, QWL_USER);
|
---|
950 |
|
---|
951 | WinCheckButton(hwnd, DVS_REMOVABLE,
|
---|
952 | ((driveflags[drive] & DRIVE_REMOVABLE) != 0));
|
---|
953 | WinCheckButton(hwnd, DVS_NOTWRITEABLE,
|
---|
954 | ((driveflags[drive] & DRIVE_NOTWRITEABLE) != 0));
|
---|
955 | WinCheckButton(hwnd, DVS_IGNORE,
|
---|
956 | ((driveflags[drive] & DRIVE_IGNORE) != 0));
|
---|
957 | WinCheckButton(hwnd, DVS_CDROM,
|
---|
958 | ((driveflags[drive] & DRIVE_CDROM) != 0));
|
---|
959 | WinCheckButton(hwnd, DVS_NOLONGNAMES,
|
---|
960 | ((driveflags[drive] & DRIVE_NOLONGNAMES) != 0));
|
---|
961 | WinCheckButton(hwnd, DVS_REMOTE,
|
---|
962 | ((driveflags[drive] & DRIVE_REMOTE) != 0));
|
---|
963 | WinCheckButton(hwnd,DVS_VIRTUAL,
|
---|
964 | ((driveflags[drive] & DRIVE_VIRTUAL) != 0));
|
---|
965 | WinCheckButton(hwnd,DVS_RAMDISK,
|
---|
966 | ((driveflags[drive] & DRIVE_RAMDISK) != 0));
|
---|
967 | WinCheckButton(hwnd, DVS_BOOT,
|
---|
968 | ((driveflags[drive] & DRIVE_BOOT) != 0));
|
---|
969 | WinCheckButton(hwnd, DVS_INVALID,
|
---|
970 | ((driveflags[drive] & DRIVE_INVALID) != 0));
|
---|
971 | WinCheckButton(hwnd, DVS_NOPRESCAN,
|
---|
972 | ((driveflags[drive] & DRIVE_NOPRESCAN) != 0));
|
---|
973 | WinCheckButton(hwnd, DVS_ZIPSTREAM,
|
---|
974 | ((driveflags[drive] & DRIVE_ZIPSTREAM) != 0));
|
---|
975 | WinCheckButton(hwnd, DVS_NOLOADICONS,
|
---|
976 | ((driveflags[drive] & DRIVE_NOLOADICONS) != 0));
|
---|
977 | WinCheckButton(hwnd, DVS_NOLOADSUBJS,
|
---|
978 | ((driveflags[drive] & DRIVE_NOLOADSUBJS) != 0));
|
---|
979 | WinCheckButton(hwnd, DVS_NOLOADLONGS,
|
---|
980 | ((driveflags[drive] & DRIVE_NOLOADLONGS) != 0));
|
---|
981 | WinCheckButton(hwnd, DVS_SLOW, ((driveflags[drive] & DRIVE_SLOW) != 0));
|
---|
982 | WinCheckButton(hwnd, DVS_INCLUDEFILES,
|
---|
983 | ((driveflags[drive] & DRIVE_INCLUDEFILES) != 0));
|
---|
984 | WinCheckButton(hwnd,DVS_NOSTATS,
|
---|
985 | ((driveflags[drive] & DRIVE_NOSTATS) != 0));
|
---|
986 | }
|
---|
987 | return 0;
|
---|
988 |
|
---|
989 | case WM_CONTROL:
|
---|
990 | return 0;
|
---|
991 |
|
---|
992 | case WM_COMMAND:
|
---|
993 | switch (SHORT1FROMMP(mp1)) {
|
---|
994 | case DID_OK:
|
---|
995 | {
|
---|
996 | ULONG drive = WinQueryWindowULong(hwnd, QWL_USER);
|
---|
997 |
|
---|
998 | if (WinQueryButtonCheckstate(hwnd, DVS_NOPRESCAN))
|
---|
999 | driveflags[drive] |= DRIVE_NOPRESCAN;
|
---|
1000 | else
|
---|
1001 | driveflags[drive] &= (~DRIVE_NOPRESCAN);
|
---|
1002 | if (WinQueryButtonCheckstate(hwnd, DVS_NOLOADICONS))
|
---|
1003 | driveflags[drive] |= DRIVE_NOLOADICONS;
|
---|
1004 | else
|
---|
1005 | driveflags[drive] &= (~DRIVE_NOLOADICONS);
|
---|
1006 | if (WinQueryButtonCheckstate(hwnd, DVS_NOLOADSUBJS))
|
---|
1007 | driveflags[drive] |= DRIVE_NOLOADSUBJS;
|
---|
1008 | else
|
---|
1009 | driveflags[drive] &= (~DRIVE_NOLOADSUBJS);
|
---|
1010 | if (WinQueryButtonCheckstate(hwnd, DVS_NOLOADLONGS))
|
---|
1011 | driveflags[drive] |= DRIVE_NOLOADLONGS;
|
---|
1012 | else
|
---|
1013 | driveflags[drive] &= (~DRIVE_NOLOADLONGS);
|
---|
1014 | if (WinQueryButtonCheckstate(hwnd, DVS_SLOW))
|
---|
1015 | driveflags[drive] |= DRIVE_SLOW;
|
---|
1016 | else
|
---|
1017 | driveflags[drive] &= (~DRIVE_SLOW);
|
---|
1018 | if (WinQueryButtonCheckstate(hwnd, DVS_INCLUDEFILES))
|
---|
1019 | driveflags[drive] |= DRIVE_INCLUDEFILES;
|
---|
1020 | else
|
---|
1021 | driveflags[drive] &= (~DRIVE_INCLUDEFILES);
|
---|
1022 | if (WinQueryButtonCheckstate(hwnd,DVS_NOSTATS))
|
---|
1023 | driveflags[drive] |= DRIVE_NOSTATS;
|
---|
1024 | else
|
---|
1025 | driveflags[drive] &= (~DRIVE_NOSTATS);
|
---|
1026 | {
|
---|
1027 | ULONG flags;
|
---|
1028 | CHAR s[80];
|
---|
1029 |
|
---|
1030 | sprintf(s, "%c.DriveFlags", (CHAR) (drive + 'A'));
|
---|
1031 | flags = driveflags[drive];
|
---|
1032 | flags &= (~(DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
|
---|
1033 | DRIVE_IGNORE | DRIVE_CDROM |
|
---|
1034 | DRIVE_NOLONGNAMES | DRIVE_REMOTE |
|
---|
1035 | DRIVE_BOOT | DRIVE_INVALID | DRIVE_ZIPSTREAM |
|
---|
1036 | DRIVE_VIRTUAL | DRIVE_RAMDISK));
|
---|
1037 | PrfWriteProfileData(fmprof, appname, s, &flags, sizeof(ULONG));
|
---|
1038 | }
|
---|
1039 | }
|
---|
1040 | WinDismissDlg(hwnd, 1);
|
---|
1041 | break;
|
---|
1042 |
|
---|
1043 | case DID_CANCEL:
|
---|
1044 | WinDismissDlg(hwnd, 0);
|
---|
1045 | break;
|
---|
1046 |
|
---|
1047 | case IDM_UNDO:
|
---|
1048 | PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
1049 | break;
|
---|
1050 |
|
---|
1051 | case IDM_HELP:
|
---|
1052 | if (hwndHelp)
|
---|
1053 | WinSendMsg(hwndHelp,
|
---|
1054 | HM_DISPLAY_HELP,
|
---|
1055 | MPFROM2SHORT(HELP_FLAGS, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
1056 | break;
|
---|
1057 | }
|
---|
1058 | return 0;
|
---|
1059 | }
|
---|
1060 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | #pragma alloc_text(FMINFO,FileInfoProc,IconProc)
|
---|
1064 | #pragma alloc_text(FMINFO2,SetDrvProc,DrvInfoProc)
|
---|