CFile和CFileDialog的结合...

王朝vc·作者佚名  2006-01-10
宽屏版  字体: |||超大  

下面是一个函数可以使用CFileDialog取得文件路径,然后用CFile打开的.

(其中,m_szEditText是已经绑定到一个CEdit里面的CString)

CString m_szTmp;

char buf[1000];

CFileDialog dlg(TRUE,"mdl","*.mdl");

if(dlg.DoModal()==IDOK) {

CFile mfile;

mfile.Open(dlg.GetPathName(), CFile::modeRead);

mfile.Read(buf,sizeof(buf));

m_szTmp = buf;

m_szEditText = m_szTmp;

mfile.Close();

}

UpdateData(FALSE);

---------------------------------------------

CFileDialog Class MembersData Members

m_ofn

The Windows OPENFILENAME structure. Provides access to basic file dialog box parameters.

Construction

CFileDialog

Constructs a CFileDialog object.

Operations

DoModal

Displays the dialog box and allows the user to make a selection.

GetPathName

Returns the full path of the selected file.

GetFileName

Returns the filename of the selected file.

GetFileExt

Returns the file extension of the selected file.

GetFileTitle

Returns the title of the selected file.

GetNextPathName

Returns the full path of the next selected file.

GetReadOnlyPref

Returns the read-only status of the selected file.

GetStartPosition

Returns the position of the first element of the filename list.

Overridables

OnShareViolation

Called when a share violation occurs.

OnFileNameOK

Called to validate the filename entered in the dialog box.

OnLBSelChangedNotify

Called when the list box selection changes.

OnInitDone

Called to handle the WM_NOTIFY CDN_INITDONE message.

OnFileNameChange

Called to handle the WM_NOTIFY CDN_SELCHANGE message.

OnFolderChange

Called to handle the WM_NOTIFY CDN_FOLDERCHANGE message.

OnTypeChange

Called to handle the WM_NOTIFY CDN_TYPECHANGE message.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有