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