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