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