VC高手进来一下。

来源:百度知道 编辑:UC知道 时间:2024/06/06 15:31:36
为什么我的dialog中的ONCTLCOLOR消息把DIALOG变为透明后 当它移动的时候或者其他窗口覆盖到它的上边后无法重绘底面啊。该怎么做啊

OnCtlColor must return a handle to the brush that is to be used for painting the control background,你这种情况是没有动态返回一个句柄应用于当前窗口
下面是一个例子:
// This OnCtlColor handler will change the color of a static control
// with the ID of IDC_MYSTATIC. The code assumes that the CMyDialog
// class has an initialized and created CBrush member named m_brush.
// The control will be painted with red text and a background
// color of m_brush.

HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// Call the base class implementation first! Otherwise, it may
// undo what we're trying to accomplish here.
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// Are we painting the IDC_MYSTATIC control? We can use
// CWnd::GetDlgCtrlID() to perform the most efficient test.
if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
{
// Set the text color to red
pDC->SetTex