Introduction - If you have any usage issues, please Google them yourself
Open a TXT file and displayed in the EDIT control steps: 1. Create a new dialog-based project, known as the ReadFile2. In the interface to add a button (IDC_BUTTON1) and a text editor (IDC_EDIT1) IDC_EDIT1 properties: multi-line, can be drop-down scroll bar .3. Edit button trigger events (void CReadFileDlg:: OnButton1 ()) void CReadFileDlg:: OnButton1 () (//TODO: Add your control notification handler code here CString sFileFilter =*. hex |*. hex CString sFileName CFileDialog fDlg (true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, sFileFilter, NULL) fDlg.DoModal () sFileName = fDlg.GetFileName () if (sFileName! =) (CFile file (sFileName, CFile:: modeRead) int nFileLength = file.GetLength () char* buffer HGLOBAL hgl =:: GlobalAlloc (GMEM_MOVEABLE, nFileLength+ 1) buffer = (char*):: GlobalLock (hgl) file.Read (buffer, nFileLength) SetDlgItemText (IDC_EDIT1, buffer):: GlobalUnlock (hgl):: GlobalFree (hgl)) UpdateData (false))
Packet : 81404586readfile.rar filelist
ReadFile\ReadFile.aps
ReadFile\ReadFile.clw
ReadFile\ReadFile.cpp
ReadFile\ReadFile.dsp
ReadFile\ReadFile.dsw
ReadFile\ReadFile.h
ReadFile\ReadFile.ncb
ReadFile\ReadFile.opt
ReadFile\ReadFile.plg
ReadFile\ReadFile.rc
ReadFile\ReadFileDlg.cpp
ReadFile\ReadFileDlg.h
ReadFile\ReadMe.txt
ReadFile\res\ReadFile.ico
ReadFile\res\ReadFile.rc2
ReadFile\resource.h
ReadFile\StdAfx.cpp
ReadFile\StdAfx.h
ReadFile\Debug
ReadFile\res
ReadFile