[cpp] view plain copy print?
CString CTestDlg::brow(LPCTSTR filter)
{
OPENFILENAME ofn
TCHAR szFilename[512]=_T("")
ZeroMemory(&ofn, sizeof(OPENFILENAME))
ofn.lStructSize = sizeof(OPENFILENAME)
ofn.hwndOwner = ::AfxGetMainWnd()->m_hWnd
ofn.lpstrFile = szFilename
ofn.nMaxFile = sizeof(szFilename)
ofn.lpstrFilter = filter
ofn.nFilterIndex = 1
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = NULL
ofn.lpstrDefExt=NULL
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY
GetOpenFileName(&ofn)
if(lstrlen(ofn.lpstrFile)>0)
{
return ofn.lpstrFile
}
return _T("")
}
[cpp] view plain copy print?
void CTestDlg::OnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE)
m_File=brow(_T("所有文件(*.*)|*.*\0\0"))
UpdateData(false)
}
[cpp] view plain copy print?
在TestDlg.h添加如下代码:
[cpp] view plain copy print?
CString brow(LPCTSTR filter)
可以添加。定义CFontDialog的回调函数,在回调函数中相应WM_INITDIALOG消息,即可创建按钮并加入按钮ID,同样相应创建按钮消息即可实现按钮功能。百度“CFontDialog 回调函数”有更多文章和示例代码,就不复制粘贴了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)