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