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