gpt4 book ai didi

c++ - 如何用 CDockablePane 中的新 CMFCPropertyGridCtrl 替换

转载 作者:太空宇宙 更新时间:2023-11-04 13:17:54 28 4
gpt4 key购买 nike

我在 CDockablePane 中创建了 CMFCPropertyGridCtrl,我想用一个新的替换这个 CMFCPropertyGridCtrl,然后我覆盖 OnEraseBkgnd。OnEraseBkgnd 仅在应用程序启动时调用,当我想通过 Invalidate 或 InvalidateRect 调用它时,它没有触发。我如何调用 OnEraseBkgnd?提前致谢。

void CCL2PropertiesPane::HostPropertyGridControl(CMFCPropertyGridCtrl* pPropertyGridControl)
{
if(NULL == pPropertyGridControl)
return;

if(m_pPropertyGridControl)
RemoveCurrentPropertyGridControl();

m_pPropertyGridControl = pPropertyGridControl;
SetWindowText(m_pPropertyGridControl->GetName());

CRect clientRectangle;
GetClientRect(&clientRectangle);
m_pPropertyGridControl->Create(WS_CHILD | WS_VISIBLE, clientRectangle, this, PROPERTIES_DOCKABLE_PANE_ID);
}
//--------------------------------------------------------------------------------
void CCL2PropertiesPane::RemoveCurrentPropertyGridControl()
{

m_pPropertyGridControl = NULL;
SetWindowText(GetPaneName());

CRect clientRectangle;
GetClientRect(&clientRectangle);

//here i want to call OnEraseBkgnd
InvalidateRect(clientRectangle);
//Invalidate();
}
//--------------------------------------------------------------------------------
BOOL CCL2PropertiesPane::OnEraseBkgnd(CDC* pDC)
{
CRect clientRectangle;
GetClientRect(&clientRectangle);

CBrush whiteBrush(RGB(250, 250, 250));
pDC->FillRect(clientRectangle, &whiteBrush);

return TRUE;
}

最佳答案

ON_WM_ERASEBKGND 添加到 CCL2PropertiesPane 的消息映射以正确删除背景。或者将 FillRect 函数移动到 OnPaint 中。

关于:

void CCL2PropertiesPane::RemoveCurrentPropertyGridControl()
{
m_pPropertyGridControl = NULL;
...
}

以上代码适用于初始化,但它不会移除或破坏任何东西。控件还在,只是让程序忘了怎么找控件。要隐藏控件,请使用:

m_pPropertyGridControl->ShowWindow(SW_HIDE);

要销毁控件,请使用 DestroyWindow(),但不建议使用上述设置。

关于c++ - 如何用 CDockablePane 中的新 CMFCPropertyGridCtrl 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36529419/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com