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