MFC 中设置控件扩展样式的最佳位置在哪里

发布于 2024-10-09 05:31:01 字数 399 浏览 0 评论 0原文

我有一个简单的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哥,最终变帅啦 2024-10-16 05:31:01

OnInitDialog() 覆盖(WM_INITDIALOG 处理程序)中调用 SetExtendedStyle()

Call SetExtendedStyle() in the OnInitDialog() override (WM_INITDIALOG handler).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文