Small procedure, file reading and writing: 1. New MFC program, select "Single Document" interface, program name "textfilter" 2. Or set up the window size, otherwise a small software is always a big interface to always feel embarrassing ^^ In Mainfrm. In CPP, PrecreateWindow (CreateStruct & Cs) modifies this CS to modify the appearance of the main interface, cs.cy = :: getSystemMetrics (SM_CYSCREEN) / 3; // Section width cs.cx = :: getSystemMetrics (SM_CXSCREEN) / 3; // Interface height cs.y = ((cs.cy * 3) - cs.cy) / 2; // interface center point Y coordinate cs.x = ((cs.cx * 3) - cs.cx) / 2; / / Explore the center point X coordinates, if you want to change the appearance of the view, you can change the CS3 in "textfilterView.cpp". In the view, use a text box in the view to display the program operation status <1> in "TextFilterView.h" defined CRichEditCtrl m_rich; <2> in "TextFilterView.cpp" of OnCreate (LPCREATESTRUCT lpCreateStruct) was added: m_rich.Create (ES_AUTOVSCROLL | ES_MULTILINE | ES_WANTRETURN | WS_CHILD | WS_VISIBLE | WS_VSCROLL, rect, this, 1); CFont font; VERIFY ( Font.createFont (16, 0, 0, 0, Fw_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, Clip_default_Precis, Default_quality, default_pitch | ff_swiss, "courier new"); m_rich.setfont (& font, 1); // Setting font <3> In order to be confused in the interface, Cricheditctrl matches the view size, in "TextFilterView.cpp", "TEXTFILTERVIEW.CPP" ONSIZE, Add: CRECT Rect; getClientRect (Rect); M_Rich.SetWindowPos (& Wndtop, 0, 0, Rect.right-Rect.TOP, SWP_SHOWINDOW); 4. When you open CFiledialog Select the file and get the file path, open the file's operation, first select CTextFilterView in the class view, select "ID_FILE_OPEN" in "Event", add the onfileOpen () function, "
Add the following code to the following code: void ctextfilterview :: onfileopen () {if (! Ismissoncomplete) {AFXMESSAGEBOX ("The last task is not completed, end the last task"); return;} // Detection the last opened file is closed IsMissonComplete = false; CFileDialog dlg (TRUE, "", "* htm.", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT); CString str ( "", 1024); dlg.m_ofn.lpstrFile = str.GetBuffer ( 1024); DLG.M_OFN.NMAXFILE = 1024; // Note: Look at the bottom str.releaseBuffer (); cstring pathname [100]; if (dlg.domodal () == idok) {position MPOS = DLG.GetStartPosition () ; Int count = 0; while (mpos! = Null) {pathname [count] = DLG.GetnextPathname (mpos); count ;} // Get all selected files m_filecout = count; // record (how much is File), m_filecout is a global variable cstring filetitle; for (int Temp = 0; Temp
GetDlgItemText (IDC_EDIT1, firstToken); GetDlgItemText (IDC_EDIT2, secondToken); GetDlgItemText (IDC_COMBO1, filteMode); for (int i = 0; i