选项卡控件上的列表控件 SetFocus 重绘错误
环境:Visual Studio 2008、Visual Studio 功能包、MFC 对话框应用程序、Windows XP、新的通用控件。
我遇到了恰好位于选项卡控件上的列表控件的问题。
要重现该问题,只需创建一个基于对话框的应用程序即可。将选项卡控件放置在该对话框上,然后将列表控件放置在该选项卡控件上。您不需要向项目添加任何代码。只需构建并运行即可。将焦点设置到列表视图,然后最小化对话框或在其前面放置另一个窗口。
现在将对话框带回前台,列表将无法正确绘制自身。
我尝试过的一件事是处理列表控件的设置焦点事件,但将其保留为空的方法主体,即...
void CMyListControl::OnSetFocus(CWnd* window)
{
// Default();
}
然后重绘问题消失,但是现在您无法选择列表中的项目。取消对 Default 调用的注释会使问题再次出现。
如果我将列表移出选项卡,问题就会消失。如果我将焦点设置到选项卡或对话框上的另一个控件,问题就会消失。这是一个奇怪的现象。
事实上,如果您仔细观察,您可以看到列表本身绘制,然后被选项卡控件遮挡。
Environment: Visual Studio 2008, Visual Studio Feature Pack, MFC Dialog App, Windows XP, New Common Controls.
I'm having a problem with a list control that happens to be on a tab control.
To reproduce the problem simply create a dialog based app. Place a tab control on that dialog, then put a list control onto that tab control. You don't need to add any code to the project. Just build and run. Set the focus to the list view and then either minimize the dialog or bring another window in front of it.
Now bring the dialog back to the foreground, the list will not draw itself correctly.
One thing I have tried is handle the set focus event for the list control, but left it with an empty method body, ie...
void CMyListControl::OnSetFocus(CWnd* window)
{
// Default();
}
Then the redraw problem goes away, however now you can not select items within the list. Uncommenting the call to Default makes the problem come back.
If I move the list off of the tab the problem goes away. If I set the focus to another control on the tab or dialog, the problem goes away. This is a weird one.
In fact, if you watch closely you can see the list drawing itself and then being obscured by the tab control.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道已经晚了,但我今天也遇到了同样的问题。您需要将ListView的父级设置为Tab控件。
注意 hWndList 的父窗口处理程序:hWndTab。或者您可以使用 SetParent。
I know it's late but I had them same problem today. You need to set ListView's parent to Tab control.
Note parent window handler for hWndList: hWndTab. Or you can use SetParent.