我做了一个ActiveX控件,在oncreate里面创建了一个CStatic控件:
CRect rectBounds;
this->GetClientRect(rectBounds); m_pEssImVideoPanel = new CStatic();
m_pEssImVideoPanel->Create(_T(""), WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, rectBounds, this, IDC_STC_VIDEO);在OnDraw里处理代码:
CBrush brush(TranslateColor(GetBackColor()));
pdc->FillRect(rcBounds, &brush);
pdc->SetTextColor(TranslateColor(GetForeColor()));
pdc->SetBkMode(OPAQUE); if (m_pEssImVideoPanel && m_pEssImVideoPanel->m_hWnd)
{
m_pEssImVideoPanel->MoveWindow(rcBounds);
}在OnCtlColor里处理代码:
HBRUSH hbr = COleControl::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here // TODO: Return a different brush if the default is not desired
if(pWnd->GetDlgCtrlID() == IDC_STC_VIDEO)
{
CBrush brush(TranslateColor(GetBackColor()));
CRect rect;
pWnd->GetClientRect(&rect);
pDC->FillRect(rect, &brush);
pDC->SetBkMode(OPAQUE);
hbr = (HBRUSH)::GetStockObject(NULL_BRUSH); // 注意最后这个hbr返回
} return hbr;
背景颜色是可以设置了,但是在窗体里面插入该控件,怎么使它能够覆盖其他控件,背景怎么看起来是透明的呢小弟刚接触ActiveX控件,望各位大虾赐教啊
CRect rectBounds;
this->GetClientRect(rectBounds); m_pEssImVideoPanel = new CStatic();
m_pEssImVideoPanel->Create(_T(""), WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, rectBounds, this, IDC_STC_VIDEO);在OnDraw里处理代码:
CBrush brush(TranslateColor(GetBackColor()));
pdc->FillRect(rcBounds, &brush);
pdc->SetTextColor(TranslateColor(GetForeColor()));
pdc->SetBkMode(OPAQUE); if (m_pEssImVideoPanel && m_pEssImVideoPanel->m_hWnd)
{
m_pEssImVideoPanel->MoveWindow(rcBounds);
}在OnCtlColor里处理代码:
HBRUSH hbr = COleControl::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here // TODO: Return a different brush if the default is not desired
if(pWnd->GetDlgCtrlID() == IDC_STC_VIDEO)
{
CBrush brush(TranslateColor(GetBackColor()));
CRect rect;
pWnd->GetClientRect(&rect);
pDC->FillRect(rect, &brush);
pDC->SetBkMode(OPAQUE);
hbr = (HBRUSH)::GetStockObject(NULL_BRUSH); // 注意最后这个hbr返回
} return hbr;
背景颜色是可以设置了,但是在窗体里面插入该控件,怎么使它能够覆盖其他控件,背景怎么看起来是透明的呢小弟刚接触ActiveX控件,望各位大虾赐教啊
http://topic.csdn.net/t/20030218/19/1441059.html
你可能没仔细看我的帖子哦,我现在不想要透明效果,比如我在窗体上拉一个ActiveX控件,再拉一些按钮文本框之类的自带控件,这些自带控件总是显示在我自定义的ActiveX控件之上,看起来像是透明的,但具体是不是透明的,还是说ActiveX控件是置底的,其他自带控件都显示在它之上
一、把上面的窗口移开;
二、把下面的窗口放到最上面来;一个容器(比如你的对话框)里面的子窗口(或者说控件),是有tab顺序的,顺序越靠后,越绘制在最上层(或者反之,我记不住了,我没做界面已经很多年)。
那么如何调整tab顺序呢,你可以google一下,vc6的话,我记得是ctrl+d;
如果你对rc文件熟悉,可以用记事本打开rc文件,里面控件的顺序就是tab顺序,把你的控件放到最后(如果不熟悉还是别乱动,可能造成ide崩溃)。