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