我的直接想法是让窗透明,但是控件不要透明.我在WM_CTLCOLOR响应函数中只让对话框背景透明.
HBRUSH CTestMgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_DLG)
{
return (HBRUSH)GetStockObject(NULL_BRUSH);
}// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return hbr;
}但是这个要在窗口重绘时才会得到响应首先说明:用Invalidate,UpdateWindow,RedrawWindodw,这些函数的一些用法,都不能在OnMove中使对话框背景重绘.//CDialog::OnPaint();
//CClientDC dc(this);
//Invalidate(FALSE);
//UpdateWindow();
//RedrawWindow(NULL,NULL,RDW_ERASENOW);
// TODO: Add your message handler code here
// HDC hDC=this-> GetDC()->m_hDC;
// LPARAM lParam=0;
//
// lParam=LOWORD(this->m_hWnd);
// lParam+=CTLCOLOR_DLG<<16;
// //::SendMessage(this-> m_hWnd,WM_CTLCOLOR,(WPARAM)hDC,lParam);
//::SendMessage(this->m_hWnd,WM_SHOWWINDOW,SW_HIDE,NULL);
//ShowWindow(SW_HIDE);
//::SendMessage(this->m_hWnd,WM_ACTIVATE,WA_ACTIVE,(LPARAM)this->m_hWnd);
问题: 还有没有其它方法让对话框背景重绘?请大家帮下,不过还请先试试,能在OnMove时重绘背景再给我说哈,再次谢谢大家......
HBRUSH CTestMgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_DLG)
{
return (HBRUSH)GetStockObject(NULL_BRUSH);
}// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return hbr;
}但是这个要在窗口重绘时才会得到响应首先说明:用Invalidate,UpdateWindow,RedrawWindodw,这些函数的一些用法,都不能在OnMove中使对话框背景重绘.//CDialog::OnPaint();
//CClientDC dc(this);
//Invalidate(FALSE);
//UpdateWindow();
//RedrawWindow(NULL,NULL,RDW_ERASENOW);
// TODO: Add your message handler code here
// HDC hDC=this-> GetDC()->m_hDC;
// LPARAM lParam=0;
//
// lParam=LOWORD(this->m_hWnd);
// lParam+=CTLCOLOR_DLG<<16;
// //::SendMessage(this-> m_hWnd,WM_CTLCOLOR,(WPARAM)hDC,lParam);
//::SendMessage(this->m_hWnd,WM_SHOWWINDOW,SW_HIDE,NULL);
//ShowWindow(SW_HIDE);
//::SendMessage(this->m_hWnd,WM_ACTIVATE,WA_ACTIVE,(LPARAM)this->m_hWnd);
问题: 还有没有其它方法让对话框背景重绘?请大家帮下,不过还请先试试,能在OnMove时重绘背景再给我说哈,再次谢谢大家......
{
return (HBRUSH)GetStockObject(NULL_BRUSH);//这里 是窗口没有背景,,
}// TODO: Change any attributes of the DC here所谓的透明只是,窗口的背景没话,,用对应屏幕的背景,,这样背景无法更新,,不能实现透明,除非一直隐藏 显示 窗口才能更新。
做一个子母窗口联动来实现控件的不透明这是现在普遍采用的方法
如果你要自己实现恐怕不想你想的那么容易
另外
应该在OnMoving中调用Invalidate吧
严重逻辑错误。这些东西都能让窗口重画(不信你设断点看看)。但你是想让窗口透明,靠本窗口自己来重画怎么可能画出个“透明”来?只有你窗口下面的东西重画、而你的窗口又没有重画的情况下,窗口才是“透明”的。
SendMessageW(WM_PAINT);
这样还不行吗?