现在的位置: 首页 > 综合 > 正文

MFC vista下的透明窗口

2014年01月05日 ⁄ 综合 ⁄ 共 758字 ⁄ 字号 评论关闭

bool bBlur = false;

void CTestGlassWindowDlg::OnBnClickedOk()

{

// TODO: Add your control notification handler code here

//OnOK();

 

bBlur = true;

// Negative margins have special meaning to DwmExtendFrameIntoClientArea.

// Negative margins create the "sheet of glass" effect, where the client area

//  is rendered as a solid surface with no window border.

MARGINS margins = {-1};

HRESULT hr = S_OK;

 

// Extend frame across entire window.

hr = DwmExtendFrameIntoClientArea(this->m_hWnd,&margins);

if (SUCCEEDED(hr))

{

//do more things

}

}

 

BOOL CTestGlassWindowDlg::OnEraseBkgnd(CDC* pDC)

{

// TODO: Add your message handler code here and/or call default

if (bBlur)

{

CDC* dc = this->GetDC();

CRect rect;

VERIFY(::GetClientRect(this->m_hWnd,&rect));

 

dc->FillSolidRect(&rect, 

RGB(0, 0, 0));

}

else

{

return CDialog::OnEraseBkgnd(pDC);

}

 

return true; // Yes, I erased the back

}

抱歉!评论已关闭.