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