| [123] | 1 |  | 
|---|
|  | 2 | /*********************************************************************** | 
|---|
|  | 3 |  | 
|---|
|  | 4 | $Id: undel.c 1335 2008-12-12 23:49:02Z stevenhl $ | 
|---|
|  | 5 |  | 
|---|
|  | 6 | Copyright (c) 1993-98 M. Kimes | 
|---|
| [1335] | 7 | Copyright (c) 2004, 2008 Steven H. Levine | 
|---|
| [123] | 8 |  | 
|---|
| [145] | 9 | 01 Aug 04 SHL Rework lstrip/rstrip usage | 
|---|
|  | 10 | 24 May 05 SHL Rework Win_Error usage | 
|---|
| [328] | 11 | 17 Jul 06 SHL Use Runtime_Error | 
|---|
| [406] | 12 | 29 Jul 06 SHL Use xfgets_bstripcr | 
|---|
| [528] | 13 | 03 Nov 06 SHL Count thread usage | 
|---|
| [775] | 14 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148) | 
|---|
| [793] | 15 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| [985] | 16 | 29 Feb 08 GKY Use xfree where appropriate | 
|---|
| [1075] | 17 | 16 JUL 08 GKY Use TMP directory for temp files | 
|---|
| [1335] | 18 | 10 Dec 08 SHL Integrate exception handler support | 
|---|
| [123] | 19 |  | 
|---|
|  | 20 | ***********************************************************************/ | 
|---|
|  | 21 |  | 
|---|
| [2] | 22 | #include <stdlib.h> | 
|---|
|  | 23 | #include <string.h> | 
|---|
|  | 24 | #include <ctype.h> | 
|---|
| [1335] | 25 | // #include <process.h>                 // _beginthread | 
|---|
| [328] | 26 |  | 
|---|
| [907] | 27 | #define INCL_DOS | 
|---|
|  | 28 | #define INCL_WIN | 
|---|
|  | 29 | #define INCL_LONGLONG | 
|---|
|  | 30 |  | 
|---|
| [1185] | 31 | #include "fm3dll.h" | 
|---|
| [1227] | 32 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
|  | 33 | #include "undel.h" | 
|---|
| [1214] | 34 | #include "init.h"                       // Data declaration(s) | 
|---|
|  | 35 | #include "mainwnd.h"                    // Data declaration(s) | 
|---|
| [2] | 36 | #include "fm3dlg.h" | 
|---|
|  | 37 | #include "fm3str.h" | 
|---|
| [907] | 38 | #include "errutil.h"                    // Dos_Error... | 
|---|
|  | 39 | #include "strutil.h"                    // GetPString | 
|---|
| [1335] | 40 | #include "pathutil.h"                   // BldFullPathName | 
|---|
| [1161] | 41 | #include "walkem.h"                     // FillPathListBox | 
|---|
| [1185] | 42 | #include "common.h"                     // DecrThreadUsage, IncrThreadUsage | 
|---|
|  | 43 | #include "valid.h"                      // MakeFullName | 
|---|
|  | 44 | #include "copyf.h"                      // unlinkf | 
|---|
|  | 45 | #include "wrappers.h"                   // xfgets | 
|---|
|  | 46 | #include "strips.h"                     // bstrip | 
|---|
|  | 47 | #include "misc.h"                       // GetCmdSpec | 
|---|
|  | 48 | #include "systemf.h"                    // runemf2 | 
|---|
| [1038] | 49 | #include "fortify.h" | 
|---|
| [1335] | 50 | #include "excputil.h"                   // xbeginthread | 
|---|
| [2] | 51 |  | 
|---|
|  | 52 | #pragma data_seg(DATA2) | 
|---|
| [328] | 53 |  | 
|---|
|  | 54 | static PSZ pszSrcFile = __FILE__; | 
|---|
|  | 55 |  | 
|---|
| [551] | 56 | struct tempstruct | 
|---|
|  | 57 | { | 
|---|
| [2] | 58 | HWND hwnd; | 
|---|
|  | 59 | CHAR path[CCHMAXPATH]; | 
|---|
|  | 60 | BOOL inclsubdirs; | 
|---|
|  | 61 | }; | 
|---|
|  | 62 |  | 
|---|
| [551] | 63 | static VOID FillUndelListThread(VOID * arg) | 
|---|
| [328] | 64 | { | 
|---|
| [551] | 65 | HWND hwnd; | 
|---|
| [1073] | 66 | CHAR s[CCHMAXPATH * 2], szTempFile[CCHMAXPATH]; | 
|---|
| [551] | 67 | CHAR *path; | 
|---|
|  | 68 | HAB thab; | 
|---|
|  | 69 | HMQ thmq; | 
|---|
| [2] | 70 | FILE *fp; | 
|---|
| [551] | 71 | HFILE oldstdout, newstdout; | 
|---|
| [2] | 72 | struct tempstruct *undelinfo; | 
|---|
| [551] | 73 | BOOL killme = FALSE; | 
|---|
| [847] | 74 | FILESTATUS3 fsa; | 
|---|
| [2] | 75 |  | 
|---|
|  | 76 | undelinfo = (struct tempstruct *)arg; | 
|---|
|  | 77 | hwnd = undelinfo->hwnd; | 
|---|
|  | 78 | path = undelinfo->path; | 
|---|
|  | 79 | DosError(FERR_DISABLEHARDERR); | 
|---|
|  | 80 |  | 
|---|
| [1038] | 81 | # ifdef FORTIFY | 
|---|
|  | 82 | Fortify_EnterScope(); | 
|---|
| [1063] | 83 | #  endif | 
|---|
| [2] | 84 | thab = WinInitialize(0); | 
|---|
| [551] | 85 | thmq = WinCreateMsgQueue(thab, 0); | 
|---|
| [528] | 86 | if (thab && thmq) { | 
|---|
| [551] | 87 | WinCancelShutdown(thmq, TRUE); | 
|---|
| [528] | 88 | IncrThreadUsage(); | 
|---|
| [551] | 89 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID); | 
|---|
| [1075] | 90 | BldFullPathName(szTempFile, pTmpDir, "$UDELETE.#$#"); | 
|---|
| [1073] | 91 | unlinkf("%s", szTempFile); | 
|---|
|  | 92 | fp = xfopen(szTempFile, "w", pszSrcFile, __LINE__); | 
|---|
| [328] | 93 | if (!fp) { | 
|---|
| [551] | 94 | Win_Error(NULLHANDLE, hwnd, pszSrcFile, __LINE__, | 
|---|
|  | 95 | GetPString(IDS_REDIRECTERRORTEXT)); | 
|---|
| [328] | 96 | killme = TRUE; | 
|---|
|  | 97 | goto Abort; | 
|---|
|  | 98 | } | 
|---|
|  | 99 | else { | 
|---|
| [2] | 100 | newstdout = -1; | 
|---|
| [551] | 101 | if (DosDupHandle(fileno(stdout), &newstdout)) { | 
|---|
|  | 102 | saymsg(MB_CANCEL, | 
|---|
|  | 103 | hwnd, | 
|---|
|  | 104 | GetPString(IDS_MAYDAYTEXT), GetPString(IDS_REDIRECTERRORTEXT)); | 
|---|
|  | 105 | fclose(fp); | 
|---|
|  | 106 | killme = TRUE; | 
|---|
|  | 107 | goto Abort; | 
|---|
| [2] | 108 | } | 
|---|
|  | 109 | oldstdout = fileno(stdout); | 
|---|
| [551] | 110 | DosDupHandle(fileno(fp), &oldstdout); | 
|---|
| [2] | 111 | runemf2(SEPARATE | INVISIBLE | WINDOWED | BACKGROUND | WAIT, | 
|---|
| [888] | 112 | hwnd, pszSrcFile, __LINE__, | 
|---|
| [551] | 113 | NULL, | 
|---|
|  | 114 | NULL, | 
|---|
|  | 115 | "UNDELETE.COM %s /L%s", | 
|---|
|  | 116 | path, (undelinfo->inclsubdirs) ? " /S" : NullStr); | 
|---|
| [2] | 117 | oldstdout = fileno(stdout); | 
|---|
| [551] | 118 | DosDupHandle(newstdout, &oldstdout); | 
|---|
| [2] | 119 | DosClose(newstdout); | 
|---|
|  | 120 | fclose(fp); | 
|---|
|  | 121 | } | 
|---|
| [1073] | 122 | fp = xfopen(szTempFile, "r", pszSrcFile, __LINE__); | 
|---|
| [328] | 123 | if (fp) { | 
|---|
| [551] | 124 | xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__);   // Skip 1st line | 
|---|
| [406] | 125 | while (!feof(fp)) { | 
|---|
| [551] | 126 | strset(s, 0); | 
|---|
|  | 127 | if (!xfgets_bstripcr(s, CCHMAXPATH + 2, fp, pszSrcFile, __LINE__)) | 
|---|
|  | 128 | break; | 
|---|
|  | 129 | if (*s) { | 
|---|
|  | 130 | if (!strnicmp(s, "SYS3194: ", 9)) { | 
|---|
| [2] | 131 |  | 
|---|
| [551] | 132 | APIRET temp; | 
|---|
| [2] | 133 |  | 
|---|
| [551] | 134 | strcat(s, " "); | 
|---|
|  | 135 | xfgets(&s[strlen(s)], CCHMAXPATH + 128 - strlen(s), fp, | 
|---|
|  | 136 | pszSrcFile, __LINE__); | 
|---|
|  | 137 | fclose(fp); | 
|---|
|  | 138 | s[CCHMAXPATH + 128] = 0; | 
|---|
|  | 139 | stripcr(s); | 
|---|
|  | 140 | rstrip(s); | 
|---|
|  | 141 | strcat(s, GetPString(IDS_ASKABOUTUNDELETEHELPTEXT)); | 
|---|
|  | 142 | temp = saymsg(MB_YESNOCANCEL | MB_ICONEXCLAMATION, | 
|---|
|  | 143 | hwnd, GetPString(IDS_ERRORTEXT), "%s", s); | 
|---|
|  | 144 | if (temp == MBID_YES) | 
|---|
|  | 145 | runemf2(BACKGROUND | INVISIBLE | SEPARATE | WINDOWED, | 
|---|
| [888] | 146 | hwnd, pszSrcFile, __LINE__, | 
|---|
| [551] | 147 | NULL, NULL, "%s /C HELP UNDELETE", GetCmdSpec(FALSE)); | 
|---|
|  | 148 | if (temp == MBID_CANCEL) | 
|---|
|  | 149 | killme = TRUE; | 
|---|
|  | 150 | goto Abort; | 
|---|
|  | 151 | } | 
|---|
|  | 152 | else if (s[1] != ':') | 
|---|
|  | 153 | continue; | 
|---|
|  | 154 | else if ((SHORT) | 
|---|
|  | 155 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_SEARCHSTRING, | 
|---|
|  | 156 | MPFROM2SHORT(0, LIT_FIRST), | 
|---|
|  | 157 | MPFROMP(s)) < 0 | 
|---|
| [847] | 158 | && DosQueryPathInfo(s, FIL_STANDARD, &fsa, | 
|---|
| [551] | 159 | (ULONG) sizeof(fsa))) | 
|---|
|  | 160 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_INSERTITEM, | 
|---|
|  | 161 | MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s)); | 
|---|
|  | 162 | } | 
|---|
| [2] | 163 | } | 
|---|
|  | 164 | fclose(fp); | 
|---|
|  | 165 | } | 
|---|
| [551] | 166 | Abort: | 
|---|
| [528] | 167 | ; | 
|---|
|  | 168 | } | 
|---|
| [1073] | 169 | DosForceDelete(szTempFile); | 
|---|
| [1009] | 170 | xfree(undelinfo, pszSrcFile, __LINE__); | 
|---|
| [528] | 171 | if (thmq) { | 
|---|
| [551] | 172 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID); | 
|---|
| [528] | 173 | if (killme) | 
|---|
| [551] | 174 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| [2] | 175 | WinDestroyMsgQueue(thmq); | 
|---|
| [528] | 176 | } | 
|---|
|  | 177 | if (thab) { | 
|---|
|  | 178 | DecrThreadUsage(); | 
|---|
| [2] | 179 | WinTerminate(thab); | 
|---|
|  | 180 | } | 
|---|
| [1038] | 181 | # ifdef FORTIFY | 
|---|
| [1063] | 182 | Fortify_LeaveScope(); | 
|---|
|  | 183 | #  endif | 
|---|
| [2] | 184 | } | 
|---|
|  | 185 |  | 
|---|
| [551] | 186 | MRESULT EXPENTRY UndeleteDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| [328] | 187 | { | 
|---|
| [551] | 188 | SHORT sSelect; | 
|---|
|  | 189 | static BOOL listdone, changed = FALSE, refresh = FALSE; | 
|---|
|  | 190 | static HPOINTER hptrIcon = (HPOINTER) 0; | 
|---|
| [2] | 191 |  | 
|---|
| [551] | 192 | switch (msg) { | 
|---|
|  | 193 | case WM_INITDLG: | 
|---|
|  | 194 | listdone = TRUE; | 
|---|
| [1009] | 195 | if (!mp2 || !*(CHAR *)mp2) { | 
|---|
| [551] | 196 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); | 
|---|
|  | 197 | WinDismissDlg(hwnd, 0); | 
|---|
| [2] | 198 | break; | 
|---|
| [551] | 199 | } | 
|---|
|  | 200 | hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, UNDEL_FRAME); | 
|---|
|  | 201 | WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPVOID); | 
|---|
|  | 202 | WinSendDlgItemMsg(hwnd, UNDEL_ENTRY, EM_SETTEXTLIMIT, | 
|---|
|  | 203 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID); | 
|---|
|  | 204 | { | 
|---|
|  | 205 | CHAR s[CCHMAXPATH]; | 
|---|
| [2] | 206 |  | 
|---|
| [1009] | 207 | strcpy(s, (CHAR *)mp2); | 
|---|
| [551] | 208 | if (s[strlen(s) - 1] != '\\') | 
|---|
|  | 209 | strcat(s, "\\"); | 
|---|
|  | 210 | strcat(s, "*"); | 
|---|
|  | 211 | WinSetDlgItemText(hwnd, UNDEL_ENTRY, s); | 
|---|
|  | 212 | WinCheckButton(hwnd, UNDEL_SUBDIRS, TRUE); | 
|---|
|  | 213 | FillPathListBox(hwnd, WinWindowFromID(hwnd, UNDEL_DRIVELIST), (HWND) 0, | 
|---|
|  | 214 | s, TRUE); | 
|---|
|  | 215 | } | 
|---|
|  | 216 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
|  | 217 | break; | 
|---|
| [2] | 218 |  | 
|---|
| [551] | 219 | case UM_SETUP: | 
|---|
|  | 220 | if (listdone) { | 
|---|
| [2] | 221 |  | 
|---|
| [551] | 222 | struct tempstruct *undelinfo; | 
|---|
|  | 223 | CHAR s[CCHMAXPATH]; | 
|---|
|  | 224 |  | 
|---|
|  | 225 | listdone = FALSE; | 
|---|
|  | 226 | undelinfo = xmallocz(sizeof(struct tempstruct), pszSrcFile, __LINE__); | 
|---|
|  | 227 | if (!undelinfo) { | 
|---|
|  | 228 | listdone = TRUE; | 
|---|
|  | 229 | WinDismissDlg(hwnd, 0); | 
|---|
|  | 230 | } | 
|---|
|  | 231 | else { | 
|---|
|  | 232 | undelinfo->hwnd = hwnd; | 
|---|
|  | 233 | WinQueryDlgItemText(hwnd, | 
|---|
|  | 234 | UNDEL_ENTRY, | 
|---|
|  | 235 | sizeof(undelinfo->path), undelinfo->path); | 
|---|
|  | 236 | bstrip(undelinfo->path); | 
|---|
|  | 237 | MakeFullName(undelinfo->path); | 
|---|
|  | 238 | undelinfo->inclsubdirs = WinQueryButtonCheckstate(hwnd, | 
|---|
|  | 239 | UNDEL_SUBDIRS); | 
|---|
|  | 240 | sprintf(s, | 
|---|
|  | 241 | GetPString(IDS_UNDELETETITLETEXT), toupper(*undelinfo->path)); | 
|---|
|  | 242 | WinSetWindowText(hwnd, s); | 
|---|
| [1335] | 243 | if (xbeginthread(FillUndelListThread, | 
|---|
|  | 244 | 65536, | 
|---|
|  | 245 | undelinfo, | 
|---|
|  | 246 | pszSrcFile, | 
|---|
|  | 247 | __LINE__) == -1) | 
|---|
|  | 248 | { | 
|---|
| [1039] | 249 | free(undelinfo); | 
|---|
| [551] | 250 | listdone = TRUE; | 
|---|
|  | 251 | WinDismissDlg(hwnd, 0); | 
|---|
| [328] | 252 | } | 
|---|
| [551] | 253 | else | 
|---|
| [771] | 254 | DosSleep(100);//05 Aug 07 GKY 500 | 
|---|
| [2] | 255 | } | 
|---|
| [551] | 256 | refresh = FALSE; | 
|---|
|  | 257 | } | 
|---|
|  | 258 | else | 
|---|
|  | 259 | refresh = TRUE; | 
|---|
|  | 260 | changed = FALSE; | 
|---|
|  | 261 | return 0; | 
|---|
| [2] | 262 |  | 
|---|
| [551] | 263 | case UM_CONTAINER_FILLED: | 
|---|
|  | 264 | listdone = TRUE; | 
|---|
|  | 265 | { | 
|---|
|  | 266 | CHAR s[33]; | 
|---|
| [2] | 267 |  | 
|---|
| [551] | 268 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, | 
|---|
|  | 269 | UNDEL_LISTBOX, | 
|---|
|  | 270 | LM_QUERYITEMCOUNT, MPVOID, MPVOID); | 
|---|
|  | 271 | sprintf(s, "%d", sSelect); | 
|---|
|  | 272 | WinSetDlgItemText(hwnd, UNDEL_COUNT, s); | 
|---|
|  | 273 | if (refresh) | 
|---|
|  | 274 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
|  | 275 | refresh = FALSE; | 
|---|
|  | 276 | } | 
|---|
|  | 277 | return 0; | 
|---|
| [2] | 278 |  | 
|---|
| [551] | 279 | case WM_CONTROL: | 
|---|
|  | 280 | switch (SHORT1FROMMP(mp1)) { | 
|---|
|  | 281 | case UNDEL_SUBDIRS: | 
|---|
|  | 282 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
|  | 283 | break; | 
|---|
| [2] | 284 |  | 
|---|
| [551] | 285 | case UNDEL_ENTRY: | 
|---|
|  | 286 | switch (SHORT2FROMMP(mp1)) { | 
|---|
|  | 287 | case EN_CHANGE: | 
|---|
|  | 288 | changed = TRUE; | 
|---|
|  | 289 | break; | 
|---|
|  | 290 | case EN_KILLFOCUS: | 
|---|
|  | 291 | if (changed) | 
|---|
|  | 292 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
|  | 293 | break; | 
|---|
| [2] | 294 | } | 
|---|
|  | 295 | break; | 
|---|
|  | 296 |  | 
|---|
| [551] | 297 | case UNDEL_DRIVELIST: | 
|---|
|  | 298 | if (!listdone) { | 
|---|
|  | 299 | Runtime_Error(pszSrcFile, __LINE__, "not listdone"); | 
|---|
|  | 300 | break; | 
|---|
| [2] | 301 | } | 
|---|
| [551] | 302 | switch (SHORT2FROMMP(mp1)) { | 
|---|
|  | 303 | case CBN_ENTER: | 
|---|
|  | 304 | { | 
|---|
|  | 305 | CHAR s[CCHMAXPATH], drive, *p; | 
|---|
| [2] | 306 |  | 
|---|
| [551] | 307 | strset(s, 0); | 
|---|
|  | 308 | WinQueryDlgItemText(hwnd, UNDEL_DRIVELIST, 3, s); | 
|---|
|  | 309 | if (!isalpha(*s)) { | 
|---|
|  | 310 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); | 
|---|
| [328] | 311 | } | 
|---|
|  | 312 | else { | 
|---|
| [551] | 313 | drive = toupper(*s); | 
|---|
|  | 314 | WinQueryDlgItemText(hwnd, UNDEL_ENTRY, sizeof(s), s); | 
|---|
|  | 315 | *s = drive; | 
|---|
|  | 316 | s[1] = ':'; | 
|---|
|  | 317 | s[2] = '\\'; | 
|---|
|  | 318 | p = strrchr(s + 2, '\\'); | 
|---|
|  | 319 | if (p) { | 
|---|
|  | 320 | p++; | 
|---|
|  | 321 | if (*p) | 
|---|
|  | 322 | memmove(s + 3, p, strlen(p) + 1); | 
|---|
|  | 323 | else { | 
|---|
|  | 324 | s[3] = '*'; | 
|---|
|  | 325 | s[4] = 0; | 
|---|
|  | 326 | } | 
|---|
|  | 327 | } | 
|---|
|  | 328 | else { | 
|---|
|  | 329 | s[3] = '*'; | 
|---|
|  | 330 | s[4] = 0; | 
|---|
|  | 331 | } | 
|---|
|  | 332 | s[CCHMAXPATH - 1] = 0; | 
|---|
|  | 333 | WinSetDlgItemText(hwnd, UNDEL_ENTRY, s); | 
|---|
|  | 334 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
|  | 335 | } | 
|---|
|  | 336 | } | 
|---|
|  | 337 | break; | 
|---|
|  | 338 | } | 
|---|
|  | 339 | break; | 
|---|
| [2] | 340 |  | 
|---|
| [551] | 341 | case UNDEL_LISTBOX: | 
|---|
|  | 342 | switch (SHORT2FROMMP(mp2)) { | 
|---|
|  | 343 | case LN_ENTER: | 
|---|
|  | 344 | WinSendDlgItemMsg(hwnd, DID_OK, BM_CLICK, MPFROMSHORT(TRUE), MPVOID); | 
|---|
|  | 345 | break; | 
|---|
|  | 346 | } | 
|---|
|  | 347 | break; | 
|---|
| [2] | 348 |  | 
|---|
| [551] | 349 | default: | 
|---|
|  | 350 | break; | 
|---|
|  | 351 | } | 
|---|
|  | 352 | return 0; | 
|---|
| [2] | 353 |  | 
|---|
| [551] | 354 | case WM_ADJUSTWINDOWPOS: | 
|---|
|  | 355 | PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID); | 
|---|
|  | 356 | break; | 
|---|
| [2] | 357 |  | 
|---|
| [551] | 358 | case UM_STRETCH: | 
|---|
|  | 359 | { | 
|---|
|  | 360 | SWP swpC, swp, swpM, swpD, swpL, swpE; | 
|---|
| [2] | 361 |  | 
|---|
| [551] | 362 | WinQueryWindowPos(hwnd, &swp); | 
|---|
|  | 363 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
|  | 364 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_LISTBOX), &swpC); | 
|---|
|  | 365 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_MASKHDR), &swpM); | 
|---|
|  | 366 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_DRVHDR), &swpD); | 
|---|
|  | 367 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_DRIVELIST), &swpL); | 
|---|
|  | 368 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_ENTRY), &swpE); | 
|---|
|  | 369 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_LISTBOX), HWND_TOP, | 
|---|
|  | 370 | SysVal(SV_CXSIZEBORDER), | 
|---|
|  | 371 | swpC.y, | 
|---|
|  | 372 | swp.cx - (SysVal(SV_CXSIZEBORDER) * 2), | 
|---|
|  | 373 | (swp.cy - swpC.y) - (SysVal(SV_CYTITLEBAR) + | 
|---|
|  | 374 | SysVal(SV_CYSIZEBORDER) + | 
|---|
|  | 375 | swpM.cy + 16), | 
|---|
|  | 376 | SWP_MOVE | SWP_SIZE); | 
|---|
|  | 377 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_MASKHDR), HWND_TOP, | 
|---|
|  | 378 | swpM.x, | 
|---|
|  | 379 | (swp.cy - swpM.cy) - (SysVal(SV_CYTITLEBAR) + | 
|---|
|  | 380 | SysVal(SV_CYSIZEBORDER) + 8), | 
|---|
|  | 381 | swpM.cx, swpM.cy, SWP_MOVE | SWP_SIZE); | 
|---|
|  | 382 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_DRVHDR), HWND_TOP, | 
|---|
|  | 383 | swpD.x, | 
|---|
|  | 384 | (swp.cy - swpM.cy) - (SysVal(SV_CYTITLEBAR) + | 
|---|
|  | 385 | SysVal(SV_CYSIZEBORDER) + 8), | 
|---|
|  | 386 | swpD.cx, swpM.cy, SWP_MOVE | SWP_SIZE); | 
|---|
|  | 387 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_DRIVELIST), HWND_TOP, | 
|---|
|  | 388 | swpL.x, | 
|---|
|  | 389 | SysVal(SV_CYSIZEBORDER), | 
|---|
|  | 390 | swpL.cx, | 
|---|
|  | 391 | swp.cy - (SysVal(SV_CYTITLEBAR) + | 
|---|
|  | 392 | (SysVal(SV_CYSIZEBORDER) * 2) + 6), | 
|---|
|  | 393 | SWP_MOVE | SWP_SIZE); | 
|---|
|  | 394 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_ENTRY), HWND_TOP, | 
|---|
|  | 395 | swpM.x + swpM.cx + 4, | 
|---|
|  | 396 | (swp.cy - swpM.cy) - (SysVal(SV_CYTITLEBAR) + | 
|---|
|  | 397 | SysVal(SV_CYSIZEBORDER) + 8), | 
|---|
|  | 398 | swp.cx - ((swpM.x + swpM.cx + 4) + | 
|---|
|  | 399 | (SysVal(SV_CXSIZEBORDER) + 8)), | 
|---|
|  | 400 | swpM.cy + 2, SWP_MOVE | SWP_SIZE); | 
|---|
|  | 401 | WinInvalidateRect(WinWindowFromID(hwnd, UNDEL_ENTRY), NULL, FALSE); | 
|---|
| [2] | 402 | } | 
|---|
| [551] | 403 | } | 
|---|
|  | 404 | return 0; | 
|---|
| [2] | 405 |  | 
|---|
| [551] | 406 | case WM_COMMAND: | 
|---|
|  | 407 | switch (SHORT1FROMMP(mp1)) { | 
|---|
|  | 408 | case UNDEL_DEL: | 
|---|
|  | 409 | case DID_OK: | 
|---|
|  | 410 | if (changed || !listdone) { | 
|---|
|  | 411 | Runtime_Error(pszSrcFile, __LINE__, "not done"); | 
|---|
| [328] | 412 | } | 
|---|
| [551] | 413 | else { | 
|---|
|  | 414 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, | 
|---|
|  | 415 | LM_QUERYSELECTION, | 
|---|
|  | 416 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
|  | 417 | if (sSelect >= 0) { | 
|---|
|  | 418 |  | 
|---|
|  | 419 | FILE *fp; | 
|---|
|  | 420 | CHAR s[CCHMAXPATH + 1]; | 
|---|
|  | 421 |  | 
|---|
|  | 422 | DosForceDelete("\\FMUNDEL.CMD"); | 
|---|
|  | 423 | fp = xfopen("\\FMUNDEL.CMD", "w", pszSrcFile, __LINE__); | 
|---|
|  | 424 | if (fp) { | 
|---|
|  | 425 | while (sSelect >= 0) { | 
|---|
|  | 426 | *s = 0; | 
|---|
|  | 427 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_QUERYITEMTEXT, | 
|---|
|  | 428 | MPFROM2SHORT(sSelect, CCHMAXPATH), | 
|---|
|  | 429 | MPFROMP(s)); | 
|---|
|  | 430 | if (SHORT1FROMMP(mp1) == UNDEL_DEL) | 
|---|
|  | 431 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_DELETEITEM, | 
|---|
|  | 432 | MPFROM2SHORT(sSelect, 0), MPVOID); | 
|---|
|  | 433 | if (*s) { | 
|---|
|  | 434 | if (SHORT1FROMMP(mp1) == DID_OK) | 
|---|
|  | 435 | fprintf(fp, | 
|---|
|  | 436 | "IF NOT EXIST \"%s\" UNDELETE.COM \"%s\" /A\n", | 
|---|
|  | 437 | s, s); | 
|---|
|  | 438 | else | 
|---|
|  | 439 | fprintf(fp, "UNDELETE.COM \"%s\" /F /A\n", s); | 
|---|
|  | 440 | } | 
|---|
|  | 441 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd, | 
|---|
|  | 442 | UNDEL_LISTBOX, | 
|---|
|  | 443 | LM_QUERYSELECTION, | 
|---|
|  | 444 | (SHORT1FROMMP(mp1) == | 
|---|
|  | 445 | DID_OK) ? | 
|---|
|  | 446 | MPFROMSHORT(sSelect) : | 
|---|
|  | 447 | MPFROMSHORT(LIT_FIRST), | 
|---|
|  | 448 | MPVOID); | 
|---|
|  | 449 | } | 
|---|
|  | 450 | fprintf(fp, "DEL \\FMUNDEL.CMD /F\n"); | 
|---|
|  | 451 | fclose(fp); | 
|---|
|  | 452 | runemf2(WINDOWED | BACKGROUND | SEPARATE | INVISIBLE, | 
|---|
| [888] | 453 | hwnd, pszSrcFile, __LINE__, | 
|---|
| [551] | 454 | NULL, NULL, "%s /C \\FMUNDEL.CMD", GetCmdSpec(FALSE)); | 
|---|
|  | 455 | } | 
|---|
|  | 456 | } | 
|---|
|  | 457 | if (SHORT1FROMMP(mp1) == DID_OK) | 
|---|
|  | 458 | WinDismissDlg(hwnd, 0); | 
|---|
|  | 459 | { | 
|---|
|  | 460 | CHAR s[33]; | 
|---|
|  | 461 |  | 
|---|
|  | 462 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, | 
|---|
|  | 463 | UNDEL_LISTBOX, | 
|---|
|  | 464 | LM_QUERYITEMCOUNT, | 
|---|
|  | 465 | MPVOID, MPVOID); | 
|---|
|  | 466 | sprintf(s, "%d", sSelect); | 
|---|
|  | 467 | WinSetDlgItemText(hwnd, UNDEL_COUNT, s); | 
|---|
|  | 468 | } | 
|---|
|  | 469 | } | 
|---|
| [328] | 470 | break; | 
|---|
| [2] | 471 |  | 
|---|
| [551] | 472 | case DID_CANCEL: | 
|---|
|  | 473 | if (!listdone) | 
|---|
|  | 474 | Runtime_Error(pszSrcFile, __LINE__, "is busy"); | 
|---|
|  | 475 | else | 
|---|
|  | 476 | WinDismissDlg(hwnd, 0); | 
|---|
| [2] | 477 | break; | 
|---|
| [551] | 478 |  | 
|---|
|  | 479 | case IDM_HELP: | 
|---|
|  | 480 | saymsg(MB_ENTER | MB_ICONASTERISK, | 
|---|
|  | 481 | hwnd, | 
|---|
|  | 482 | GetPString(IDS_UNDELETEHELPTITLETEXT), | 
|---|
|  | 483 | GetPString(IDS_UNDELETEHELPTEXT)); | 
|---|
|  | 484 | break; | 
|---|
|  | 485 | } | 
|---|
|  | 486 | return 0; | 
|---|
|  | 487 |  | 
|---|
|  | 488 | case WM_CLOSE: | 
|---|
|  | 489 | if (!listdone) { | 
|---|
|  | 490 | Runtime_Error(pszSrcFile, __LINE__, "not listdone"); | 
|---|
|  | 491 | return 0; | 
|---|
|  | 492 | } | 
|---|
|  | 493 | break; | 
|---|
|  | 494 |  | 
|---|
|  | 495 | case WM_DESTROY: | 
|---|
|  | 496 | if (hptrIcon) | 
|---|
|  | 497 | WinDestroyPointer(hptrIcon); | 
|---|
|  | 498 | hptrIcon = (HPOINTER) 0; | 
|---|
|  | 499 | break; | 
|---|
| [2] | 500 | } | 
|---|
| [551] | 501 | return WinDefDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| [2] | 502 | } | 
|---|
| [793] | 503 |  | 
|---|
|  | 504 | #pragma alloc_text(UNDELETE,FillUndelListThread,UndeleteDlgProc) | 
|---|