| [2] | 1 | #define INCL_DOS | 
|---|
|  | 2 | #define INCL_WIN | 
|---|
|  | 3 | #define INCL_GPI | 
|---|
|  | 4 | #define INCL_MMIOOS2 | 
|---|
|  | 5 |  | 
|---|
|  | 6 | #include <os2.h> | 
|---|
|  | 7 | #include <os2me.h> | 
|---|
|  | 8 | #include <stdio.h> | 
|---|
|  | 9 | #include <stdlib.h> | 
|---|
|  | 10 | #include <string.h> | 
|---|
|  | 11 | #include <ctype.h> | 
|---|
|  | 12 | #include "fm3dll.h" | 
|---|
|  | 13 | #include "fm3dlg.h" | 
|---|
|  | 14 |  | 
|---|
|  | 15 | #pragma alloc_text(DEFVIEW,DefaultView,ShowMultimedia,DefaultViewKeys) | 
|---|
|  | 16 |  | 
|---|
|  | 17 |  | 
|---|
|  | 18 | BOOL ShowMultimedia (CHAR *filename) { | 
|---|
|  | 19 |  | 
|---|
|  | 20 | static BOOL       unavailable = FALSE; | 
|---|
|  | 21 | BOOL              ret = FALSE; | 
|---|
|  | 22 | CHAR              loaderror[CCHMAXPATH]; | 
|---|
|  | 23 | HMODULE           MMIOModHandle = (HMODULE)0; | 
|---|
|  | 24 | PMMIOIDENTIFYFILE MMIOIdentifyFile = (PMMIOIDENTIFYFILE)0; | 
|---|
|  | 25 | FOURCC            fccStorageSystem = (FOURCC)0; | 
|---|
|  | 26 | MMFORMATINFO      mmFormatInfo; | 
|---|
|  | 27 | APIRET            rc; | 
|---|
|  | 28 |  | 
|---|
|  | 29 | if(unavailable || | 
|---|
|  | 30 | !filename || | 
|---|
|  | 31 | !*filename) | 
|---|
|  | 32 | return ret; | 
|---|
|  | 33 |  | 
|---|
|  | 34 | /* load MMPM/2, if available. */ | 
|---|
|  | 35 | *loaderror = 0; | 
|---|
|  | 36 | rc = DosLoadModule(loaderror, | 
|---|
|  | 37 | sizeof(loaderror), | 
|---|
|  | 38 | "MMIO", | 
|---|
|  | 39 | &MMIOModHandle); | 
|---|
|  | 40 | if(rc) { | 
|---|
|  | 41 | unavailable = TRUE; | 
|---|
|  | 42 | return ret; | 
|---|
|  | 43 | } | 
|---|
|  | 44 | else { | 
|---|
|  | 45 | if(DosQueryProcAddr(MMIOModHandle, | 
|---|
|  | 46 | 0, | 
|---|
|  | 47 | "mmioIdentifyFile", | 
|---|
|  | 48 | (PFN *)&MMIOIdentifyFile)) { | 
|---|
|  | 49 | DosFreeModule(MMIOModHandle); | 
|---|
|  | 50 | unavailable = TRUE; | 
|---|
|  | 51 | return ret; | 
|---|
|  | 52 | } | 
|---|
|  | 53 | } | 
|---|
|  | 54 |  | 
|---|
|  | 55 | /* attempt to identify the file using MMPM/2 */ | 
|---|
|  | 56 | memset(&mmFormatInfo,0,sizeof(MMFORMATINFO)); | 
|---|
|  | 57 | mmFormatInfo.ulStructLen = sizeof(MMFORMATINFO); | 
|---|
|  | 58 | rc = MMIOIdentifyFile(filename, | 
|---|
|  | 59 | 0L, | 
|---|
|  | 60 | &mmFormatInfo, | 
|---|
|  | 61 | &fccStorageSystem, | 
|---|
|  | 62 | 0L, | 
|---|
|  | 63 | MMIO_FORCE_IDENTIFY_FF); | 
|---|
|  | 64 | /* free module handle */ | 
|---|
|  | 65 | DosFreeModule(MMIOModHandle); | 
|---|
|  | 66 |  | 
|---|
|  | 67 | /* check returns from MMPM/2's identification process */ | 
|---|
|  | 68 | if(rc != MMIO_ERROR && | 
|---|
|  | 69 | mmFormatInfo.fccIOProc != FOURCC_DOS) { | 
|---|
|  | 70 | if(mmFormatInfo.ulMediaType == MMIO_MEDIATYPE_IMAGE && | 
|---|
|  | 71 | (mmFormatInfo.ulFlags & MMIO_CANREADTRANSLATED) != 0) { | 
|---|
|  | 72 | /* is an image */ | 
|---|
|  | 73 | runemf2(SEPARATE | WINDOWED, | 
|---|
|  | 74 | HWND_DESKTOP, | 
|---|
|  | 75 | NULL, | 
|---|
|  | 76 | NULL, | 
|---|
|  | 77 | "%sIMAGE.EXE \"%s\"", | 
|---|
|  | 78 | (fAddUtils) ? "UTILS\\" : NullStr, | 
|---|
|  | 79 | filename); | 
|---|
|  | 80 | ret = TRUE; | 
|---|
|  | 81 | } | 
|---|
|  | 82 | else { | 
|---|
|  | 83 | if(mmFormatInfo.ulMediaType != MMIO_MEDIATYPE_IMAGE) | 
|---|
|  | 84 | /* is a multimedia file (WAV, MID, AVI, etc.) */ | 
|---|
|  | 85 | runemf2(SEPARATE | WINDOWED, | 
|---|
|  | 86 | HWND_DESKTOP, | 
|---|
|  | 87 | NULL, | 
|---|
|  | 88 | NULL, | 
|---|
|  | 89 | "%sFM2PLAY.EXE \"%s\"", | 
|---|
|  | 90 | (fAddUtils) ? "UTILS\\" : NullStr, | 
|---|
|  | 91 | filename); | 
|---|
|  | 92 | ret = TRUE; | 
|---|
|  | 93 | } | 
|---|
|  | 94 | } | 
|---|
|  | 95 |  | 
|---|
|  | 96 | return ret; | 
|---|
|  | 97 | } | 
|---|
|  | 98 |  | 
|---|
|  | 99 |  | 
|---|
|  | 100 | VOID DefaultViewKeys (HWND hwnd,HWND hwndFrame,HWND hwndParent, | 
|---|
|  | 101 | SWP *swp,CHAR *filename) { | 
|---|
|  | 102 |  | 
|---|
|  | 103 | if((shiftstate & (KC_CTRL | KC_SHIFT)) == | 
|---|
|  | 104 | (KC_CTRL | KC_SHIFT)) | 
|---|
|  | 105 | DefaultView(hwnd, | 
|---|
|  | 106 | hwndFrame, | 
|---|
|  | 107 | hwndParent, | 
|---|
|  | 108 | swp, | 
|---|
|  | 109 | 4, | 
|---|
|  | 110 | filename); | 
|---|
|  | 111 | else if(shiftstate & KC_CTRL) | 
|---|
|  | 112 | DefaultView(hwnd, | 
|---|
|  | 113 | hwndFrame, | 
|---|
|  | 114 | hwndParent, | 
|---|
|  | 115 | swp, | 
|---|
|  | 116 | 2, | 
|---|
|  | 117 | filename); | 
|---|
|  | 118 | else if(shiftstate & KC_SHIFT) | 
|---|
|  | 119 | DefaultView(hwnd, | 
|---|
|  | 120 | hwndFrame, | 
|---|
|  | 121 | hwndParent, | 
|---|
|  | 122 | swp, | 
|---|
|  | 123 | 1, | 
|---|
|  | 124 | filename); | 
|---|
|  | 125 | else | 
|---|
|  | 126 | DefaultView(hwnd, | 
|---|
|  | 127 | hwndFrame, | 
|---|
|  | 128 | hwndParent, | 
|---|
|  | 129 | swp, | 
|---|
|  | 130 | 0, | 
|---|
|  | 131 | filename); | 
|---|
|  | 132 | } | 
|---|
|  | 133 |  | 
|---|
|  | 134 |  | 
|---|
|  | 135 | VOID DefaultView (HWND hwnd,HWND hwndFrame,HWND hwndParent,SWP *swp, | 
|---|
|  | 136 | ULONG flags,CHAR *filename) { | 
|---|
|  | 137 |  | 
|---|
|  | 138 | /* | 
|---|
|  | 139 | * bitmapped flags: | 
|---|
|  | 140 | * --------------- | 
|---|
|  | 141 | * 1  = View directly | 
|---|
|  | 142 | * 2  = Open WPS default view | 
|---|
|  | 143 | * 4  = Open WPS settings view | 
|---|
|  | 144 | * 8  = Edit | 
|---|
|  | 145 | * 16 = Info | 
|---|
|  | 146 | * 32 = No view info | 
|---|
|  | 147 | */ | 
|---|
|  | 148 |  | 
|---|
|  | 149 | HWND  hwndArc = (HWND)0; | 
|---|
|  | 150 | char *p,*dummy[3]; | 
|---|
|  | 151 |  | 
|---|
|  | 152 | if(!hwndParent) | 
|---|
|  | 153 | hwndParent = HWND_DESKTOP; | 
|---|
|  | 154 |  | 
|---|
|  | 155 | if(flags & 32) { | 
|---|
|  | 156 | flags &= (~16); | 
|---|
|  | 157 | if(!IsFile(filename)) { | 
|---|
|  | 158 | DosBeep(50,100); | 
|---|
|  | 159 | return; | 
|---|
|  | 160 | } | 
|---|
|  | 161 | } | 
|---|
|  | 162 |  | 
|---|
|  | 163 | if(flags & 1)     /* directly view the file */ | 
|---|
|  | 164 | goto ViewIt; | 
|---|
|  | 165 |  | 
|---|
|  | 166 | if(flags & 2) {   /* open default WPS view of file */ | 
|---|
|  | 167 | OpenObject(filename, | 
|---|
|  | 168 | Default, | 
|---|
|  | 169 | hwnd); | 
|---|
|  | 170 | return; | 
|---|
|  | 171 | } | 
|---|
|  | 172 |  | 
|---|
|  | 173 | if(flags & 4) {   /* open WPS settings notebook for file */ | 
|---|
|  | 174 | OpenObject(filename, | 
|---|
|  | 175 | Settings, | 
|---|
|  | 176 | hwnd); | 
|---|
|  | 177 | return; | 
|---|
|  | 178 | } | 
|---|
|  | 179 |  | 
|---|
|  | 180 | if((flags & 16) || | 
|---|
|  | 181 | !IsFile(filename)) {   /* open info for directories */ | 
|---|
|  | 182 |  | 
|---|
|  | 183 | char fullname[CCHMAXPATH]; | 
|---|
|  | 184 |  | 
|---|
|  | 185 | if(!IsFullName(filename)) { | 
|---|
|  | 186 | if(!DosQueryPathInfo(filename, | 
|---|
|  | 187 | FIL_QUERYFULLNAME, | 
|---|
|  | 188 | fullname, | 
|---|
|  | 189 | sizeof(fullname))) | 
|---|
|  | 190 | filename = fullname; | 
|---|
|  | 191 | } | 
|---|
|  | 192 | if(IsFullName(filename) && | 
|---|
|  | 193 | !(driveflags[toupper(*filename) - 'A'] & DRIVE_INVALID)) { | 
|---|
|  | 194 | if(!IsRoot(filename)) { | 
|---|
|  | 195 | dummy[0] = filename; | 
|---|
|  | 196 | dummy[1] = NULL; | 
|---|
|  | 197 | WinDlgBox(HWND_DESKTOP, | 
|---|
|  | 198 | HWND_DESKTOP, | 
|---|
|  | 199 | FileInfoProc, | 
|---|
|  | 200 | FM3ModHandle, | 
|---|
|  | 201 | FLE_FRAME, | 
|---|
|  | 202 | (PVOID)dummy); | 
|---|
|  | 203 | } | 
|---|
|  | 204 | else | 
|---|
|  | 205 | WinDlgBox(HWND_DESKTOP, | 
|---|
|  | 206 | HWND_DESKTOP, | 
|---|
|  | 207 | DrvInfoProc, | 
|---|
|  | 208 | FM3ModHandle, | 
|---|
|  | 209 | INFO_FRAME, | 
|---|
|  | 210 | (PVOID)filename); | 
|---|
|  | 211 | } | 
|---|
|  | 212 | return; | 
|---|
|  | 213 | } | 
|---|
|  | 214 |  | 
|---|
|  | 215 | if(flags & 8) {   /* edit file */ | 
|---|
|  | 216 |  | 
|---|
|  | 217 | ULONG type = IDM_EDITTEXT; | 
|---|
|  | 218 |  | 
|---|
|  | 219 | dummy[0] = filename; | 
|---|
|  | 220 | dummy[1] = NULL; | 
|---|
|  | 221 | if(TestBinary(filename)) | 
|---|
|  | 222 | type = IDM_EDITBINARY; | 
|---|
|  | 223 | switch(type) { | 
|---|
|  | 224 | case IDM_EDITBINARY: | 
|---|
|  | 225 | if(*bined) { | 
|---|
|  | 226 | ExecOnList((HWND)0, | 
|---|
|  | 227 | bined, | 
|---|
|  | 228 | WINDOWED | SEPARATE, | 
|---|
|  | 229 | NULL, | 
|---|
|  | 230 | dummy, | 
|---|
|  | 231 | NULL); | 
|---|
|  | 232 | break; | 
|---|
|  | 233 | } | 
|---|
|  | 234 | /* else intentional fallthru */ | 
|---|
|  | 235 | case IDM_EDITTEXT: | 
|---|
|  | 236 | if(*editor) | 
|---|
|  | 237 | ExecOnList((HWND)0, | 
|---|
|  | 238 | editor, | 
|---|
|  | 239 | WINDOWED | SEPARATE, | 
|---|
|  | 240 | NULL, | 
|---|
|  | 241 | dummy, | 
|---|
|  | 242 | NULL); | 
|---|
|  | 243 | else { | 
|---|
|  | 244 | type = (type == IDM_EDITTEXT) ? 8 : | 
|---|
|  | 245 | (type == IDM_EDITBINARY) ? 16 : | 
|---|
|  | 246 | 0; | 
|---|
|  | 247 | type |= 4; | 
|---|
|  | 248 | StartMLEEditor(hwndParent, | 
|---|
|  | 249 | type, | 
|---|
|  | 250 | filename, | 
|---|
|  | 251 | hwndFrame); | 
|---|
|  | 252 | } | 
|---|
|  | 253 | break; | 
|---|
|  | 254 | } | 
|---|
|  | 255 | return; | 
|---|
|  | 256 | } | 
|---|
|  | 257 |  | 
|---|
|  | 258 | if(ExecAssociation(hwnd, | 
|---|
|  | 259 | filename) == -1) { | 
|---|
|  | 260 | hwndArc = StartArcCnr((fExternalArcboxes || !swp || | 
|---|
|  | 261 | strcmp(realappname,FM3Str)) ? | 
|---|
|  | 262 | HWND_DESKTOP : | 
|---|
|  | 263 | hwndParent, | 
|---|
|  | 264 | hwndFrame, | 
|---|
|  | 265 | filename, | 
|---|
|  | 266 | 4, | 
|---|
|  | 267 | NULL); | 
|---|
|  | 268 | if(!hwndArc) { | 
|---|
|  | 269 | if(!fCheckMM || | 
|---|
|  | 270 | !ShowMultimedia(filename)) { | 
|---|
|  | 271 | if(!IsExecutable(filename) || | 
|---|
|  | 272 | !ExecFile(hwnd,filename)) { | 
|---|
|  | 273 | p = strrchr(filename,'.'); | 
|---|
|  | 274 | if(!p) | 
|---|
|  | 275 | p = "."; | 
|---|
|  | 276 | if(stricmp(p,".INI") || | 
|---|
|  | 277 | !StartIniEditor(hwndParent, | 
|---|
|  | 278 | filename, | 
|---|
|  | 279 | 4)) { | 
|---|
|  | 280 | if(stricmp(p,".HLP") || | 
|---|
|  | 281 | !ViewHelp(filename)) { | 
|---|
|  | 282 | ViewIt: | 
|---|
|  | 283 | if(*viewer) { | 
|---|
|  | 284 | dummy[0] = filename; | 
|---|
|  | 285 | dummy[1] = NULL; | 
|---|
|  | 286 | ExecOnList(hwnd, | 
|---|
|  | 287 | viewer, | 
|---|
|  | 288 | WINDOWED | SEPARATE | | 
|---|
|  | 289 | ((fViewChild) ? CHILD : 0), | 
|---|
|  | 290 | NULL, | 
|---|
|  | 291 | dummy, | 
|---|
|  | 292 | NULL); | 
|---|
|  | 293 | } | 
|---|
|  | 294 | else | 
|---|
|  | 295 | StartMLEEditor(hwndParent, | 
|---|
|  | 296 | 5, | 
|---|
|  | 297 | filename, | 
|---|
|  | 298 | hwndFrame); | 
|---|
|  | 299 | } | 
|---|
|  | 300 | } | 
|---|
|  | 301 | } | 
|---|
|  | 302 | } | 
|---|
|  | 303 | } | 
|---|
|  | 304 | else { | 
|---|
|  | 305 | if((swp && | 
|---|
|  | 306 | !fExternalArcboxes && | 
|---|
|  | 307 | !strcmp(realappname,FM3Str)) && | 
|---|
|  | 308 | !ParentIsDesktop(hwnd,hwndParent)) | 
|---|
|  | 309 | WinSetWindowPos(hwndArc, | 
|---|
|  | 310 | HWND_TOP, | 
|---|
|  | 311 | swp->x, | 
|---|
|  | 312 | swp->y, | 
|---|
|  | 313 | swp->cx, | 
|---|
|  | 314 | swp->cy, | 
|---|
|  | 315 | SWP_MOVE   | SWP_SIZE     | SWP_SHOW | | 
|---|
|  | 316 | SWP_ZORDER | SWP_ACTIVATE); | 
|---|
|  | 317 | } | 
|---|
|  | 318 | } | 
|---|
|  | 319 | } | 
|---|
|  | 320 |  | 
|---|