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