CCommonDlg CDN_INITDONE未按预期工作 [英] CCommonDlg CDN_INITDONE Not working as expected

查看:70
本文介绍了CCommonDlg CDN_INITDONE未按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿那边,



我正在使用基于CCommonDlg的FileOpen Dlg。

我不想做一些事情创建对话框后的CListCtrl(例如选择项目)。



所以我将我的附加功能添加到我的OnInitDone()函数中OnNotify:

Hey out there,

i'm using a CCommonDlg based FileOpen Dlg.
I wan't to do some stuff with the CListCtrl (for example selecting an item) after the Dialog has been created.

So i add my additional functionality into my OnInitDone() function which i called this way from the OnNotify:

BOOL CMyFileDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
	// ...

	OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
	switch(pNotify->hdr.code)
	{
	case CDN_INITDONE:
		OnInitDone();
		return TRUE;
	case CDN_SELCHANGE:
		OnFileNameChange();
		return TRUE;
	case CDN_FOLDERCHANGE:
		OnFolderChange();
		return TRUE;
        // case for all other "CDN_" messages
        }

        // ...
}





但是进入OnInitDone函数看起来似乎控件不存在。

当我以下列方式调用FindWindowEx时它总会返回0x0:



But into the OnInitDone function it seems like the Control doesen't exsist.
When i call FindWindowEx in the following way it always returns 0x0:

HWND hwndParentDlg = ::GetParent(this->m_hWnd);
HWND hwndShellDllDefView = ::FindWindowEx(hwndParentDlg, NULL, "SHELLDLL_DefView", NULL);
HWND hwndSysListView = ::FindWindowEx(hwndShellDllDefView, NULL, "SysListView32", NULL);





我玩了一下,检查了我是否可以在OnFolderChange()中获得HWND。在第一眼看来似乎一切都很好,我从SysListView32获得一个有效的HWND。

但是看起来似乎控件存在但没有物品。

所以我将我的代码放入OnFileNameChange()以检查我是否将我的代码放在错误的地方或者我的代码是否有问题。

这里的OnFileNameChange()一切都很酷。 HWND有效,我可以访问SysListView32中的项目。



问题是,我想在创建Dialog之后做一些小调整而不是如果用户选择一个新文件。



所以请帮助我,请原谅我的英语不好。



非常感谢你帮助我!!!!



I played a little bit around and checked if i can get the HWNDs in OnFolderChange(). At the first look it seems everything is ok here, i get a valid HWND from the SysListView32.
But at the secound look it seems like the Control exists but have no items.
So i put my code into the OnFileNameChange() for checking if i put my code at the "wrong place" or if my code is faulty.
Here inside the OnFileNameChange() everything is cool. The HWND is valid and i can access to the items in the SysListView32.

The problem is, i want to do my little adjustments after the Dialog has been created and not if the user select a new file.

So please help me and please forgive me my bad english.

Thank you so much guys for helping me!!!!

推荐答案

谷歌是你的朋友。我发现了这个讨论: https:// groups .google.com / forum /#!topic / comp.os.ms-windows.programmer.win32 / r3-_zzD-ElY [ ^ ]

引用:
Google is your friend. I found this discussion: https://groups.google.com/forum/#!topic/comp.os.ms-windows.programmer.win32/r3-_zzD-ElY[^]
Cite:
Quote:

请注意,模板中没有listview控件;相反,有一个

列表框控件(lst1)。这是一个占位符控件,用于告诉COMMDLG

代码放置SHELLDLL_DefView窗口的位置,在处理完CDN_INITDONE通知后,COMMDLG显然会创建*。所以当你的CDN_INITDONE

处理程序被调用时,还没有创建

SHELLDLL_DefView窗口。

Note that there is no listview control in the template; instead, there's a
listbox control (lst1). That's a placeholder control to tell the COMMDLG
code where to put the SHELLDLL_DefView window, which COMMDLG apparently
creates *after* the CDN_INITDONE notification has been processed. So the
SHELLDLL_DefView window hasn't been created yet when your CDN_INITDONE
handler is called.

当你得到 CDN_FOLDERCHANGE 通知,列表视图已创建但到目前为止尚未填写。

When you get the CDN_FOLDERCHANGE notification, the list view has been created but has not been filled so far.


这篇关于CCommonDlg CDN_INITDONE未按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆