void CMyView::OnFileOpen()
{
// TODO: Add your command handler code here
CFileDialog fd(FALSE);
fd.m_ofn.lpstrFileTitle="打开对话框";
fd.m_ofn.lpstrFilter="源文件(*.cpp)\0*.cpp\0\0";
fd.m_ofn.lpstrDefExt="cpp";
fd.DoModal();
}写一个打开文件的对话框,代码如上,结果一运行自动结束了,这是咋回事??
{
// TODO: Add your command handler code here
CFileDialog fd(FALSE);
fd.m_ofn.lpstrFileTitle="打开对话框";
fd.m_ofn.lpstrFilter="源文件(*.cpp)\0*.cpp\0\0";
fd.m_ofn.lpstrDefExt="cpp";
fd.DoModal();
}写一个打开文件的对话框,代码如上,结果一运行自动结束了,这是咋回事??
return;
后来发现了。
问题是你的这句代码:
fd.m_ofn.lpstrFileTitle="打开对话框";
实际上lpstrFileTitle并不是对话框标题。
你大意了,标题是这个lpstrTitle。呵呵。
下面给出MSDN的解释:
1。
lpstrFileTitle:
Pointer to a buffer that receives the file name and extension (without path information) of the selected file. This member can be NULL.2。
lpstrTitle
Pointer to a string to be placed in the title bar of the dialog box. If this member is NULL, the system uses the default title (that is, Save As or Open).以前还没注意到呢。。呵呵。另外分太少了 55555555
本来我打算给10分的,不小心少弄了个0,抱歉呵.....