fclose (file); free (pstrBuffer); return TRUE; /函数:PopFindFindDlg /作用:弹出Find对话框 HWND PopFindFindDlg(HWND hwnd) static FINDREPLACE fr; /初始化f变量 fr.IStructSize=sizeof (FINDREPLACE); fr.hwndOwner=hwnd; fr.hInstance=NULL; fir.Flags=FR HIDEUPDOWN FR HIDEMATCHCASE FR HIDEWHOLEWORD: fr.lpstrFindWhat=szFindText; fr.lpstrReplace With NULL;
fclose (file); free (pstrBuffer); return TRUE; } //函数:PopFindFindDlg //作用:弹出Find对话框 HWND PopFindFindDlg (HWND hwnd) { static FINDREPLACE fr; //初始化fr变量 fr.lStructSize= sizeof (FINDREPLACE); fr.hwndOwner= hwnd; fr.hInstance= NULL; fr.Flags=FR_HIDEUPDOWN | FR_HIDEMATCHCASE | FR_HIDEWHOLEWORD; fr.lpstrFindWhat= szFindText; fr.lpstrReplaceWith = NULL;
fr.wFindWhatLen=sizeof (szFindText); fr.wReplaceWithLen=0; fr.ICustData =0; fr.lpfnHook=NULL; fr.lpTemplateName=NULL; return FindText(&f);/弹出Find对话框 /函数:PopFindReplaceDlg /作用:弹出Replace对话框 HWND PopFindReplaceDlg (HWND hwnd) static FINDREPLACE fr: /初始化五变量 fr.IStructSize=sizeof (FINDREPLACE); fr.hwndOwner=hwnd; fr.hInstance=NULL;
fr.wFindWhatLen= sizeof (szFindText); fr.wReplaceWithLen= 0; fr.lCustData = 0; fr.lpfnHook= NULL; fr.lpTemplateName= NULL; return FindText (&fr);// 弹出Find对话框 } //函数:PopFindReplaceDlg //作用:弹出Replace对话框 HWND PopFindReplaceDlg (HWND hwnd) { static FINDREPLACE fr; //初始化fr变量 fr.lStructSize= sizeof (FINDREPLACE); fr.hwndOwner= hwnd; fr.hInstance= NULL;
fir.Flags=FR HIDEUPDOWN FR HIDEMATCHCASE FR HIDEWHOLEWORD: fr.lpstrFind What=szFindText; fr.lpstrReplace With szReplText; fr.wFindWhatLen=sizeof (szFindText); fr.wReplace WithLen=sizeof (szReplText); fr.ICustData=0; fr.lpfnHook=NULL; fr.lpTemplateName=NULL; return ReplaceText(&ff);/弹出Replace对话框
fr.Flags=FR_HIDEUPDOWN | FR_HIDEMATCHCASE | FR_HIDEWHOLEWORD; fr.lpstrFindWhat= szFindText; fr.lpstrReplaceWith = szReplText; fr.wFindWhatLen= sizeof (szFindText); fr.wReplaceWithLen= sizeof (szReplText); fr.lCustData= 0; fr.lpfnHook= NULL; fr.lpTemplateName= NULL; return ReplaceText (&fr); //弹出Replace对话框 }
/函数:PopFindFindText /作用:查找字符串 BOOL PopFindFindText (HWND hwndEdit, int *piSearchOffset LPFINDREPLACE pfr) int iLength,iPos; PSTR pstrDoc,pstrPos; /获取编辑框中的文本内容长度 iLength GetWindowTextLength (hwndEdit); if(NULL =(pstrDoc =(PSTR)malloc (iLength +1))) return FALSE; /获取编辑框中的文本内容 GetWindowText (hwndEdit,pstrDoc,iLength 1); pstrPos strstr (pstrDoc +*piSearchOffset,pfr->lpstrFindWhat): free (pstrDoc);
//函数:PopFindFindText //作用:查找字符串 BOOL PopFindFindText (HWND hwndEdit, int *piSearchOffset, LPFINDREPLACE pfr) { int iLength, iPos; PSTR pstrDoc, pstrPos; //获取编辑框中的文本内容长度 iLength = GetWindowTextLength (hwndEdit); if (NULL == (pstrDoc = (PSTR) malloc (iLength + 1))) return FALSE; //获取编辑框中的文本内容 GetWindowText (hwndEdit, pstrDoc, iLength + 1); pstrPos = strstr (pstrDoc + *piSearchOffset, pfr->lpstrFindWhat); free (pstrDoc);
if (pstrPos ==NULL) return FALSE: iPos pstrPos pstrDoc; *piSearchOffset iPos strlen (pfr->IpstrFindWhat); SendMessage (hwndEdit,EM SETSEL,iPos,*piSearchOffset); SendMessage (hwndEdit,EM SCROLLCARET,0,0); return TRUE;
if (pstrPos == NULL) return FALSE; iPos = pstrPos - pstrDoc; *piSearchOffset = iPos + strlen (pfr->lpstrFindWhat); SendMessage (hwndEdit, EM_SETSEL, iPos, *piSearchOffset); SendMessage (hwndEdit, EM_SCROLLCARET, 0, 0); return TRUE; }