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