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