| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: extract.c 1395 2009-02-08 01:48:16Z gyoung $ | 
|---|
| 5 |  | 
|---|
| 6 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 7 | Copyright (c) 2004, 2008 Steven H. Levine | 
|---|
| 8 |  | 
|---|
| 9 | 01 Aug 04 SHL Rework lstrip/rstrip usage | 
|---|
| 10 | 05 Jun 05 SHL Use QWL_USER | 
|---|
| 11 | 17 Jul 06 SHL Use Runtime_Error | 
|---|
| 12 | 20 Dec 06 GKY Added checkbox to make default extract with directories | 
|---|
| 13 | 22 Mar 07 GKY Use QWL_USER | 
|---|
| 14 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods | 
|---|
| 15 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| 16 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory | 
|---|
| 17 | 29 Nov 08 GKY Add the option of creating a subdirectory from the arcname | 
|---|
| 18 | for the extract path. | 
|---|
| 19 | 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook. | 
|---|
| 20 |  | 
|---|
| 21 | ***********************************************************************/ | 
|---|
| 22 |  | 
|---|
| 23 | #include <string.h> | 
|---|
| 24 | #include <ctype.h> | 
|---|
| 25 |  | 
|---|
| 26 | #define INCL_WIN | 
|---|
| 27 | #define INCL_DOS | 
|---|
| 28 | #define INCL_LONGLONG                   // dircnrs.h | 
|---|
| 29 |  | 
|---|
| 30 | #include "fm3dll.h" | 
|---|
| 31 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| 32 | #include "init.h"                       // Data declaration(s) | 
|---|
| 33 | #include "arccnrs.h"                    // Data declaration(s) | 
|---|
| 34 | #include "notebook.h"                   // Data declaration(s) | 
|---|
| 35 | #include "mainwnd.h"                    // Data declaration(s) | 
|---|
| 36 | #include "fm3dlg.h" | 
|---|
| 37 | #include "fm3str.h" | 
|---|
| 38 | #include "errutil.h"                    // Dos_Error... | 
|---|
| 39 | #include "strutil.h"                    // GetPString | 
|---|
| 40 | #include "cmdline.h"                    // CmdLineDlgProc | 
|---|
| 41 | #include "extract.h" | 
|---|
| 42 | #include "walkem.h"                     // WalkExtractDlgProc | 
|---|
| 43 | #include "droplist.h"                   // AcceptOneDrop, DropHelp, GetOneDrop | 
|---|
| 44 | #include "misc.h"                       // DrawTargetEmphasis | 
|---|
| 45 | #include "chklist.h"                    // PosOverOkay | 
|---|
| 46 | #include "mkdir.h"                      // SetDir | 
|---|
| 47 | #include "valid.h"                      // MakeValidDir | 
|---|
| 48 | #include "systemf.h"                    // runemf2 | 
|---|
| 49 | #include "dirs.h"                       // save_dir2 | 
|---|
| 50 | #include "strips.h"                     // bstrip | 
|---|
| 51 |  | 
|---|
| 52 | #pragma data_seg(DATA1) | 
|---|
| 53 |  | 
|---|
| 54 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 55 |  | 
|---|
| 56 | MRESULT EXPENTRY ExtractTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 57 | { | 
|---|
| 58 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 59 | static BOOL emphasized = FALSE; | 
|---|
| 60 |  | 
|---|
| 61 | switch (msg) { | 
|---|
| 62 | case DM_DRAGOVER: | 
|---|
| 63 | if (!emphasized) { | 
|---|
| 64 | emphasized = TRUE; | 
|---|
| 65 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 66 | } | 
|---|
| 67 | if (AcceptOneDrop(hwnd, mp1, mp2)) | 
|---|
| 68 | return MRFROM2SHORT(DOR_DROP, DO_MOVE); | 
|---|
| 69 | return MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| 70 |  | 
|---|
| 71 | case DM_DRAGLEAVE: | 
|---|
| 72 | if (emphasized) { | 
|---|
| 73 | emphasized = FALSE; | 
|---|
| 74 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 75 | } | 
|---|
| 76 | break; | 
|---|
| 77 |  | 
|---|
| 78 | case DM_DROPHELP: | 
|---|
| 79 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_EXTDROPHELPTEXT)); | 
|---|
| 80 | return 0; | 
|---|
| 81 |  | 
|---|
| 82 | case DM_DROP: | 
|---|
| 83 | { | 
|---|
| 84 | char szFrom[CCHMAXPATH + 2]; | 
|---|
| 85 |  | 
|---|
| 86 | if (emphasized) { | 
|---|
| 87 | emphasized = FALSE; | 
|---|
| 88 | DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| 89 | } | 
|---|
| 90 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) | 
|---|
| 91 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND, | 
|---|
| 92 | MPFROM2SHORT(IDM_SWITCH, 0), MPFROMP(szFrom)); | 
|---|
| 93 | } | 
|---|
| 94 | return 0; | 
|---|
| 95 | } | 
|---|
| 96 | return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) : | 
|---|
| 97 | WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| 98 | } | 
|---|
| 99 |  | 
|---|
| 100 | MRESULT EXPENTRY ExtractDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 101 | { | 
|---|
| 102 | EXTRDATA *arcdata = NULL; | 
|---|
| 103 | ULONG size; | 
|---|
| 104 | BOOL fFileNameExtPath; | 
|---|
| 105 |  | 
|---|
| 106 | switch (msg) { | 
|---|
| 107 | case WM_INITDLG: | 
|---|
| 108 | WinSetWindowPtr(hwnd, QWL_USER, mp2); | 
|---|
| 109 | arcdata = (EXTRDATA *) mp2; | 
|---|
| 110 | { | 
|---|
| 111 | BOOL fDirectory = FALSE; | 
|---|
| 112 | BOOL fRemember = FALSE; | 
|---|
| 113 | PFNWP oldproc; | 
|---|
| 114 |  | 
|---|
| 115 | fFileNameExtPath = FALSE; | 
|---|
| 116 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, EXT_DIRECTORY), | 
|---|
| 117 | (PFNWP) ExtractTextProc); | 
|---|
| 118 | if (oldproc) | 
|---|
| 119 | WinSetWindowPtr(WinWindowFromID(hwnd, EXT_DIRECTORY), | 
|---|
| 120 | QWL_USER, (PVOID) oldproc); | 
|---|
| 121 | size = sizeof(BOOL); | 
|---|
| 122 | PrfQueryProfileData(fmprof, FM3Str, "RememberExt", | 
|---|
| 123 | (PVOID) & fRemember, &size); | 
|---|
| 124 | size = sizeof(BOOL); | 
|---|
| 125 | PrfQueryProfileData(fmprof, FM3Str, "DirectoryExt", | 
|---|
| 126 | (PVOID) & fDirectory, &size); | 
|---|
| 127 | size = sizeof(BOOL); | 
|---|
| 128 | PrfQueryProfileData(fmprof, FM3Str, "FileNamePathExt", | 
|---|
| 129 | (PVOID) & fFileNameExtPath, &size); | 
|---|
| 130 | WinCheckButton(hwnd, EXT_REMEMBER, fRemember); | 
|---|
| 131 | WinCheckButton(hwnd, EXT_AWDIRS, fDirectory); | 
|---|
| 132 | WinCheckButton(hwnd, EXT_FILENAMEEXT, fFileNameExtPath); | 
|---|
| 133 | WinSendDlgItemMsg(hwnd, EXT_DIRECTORY, EM_SETTEXTLIMIT, | 
|---|
| 134 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID); | 
|---|
| 135 | WinSendDlgItemMsg(hwnd, EXT_COMMAND, EM_SETTEXTLIMIT, | 
|---|
| 136 | MPFROM2SHORT(256, 0), MPVOID); | 
|---|
| 137 | WinSendDlgItemMsg(hwnd, EXT_MASK, EM_SETTEXTLIMIT, | 
|---|
| 138 | MPFROM2SHORT(256, 0), MPVOID); | 
|---|
| 139 | WinSendDlgItemMsg(hwnd, EXT_FILENAME, EM_SETTEXTLIMIT, | 
|---|
| 140 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID); | 
|---|
| 141 | if (arcdata->arcname && *arcdata->arcname) | 
|---|
| 142 | WinSetDlgItemText(hwnd, EXT_FILENAME, arcdata->arcname); | 
|---|
| 143 | else | 
|---|
| 144 | WinSetDlgItemText(hwnd, EXT_FILENAME, GetPString(IDS_EXTVARIOUSTEXT)); | 
|---|
| 145 |  | 
|---|
| 146 | if (fFileNameExtPath && arcdata->arcname) { | 
|---|
| 147 |  | 
|---|
| 148 | CHAR FileName[CCHMAXPATH]; | 
|---|
| 149 | PSZ p; | 
|---|
| 150 |  | 
|---|
| 151 | strcpy(FileName, arcdata->arcname); | 
|---|
| 152 | p = strrchr(FileName, '.'); | 
|---|
| 153 | if (p) | 
|---|
| 154 | *p = 0; | 
|---|
| 155 | else { | 
|---|
| 156 | p = FileName + strlen(arcdata->arcname); | 
|---|
| 157 | p--; | 
|---|
| 158 | *p = 0; | 
|---|
| 159 | } | 
|---|
| 160 | strcpy(arcdata->extractdir, FileName); | 
|---|
| 161 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir); | 
|---|
| 162 | } | 
|---|
| 163 | if (fDirectory) { | 
|---|
| 164 | WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_SETCHECK, | 
|---|
| 165 | MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 166 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs); | 
|---|
| 167 | } | 
|---|
| 168 | else { | 
|---|
| 169 | WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_SETCHECK, | 
|---|
| 170 | MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 171 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract); | 
|---|
| 172 |  | 
|---|
| 173 | } | 
|---|
| 174 | if (fRemember) { | 
|---|
| 175 |  | 
|---|
| 176 | CHAR textdir[CCHMAXPATH]; | 
|---|
| 177 |  | 
|---|
| 178 | PrfQueryProfileString(fmprof, FM3Str, "Ext_ExtractDir", NULL, textdir, sizeof(textdir)); | 
|---|
| 179 | if (*textdir && !IsFile(textdir)) | 
|---|
| 180 | strcpy(arcdata->extractdir, textdir); | 
|---|
| 181 | PrfQueryProfileString(fmprof, FM3Str, "Ext_Mask", NULL, textdir, sizeof(textdir)); | 
|---|
| 182 | WinSetDlgItemText(hwnd, EXT_MASK, textdir); | 
|---|
| 183 | } | 
|---|
| 184 | if (*extractpath && (!fRemember || !*arcdata->extractdir)) { | 
|---|
| 185 | if (arcdata->arcname && *arcdata->arcname && | 
|---|
| 186 | !strcmp(extractpath, "*")) { | 
|---|
| 187 |  | 
|---|
| 188 | CHAR *p; | 
|---|
| 189 |  | 
|---|
| 190 | strcpy(arcdata->extractdir, arcdata->arcname); | 
|---|
| 191 | p = strrchr(arcdata->extractdir, '\\'); | 
|---|
| 192 | if (p) { | 
|---|
| 193 | if (p < arcdata->extractdir + 3) | 
|---|
| 194 | p++; | 
|---|
| 195 | *p = 0; | 
|---|
| 196 | } | 
|---|
| 197 | } | 
|---|
| 198 | else | 
|---|
| 199 | strcpy(arcdata->extractdir, extractpath); | 
|---|
| 200 | } | 
|---|
| 201 | if (!*arcdata->extractdir) { | 
|---|
| 202 | if (*lastextractpath) | 
|---|
| 203 | strcpy(arcdata->extractdir, lastextractpath); | 
|---|
| 204 | else if (arcdata->arcname && *arcdata->arcname) { | 
|---|
| 205 |  | 
|---|
| 206 | CHAR *p; | 
|---|
| 207 |  | 
|---|
| 208 | strcpy(arcdata->extractdir, arcdata->arcname); | 
|---|
| 209 | p = strrchr(arcdata->extractdir, '\\'); | 
|---|
| 210 | if (p) { | 
|---|
| 211 | if (p < arcdata->extractdir + 3) | 
|---|
| 212 | p++; | 
|---|
| 213 | *p = 0; | 
|---|
| 214 | } | 
|---|
| 215 | } | 
|---|
| 216 | if (!*arcdata->extractdir) | 
|---|
| 217 | strcpy(arcdata->extractdir, pFM2SaveDirectory); | 
|---|
| 218 | } | 
|---|
| 219 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir); | 
|---|
| 220 | if (!arcdata->info->exwdirs) | 
|---|
| 221 | WinEnableWindow(WinWindowFromID(hwnd, EXT_WDIRS), FALSE); | 
|---|
| 222 | else if (fRemember) { | 
|---|
| 223 | fRemember = FALSE; | 
|---|
| 224 | size = sizeof(BOOL); | 
|---|
| 225 | PrfQueryProfileData(fmprof, FM3Str, "Ext_WDirs", | 
|---|
| 226 | (PVOID) &fRemember, &size); | 
|---|
| 227 | if (fRemember) | 
|---|
| 228 | PostMsg(WinWindowFromID(hwnd, EXT_WDIRS), BM_CLICK, MPVOID, MPVOID); | 
|---|
| 229 | } | 
|---|
| 230 | } | 
|---|
| 231 | *arcdata->command = 0; | 
|---|
| 232 | PosOverOkay(hwnd); | 
|---|
| 233 | break; | 
|---|
| 234 |  | 
|---|
| 235 | case WM_ADJUSTWINDOWPOS: | 
|---|
| 236 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID); | 
|---|
| 237 | break; | 
|---|
| 238 |  | 
|---|
| 239 | case UM_SETDIR: | 
|---|
| 240 | PaintRecessedWindow(WinWindowFromID(hwnd, EXT_HELP), (HPS) 0, FALSE, | 
|---|
| 241 | TRUE); | 
|---|
| 242 | return 0; | 
|---|
| 243 |  | 
|---|
| 244 | case WM_CONTROL: | 
|---|
| 245 | arcdata = (EXTRDATA *) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 246 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 247 | case EXT_REMEMBER: | 
|---|
| 248 | { | 
|---|
| 249 | BOOL fRemember = WinQueryButtonCheckstate(hwnd, EXT_REMEMBER); | 
|---|
| 250 | size = sizeof(BOOL); | 
|---|
| 251 | PrfWriteProfileData(fmprof, FM3Str, "RememberExt", | 
|---|
| 252 | (PVOID) &fRemember, size); | 
|---|
| 253 | WinSendDlgItemMsg(hwnd, EXT_FILENAMEEXT, BM_SETCHECK, | 
|---|
| 254 | MPFROM2SHORT(FALSE, 0), MPVOID); | 
|---|
| 255 | } | 
|---|
| 256 | break; | 
|---|
| 257 |  | 
|---|
| 258 | case EXT_AWDIRS: | 
|---|
| 259 | { | 
|---|
| 260 | BOOL fDirectory = WinQueryButtonCheckstate(hwnd, EXT_AWDIRS); | 
|---|
| 261 | size = sizeof(BOOL); | 
|---|
| 262 | PrfWriteProfileData(fmprof, FM3Str, "DirectoryExt", | 
|---|
| 263 | (PVOID) &fDirectory, size); | 
|---|
| 264 |  | 
|---|
| 265 | if (fDirectory) { | 
|---|
| 266 | WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_SETCHECK, | 
|---|
| 267 | MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 268 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs); | 
|---|
| 269 | } | 
|---|
| 270 | else { | 
|---|
| 271 | WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_SETCHECK, | 
|---|
| 272 | MPFROM2SHORT(TRUE, 0), MPVOID); | 
|---|
| 273 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract); | 
|---|
| 274 | } | 
|---|
| 275 | } | 
|---|
| 276 | break; | 
|---|
| 277 |  | 
|---|
| 278 | case EXT_FILENAMEEXT: | 
|---|
| 279 | { | 
|---|
| 280 | BOOL fFileNameExtPath = WinQueryButtonCheckstate(hwnd, EXT_FILENAMEEXT); | 
|---|
| 281 | BOOL fRemember = WinQueryButtonCheckstate(hwnd, EXT_REMEMBER); | 
|---|
| 282 | size = sizeof(BOOL); | 
|---|
| 283 | PrfWriteProfileData(fmprof, FM3Str, "FileNamePathExt", | 
|---|
| 284 | fRemember ? FALSE : (PVOID) &fFileNameExtPath, size); | 
|---|
| 285 | if (fRemember) { | 
|---|
| 286 | WinSendDlgItemMsg(hwnd, EXT_FILENAMEEXT, BM_SETCHECK, | 
|---|
| 287 | MPFROM2SHORT(FALSE, 0), MPVOID); | 
|---|
| 288 | break; | 
|---|
| 289 | } | 
|---|
| 290 | if (fFileNameExtPath && arcdata->arcname) { | 
|---|
| 291 | CHAR FileName[CCHMAXPATH]; | 
|---|
| 292 | PSZ p; | 
|---|
| 293 |  | 
|---|
| 294 | strcpy(FileName, arcdata->arcname); | 
|---|
| 295 | p = strrchr(FileName, '.'); | 
|---|
| 296 | if (p) | 
|---|
| 297 | *p = 0; | 
|---|
| 298 | else { | 
|---|
| 299 | p = FileName + strlen(arcdata->arcname); | 
|---|
| 300 | p--; | 
|---|
| 301 | *p = 0; | 
|---|
| 302 | } | 
|---|
| 303 | strcpy(arcdata->extractdir, FileName); | 
|---|
| 304 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir); | 
|---|
| 305 | } | 
|---|
| 306 | else { | 
|---|
| 307 | *arcdata->extractdir = 0; | 
|---|
| 308 | if (*extractpath) { | 
|---|
| 309 | if (arcdata->arcname && *arcdata->arcname && | 
|---|
| 310 | !strcmp(extractpath, "*")) { | 
|---|
| 311 |  | 
|---|
| 312 | CHAR *p; | 
|---|
| 313 |  | 
|---|
| 314 | strcpy(arcdata->extractdir, arcdata->arcname); | 
|---|
| 315 | p = strrchr(arcdata->extractdir, '\\'); | 
|---|
| 316 | if (p) { | 
|---|
| 317 | if (p < arcdata->extractdir + 3) | 
|---|
| 318 | p++; | 
|---|
| 319 | *p = 0; | 
|---|
| 320 | } | 
|---|
| 321 | } | 
|---|
| 322 | else | 
|---|
| 323 | strcpy(arcdata->extractdir, extractpath); | 
|---|
| 324 | } | 
|---|
| 325 | if (!*arcdata->extractdir) { | 
|---|
| 326 | if (arcdata->arcname && *arcdata->arcname) { | 
|---|
| 327 |  | 
|---|
| 328 | CHAR *p; | 
|---|
| 329 |  | 
|---|
| 330 | strcpy(arcdata->extractdir, arcdata->arcname); | 
|---|
| 331 | p = strrchr(arcdata->extractdir, '\\'); | 
|---|
| 332 | if (p) { | 
|---|
| 333 | if (p < arcdata->extractdir + 3) | 
|---|
| 334 | p++; | 
|---|
| 335 | *p = 0; | 
|---|
| 336 | } | 
|---|
| 337 | } | 
|---|
| 338 | if (!*arcdata->extractdir) | 
|---|
| 339 | strcpy(arcdata->extractdir, pFM2SaveDirectory); | 
|---|
| 340 | } | 
|---|
| 341 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir); | 
|---|
| 342 | } | 
|---|
| 343 | } | 
|---|
| 344 | break; | 
|---|
| 345 |  | 
|---|
| 346 | case EXT_FILENAME: | 
|---|
| 347 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) | 
|---|
| 348 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); | 
|---|
| 349 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS) | 
|---|
| 350 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCARCNAMEHELPTEXT)); | 
|---|
| 351 | break; | 
|---|
| 352 |  | 
|---|
| 353 | case EXT_DIRECTORY: | 
|---|
| 354 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) | 
|---|
| 355 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); | 
|---|
| 356 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS) | 
|---|
| 357 | WinSetDlgItemText(hwnd, EXT_HELP, | 
|---|
| 358 | GetPString(IDS_EXTEXTRACTDIRHELPTEXT)); | 
|---|
| 359 | break; | 
|---|
| 360 |  | 
|---|
| 361 | case EXT_COMMAND: | 
|---|
| 362 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) | 
|---|
| 363 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); | 
|---|
| 364 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS) | 
|---|
| 365 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCCMDHELPTEXT)); | 
|---|
| 366 | break; | 
|---|
| 367 |  | 
|---|
| 368 | case EXT_MASK: | 
|---|
| 369 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS) | 
|---|
| 370 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCDEFAULTHELPTEXT)); | 
|---|
| 371 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS) | 
|---|
| 372 | WinSetDlgItemText(hwnd, EXT_HELP, GetPString(IDS_ARCMASKHELPTEXT)); | 
|---|
| 373 | break; | 
|---|
| 374 |  | 
|---|
| 375 | case EXT_NORMAL: | 
|---|
| 376 | if ((BOOL) WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_QUERYCHECK, | 
|---|
| 377 | MPVOID, MPVOID)) | 
|---|
| 378 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract); | 
|---|
| 379 | break; | 
|---|
| 380 |  | 
|---|
| 381 | case EXT_WDIRS: | 
|---|
| 382 | if (arcdata->info->exwdirs) { | 
|---|
| 383 | if ((BOOL) WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_QUERYCHECK, | 
|---|
| 384 | MPVOID, MPVOID)) | 
|---|
| 385 | WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs); | 
|---|
| 386 | } | 
|---|
| 387 | break; | 
|---|
| 388 | } | 
|---|
| 389 | return 0; | 
|---|
| 390 |  | 
|---|
| 391 | case WM_COMMAND: | 
|---|
| 392 | arcdata = (EXTRDATA *) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| 393 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 394 | case IDM_SWITCH: | 
|---|
| 395 | if (mp2) { | 
|---|
| 396 |  | 
|---|
| 397 | CHAR tdir[CCHMAXPATH]; | 
|---|
| 398 |  | 
|---|
| 399 | strcpy(tdir, (CHAR *) mp2); | 
|---|
| 400 | MakeValidDir(tdir); | 
|---|
| 401 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, tdir); | 
|---|
| 402 | } | 
|---|
| 403 | break; | 
|---|
| 404 |  | 
|---|
| 405 | case DID_CANCEL: | 
|---|
| 406 | arcdata->ret = 0; | 
|---|
| 407 | WinDismissDlg(hwnd, 0); | 
|---|
| 408 | break; | 
|---|
| 409 | case DID_OK: | 
|---|
| 410 | { | 
|---|
| 411 | CHAR s[CCHMAXPATH + 1]; | 
|---|
| 412 | BOOL fRemember; | 
|---|
| 413 |  | 
|---|
| 414 | fRemember = WinQueryButtonCheckstate(hwnd, EXT_REMEMBER); | 
|---|
| 415 | *s = 0; | 
|---|
| 416 | WinQueryDlgItemText(hwnd, EXT_DIRECTORY, CCHMAXPATH, s); | 
|---|
| 417 | bstrip(s); | 
|---|
| 418 | if (*s) { | 
|---|
| 419 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), | 
|---|
| 420 | QW_OWNER), hwnd, s, fFileNameExtPath ? 1:0)) { | 
|---|
| 421 | strcpy(arcdata->extractdir, s); | 
|---|
| 422 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, s); | 
|---|
| 423 | if ((!isalpha(*s) || s[1] != ':') && *s != '.') | 
|---|
| 424 | saymsg(MB_ENTER, hwnd, | 
|---|
| 425 | GetPString(IDS_WARNINGTEXT), | 
|---|
| 426 | GetPString(IDS_SPECIFYDRIVETEXT)); | 
|---|
| 427 | } | 
|---|
| 428 | else | 
|---|
| 429 | break; | 
|---|
| 430 | strcpy(lastextractpath, s); | 
|---|
| 431 | if (fRemember) { | 
|---|
| 432 | PrfWriteProfileString(fmprof, FM3Str, "Ext_ExtractDir", s); | 
|---|
| 433 | fRemember = WinQueryButtonCheckstate(hwnd, EXT_WDIRS); | 
|---|
| 434 | size = sizeof(BOOL); | 
|---|
| 435 | PrfWriteProfileData(fmprof, FM3Str, "Ext_WDirs", | 
|---|
| 436 | (PVOID) &fRemember, size); | 
|---|
| 437 | fRemember = TRUE; | 
|---|
| 438 | } | 
|---|
| 439 | *s = 0; | 
|---|
| 440 | WinQueryDlgItemText(hwnd, EXT_COMMAND, 256, s); | 
|---|
| 441 | if (*s) { | 
|---|
| 442 | strcpy(arcdata->command, s); | 
|---|
| 443 | *s = 0; | 
|---|
| 444 | WinQueryDlgItemText(hwnd, EXT_MASK, 256, s); | 
|---|
| 445 | *arcdata->masks = 0; | 
|---|
| 446 | strcpy(arcdata->masks, s); | 
|---|
| 447 | if (fRemember) | 
|---|
| 448 | PrfWriteProfileString(fmprof, FM3Str, "Ext_Mask", s); | 
|---|
| 449 | arcdata->ret = 1; | 
|---|
| 450 | WinDismissDlg(hwnd, 1); | 
|---|
| 451 | break; | 
|---|
| 452 | } | 
|---|
| 453 | } | 
|---|
| 454 | } | 
|---|
| 455 | if (!fErrorBeepOff) | 
|---|
| 456 | DosBeep(50, 100);                       // Complain a refuse to quit | 
|---|
| 457 | break; | 
|---|
| 458 |  | 
|---|
| 459 | case IDM_HELP: | 
|---|
| 460 | if (hwndHelp) | 
|---|
| 461 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 462 | MPFROM2SHORT(HELP_EXTRACT, 0), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 463 | break; | 
|---|
| 464 |  | 
|---|
| 465 | case EXT_WALK: | 
|---|
| 466 | { | 
|---|
| 467 | CHAR temp[CCHMAXPATH + 1]; | 
|---|
| 468 |  | 
|---|
| 469 | strcpy(temp, arcdata->extractdir); | 
|---|
| 470 | if (WinDlgBox(HWND_DESKTOP, WinQueryWindow(WinQueryWindow(hwnd, | 
|---|
| 471 | QW_PARENT), | 
|---|
| 472 | QW_OWNER), | 
|---|
| 473 | WalkExtractDlgProc, FM3ModHandle, WALK_FRAME, | 
|---|
| 474 | (PVOID) temp)) { | 
|---|
| 475 | if (*temp && stricmp(temp, arcdata->extractdir)) { | 
|---|
| 476 | strcpy(arcdata->extractdir, temp); | 
|---|
| 477 | } | 
|---|
| 478 | } | 
|---|
| 479 | WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir); | 
|---|
| 480 | } | 
|---|
| 481 | break; | 
|---|
| 482 |  | 
|---|
| 483 | case EXT_SEE: | 
|---|
| 484 | { | 
|---|
| 485 | CHAR s[1001], *p; | 
|---|
| 486 | EXECARGS ex; | 
|---|
| 487 |  | 
|---|
| 488 | WinQueryDlgItemText(hwnd, EXT_COMMAND, 256, s); | 
|---|
| 489 | lstrip(s); | 
|---|
| 490 | if (!*s) | 
|---|
| 491 | Runtime_Error(pszSrcFile, __LINE__, "no command"); | 
|---|
| 492 | else { | 
|---|
| 493 | p = strchr(s, ' '); | 
|---|
| 494 | if (p) | 
|---|
| 495 | *p = 0;                     // Drop options | 
|---|
| 496 | memset(&ex, 0, sizeof(EXECARGS)); | 
|---|
| 497 | ex.commandline = s; | 
|---|
| 498 | ex.flags = WINDOWED | SEPARATEKEEP | MAXIMIZED; | 
|---|
| 499 | *ex.path = 0; | 
|---|
| 500 | *ex.environment = 0; | 
|---|
| 501 | if (WinDlgBox(HWND_DESKTOP, | 
|---|
| 502 | hwnd, | 
|---|
| 503 | CmdLineDlgProc, | 
|---|
| 504 | FM3ModHandle, EXEC_FRAME, MPFROMP(&ex)) && *s) { | 
|---|
| 505 | runemf2(ex.flags, | 
|---|
| 506 | hwnd, pszSrcFile, __LINE__, | 
|---|
| 507 | NULL, (*ex.environment) ? ex.environment : NULL, "%s", s); | 
|---|
| 508 | } | 
|---|
| 509 | } | 
|---|
| 510 | } | 
|---|
| 511 | break; | 
|---|
| 512 | } | 
|---|
| 513 | return 0; | 
|---|
| 514 |  | 
|---|
| 515 | case WM_CLOSE: | 
|---|
| 516 | break; | 
|---|
| 517 | } | 
|---|
| 518 | return WinDefDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| 519 | } | 
|---|
| 520 |  | 
|---|
| 521 | #pragma alloc_text(FMEXTRACT,ExtractTextProc,ExtractDlgProc) | 
|---|