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