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