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