打开对话框CFileDialog中有个控件lst1,用于列表显示文件.请问它是CListBox类吗??
我想通过它的指针来对它进行一些操作.自定义一个类,派生自CFileDialog.
class CMyFileDialog:public CFileDialog
{
CListBox* m_pListBox;
}
重载CFileDialog的OnInitDone()
CMyFileDialog::OnInitDone()
{
m_pListBox = (CListBox*)GetParent()->GetDlgItem(lst1);
ASSERT(m_pListBox->m_hWnd);
//得到打开文件对话框的listbox控件的指针.
}
重载CFileDialog的OnFileNameChange()
CMyFileDialog::OnFileNameChange()
{
int nCount = m_pListBox->GetCount();
//得到的nCount一直为0..可是ListBox里是有项的啊..怎么会
//得到0那,难道这个指针为非法指针??
}
主要问题:想通过得到的m_pListBox指针来读取ListBox当前的选择项,怀疑
CFileDialog里用于列表显示文件的控件不是CListBox,如果不是,是什么控件??如果是CListBox控件,为何得到的m_pListBox指针不能用??
我想通过它的指针来对它进行一些操作.自定义一个类,派生自CFileDialog.
class CMyFileDialog:public CFileDialog
{
CListBox* m_pListBox;
}
重载CFileDialog的OnInitDone()
CMyFileDialog::OnInitDone()
{
m_pListBox = (CListBox*)GetParent()->GetDlgItem(lst1);
ASSERT(m_pListBox->m_hWnd);
//得到打开文件对话框的listbox控件的指针.
}
重载CFileDialog的OnFileNameChange()
CMyFileDialog::OnFileNameChange()
{
int nCount = m_pListBox->GetCount();
//得到的nCount一直为0..可是ListBox里是有项的啊..怎么会
//得到0那,难道这个指针为非法指针??
}
主要问题:想通过得到的m_pListBox指针来读取ListBox当前的选择项,怀疑
CFileDialog里用于列表显示文件的控件不是CListBox,如果不是,是什么控件??如果是CListBox控件,为何得到的m_pListBox指针不能用??
直接画个STATIC控件
整个装进来
void CFilePicViewDlg::OnFileNameChange()
{
//Get the currently selected file name
CFileDialog::OnFileNameChange(); if (m_bPreview)
m_DIBStaticCtrl.LoadDib(GetPathName()); // the control will handle errors CString strFilePath=GetPathName(); //Get the big icon associated with this file
//获取大图标
SHFILEINFO fi;
SHGetFileInfo(strFilePath,0,&fi,sizeof(SHFILEINFO),SHGFI_ICON);}
我的目的是得到CFileDialog中lst1的正确指针.以及正确的控件类型.
CWnd* pWnd = (CWnd*)GetParent()->GetDlgItem(lst1);可以得到lst1的指针.但下一步的问题是lst1到底属于什么控件..我应该把它强制成什么控件指针..因为这样才能决定我用什么函数来得到我想要的信息..比如如果是CListBox
我就需要用(CListBox* pWnd)->GetCount()来得到目前的项目数...而如果是
CListCtrl则需要用(CListCtrl* pWnd)->GetItemCount()来得到..
我想要一个选择多个目录的文件打开对话框,而且不想自己再去重新做一个对话框,希望通过重载CFileDialog来实现..我需要得到目前lst1里选择了多少个目录,以及每个目录的名字之类的信息.我重载CFileDialog函数使它只显示目录,并可以显示多个目录...但不知道怎样得到这些目录的具体信息...
请高手告知怎么解决??如果有例子.请发送到[email protected].谢谢
http://expert.csdn.net/Expert/topic/1173/1173896.xml