break; case WM CLOSE: if (!bNeedSave IDCANCEL ! AskAboutSave (hwnd,szTitleName)) Destroy Window (hwnd); return 0; case WM QUERYENDSESSION if (!bNeedSave IDCANCEL !AskAboutSave (hwnd,szTitleName)) return 1; return 0; case WM DESTROY: PostQuitMessage (0); return 0; default: /处理"Find-Replace”消息 if (iMsg =iMsgFindReplace)
break; case WM_CLOSE: if (!bNeedSave || IDCANCEL != AskAboutSave (hwnd, szTitleName)) DestroyWindow (hwnd); return 0; case WM_QUERYENDSESSION : if (!bNeedSave || IDCANCEL != AskAboutSave (hwnd, szTitleName)) return 1; return 0; case WM_DESTROY: PostQuitMessage (0); return 0; default: //处理"Find-Replace" 消息 if (iMsg == iMsgFindReplace) {
pfr =(LPFINDREPLACE)IParam if(pfr->Flags FR DIALOGTERM) hDlgModeless NULL; if(pfr->Flags FR FINDNEXT) if (!PopFindFindText (hwndEdit,&iOffset,pfr)) OkMessage(hwnd,"文本没找到!","0", if(pfr->Flags FR REPLACE pfr->Flags FR REPLACEALL) if(!PopFindReplaceText (hwndEdit,&iOffset,pfr)) OkMessage(hwnd,"文本没找到!","川0"), if(pfr->Flags FR REPLACEALL) while (PopFindReplaceText (hwndEdit,&iOffset,pfr)); return 0 ;
pfr = (LPFINDREPLACE) lParam ; if (pfr->Flags & FR_DIALOGTERM) hDlgModeless = NULL; if (pfr->Flags & FR_FINDNEXT) if (!PopFindFindText (hwndEdit, &iOffset, pfr)) OkMessage (hwnd, "文本没找到!", "\0") ; if (pfr->Flags & FR_REPLACE ||pfr->Flags & FR_REPLACEALL) if (!PopFindReplaceText (hwndEdit, &iOffset, pfr)) OkMessage (hwnd, "文本没找到!", "\0") ; if (pfr->Flags & FR_REPLACEALL) while (PopFindReplaceText (hwndEdit, &iOffset, pfr)); return 0 ;}
break } return DefWindowProc (hwnd,iMsg,wParam,lParam); /函数:PopFilelnitialize /作用:初始化全局变量ofm void PopFileInitialize (HWND hwnd) static char szFilter[]="文本文件(*.TXT)0*.txto" "ASCII文件(*.ASC)0*.asc0"\ "所有文件(*.*)0*.*0八0”; ofn.IStructSize=sizeof (OPENFILENAME) ofn.hwndOwner=hwnd ofn.hInstance=NULL ofn.lpstrFilter=szFilter
break ; } return DefWindowProc (hwnd, iMsg, wParam, lParam) ; } //函数:PopFileInitialize //作用:初始化全局变量ofn void PopFileInitialize (HWND hwnd) { static char szFilter[] = "文本文件(*.TXT)\0*.txt\0" \ "ASCII文件(*.ASC)\0*.asc\0" \ "所有文件 (*.*)\0*.*\0\0" ; ofn.lStructSize= sizeof (OPENFILENAME) ; ofn.hwndOwner= hwnd ; ofn.hInstance= NULL ; ofn.lpstrFilter= szFilter ;
ofn.lpstrCustomFilter NULL ofn.nMaxCustFilter=0 ofn.nFilterIndex=0; ofn.lpstrFile=NULL ofn.nMaxFile=MAX PATH ofn.lpstrFileTitle=NULL ofn.nMaxFileTitle=MAX FNAME MAX EXT ofn.IpstrInitialDir=NULL ofn.IpstrTitle=NULL ofn.Flags=0; ofn.nFileOffset=0; ofn.nFileExtension=0;
ofn.lpstrCustomFilter = NULL ; ofn.nMaxCustFilter= 0 ; ofn.nFilterIndex= 0 ; ofn.lpstrFile= NULL ; ofn.nMaxFile= _MAX_PATH ; ofn.lpstrFileTitle= NULL ; ofn.nMaxFileTitle= _MAX_FNAME + _MAX_EXT ; ofn.lpstrInitialDir= NULL ; ofn.lpstrTitle= NULL ; ofn.Flags= 0 ; ofn.nFileOffset= 0 ; ofn.nFileExtension= 0 ;
ofn.lpstrDefExt="txt"; ofn.ICustData=OL ofn.lpfnHook=NULL ofn.lpTemplateName=NULL /函数:PopFileOpenDlg /作用:弹出Open对话框 BOOL PopFileOpenDlg (HWND hwnd,PSTR pstrFileName,PSTR pstr TitleName) ofn.hwndOwner=hwnd ofn.lpstrFile=pstrFileName ofn.lpstrFileTitle=pstrTitleName ofn.Flags=OFN HIDEREADONLY; return GetOpenFileName(&ofn);/弹出Open对话框
ofn.lpstrDefExt= "txt" ; ofn.lCustData= 0L ; ofn.lpfnHook= NULL ; ofn.lpTemplateName= NULL ; } //函数:PopFileOpenDlg //作用:弹出Open对话框 BOOL PopFileOpenDlg (HWND hwnd, PSTR pstrFileName, PSTR pstrTitleName) { ofn.hwndOwner= hwnd ; ofn.lpstrFile= pstrFileName ; ofn.lpstrFileTitle= pstrTitleName ; ofn.Flags= OFN_HIDEREADONLY; return GetOpenFileName (&ofn) ;//弹出Open对话框 }