我要自定义一个open对话框,除了common filedialog,添加了一些control,同时使用了hook,在hook proc中有 WM_INITDIALOG的定义,那么请问添加的control在什么地方定义,比如说我要
BOOL fdex_mfc_dlg::OnInitDialog()
{
CFileDialog::OnInitDialog();
CListBox* pLB = (CListBox*)GetDlgItem(IDC_ENV);
pLB->InsertString(-1, "Current Project");
pLB->InsertString(-1, "Current scenes");
pLB->InsertString(-1, "Projects");
pLB->InsertString(-1, "Default");
pLB->InsertString(-1, "Home");
pLB->SetIndex(0);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}好像不起作用了!主要是hook proc是全局函数,该如何使用使用mfc类
文件对话框上的控件在收到WM_INITDIALOG甚至是CDN_INITDONE的时候都还不存在。最简单的解决方法是使用自定义消息
BOOL CMyOpenDlg::OnInitDialog()
{
CFileDialog::OnInitDialog();
PostMessage(MYWM_POSTINIT,0,0);
return TRUE;
}
然后在MYWM_POSTINIT的处理函数中操作文件对话框上的控件。因为使用了PostMessage,所以这个消息在之前消息队列中所有消息得到处理之后才会被处理,这时候文件对话框已经初始化完毕了。
仿COMMANDIALOG的VC源码编写 添加control