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