MFC 中设置控件扩展样式的最佳位置在哪里
我有一个简单的MFC MDI应用程序,其中有主CFormView,其中有CListCtrl控件。我想设置其扩展样式,如下所示:
m_listctrl.SetExtendedStyle(LVS_EX_DOUBLEBUFFER|LVS_EX_GRIDLINES);
问题是我应该在哪里放置此初始化代码?我试图将它放在 CMyFormView 构造函数中,但我意识到我的 CListCtrl 控件是在 CMyFormView::DoDataExchange() 中创建的,通过:
DDX_Control(pDX, IDC_LIST_INVENTORY, m_listctrl);
所以构造函数位于 DoDataExchange() 之前,将导致断言失败。
I have a simple MFC MDI application, where there is main CFormView, in which there is CListCtrl control. I want to set its extended styles like below:
m_listctrl.SetExtendedStyle(LVS_EX_DOUBLEBUFFER|LVS_EX_GRIDLINES);
Question is where should I place this initialisation code? I tried to put it in CMyFormView constructor, but I realised that my CListCtrl control is created in CMyFormView::DoDataExchange(), by:
DDX_Control(pDX, IDC_LIST_INVENTORY, m_listctrl);
So constructor is before DoDataExchange() and will cause Assert failure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
OnInitDialog()
覆盖(WM_INITDIALOG
处理程序)中调用SetExtendedStyle()
。Call
SetExtendedStyle()
in theOnInitDialog()
override (WM_INITDIALOG
handler).