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