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