void CTestDlg::ToggleTransparency(HWND hWnd)
{
::SetWindowLong(
hWnd,
GWL_EXSTYLE,
GetWindowLong(hWnd,GWL_EXSTYLE)^WS_EX_LAYERED);
// When bAlpha is 0, the window is completely transparent.
// When bAlpha is 255, the window is opaque.
::SetLayeredWindowAttributes(hWnd, RGB(0,0,0), 200, LWA_ALPHA);
}
BOOL CTestDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
ToggleTransparency(this->GetSafeHwnd());
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
{
::SetWindowLong(
hWnd,
GWL_EXSTYLE,
GetWindowLong(hWnd,GWL_EXSTYLE)^WS_EX_LAYERED);
// When bAlpha is 0, the window is completely transparent.
// When bAlpha is 255, the window is opaque.
::SetLayeredWindowAttributes(hWnd, RGB(0,0,0), 200, LWA_ALPHA);
}
BOOL CTestDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
ToggleTransparency(this->GetSafeHwnd());
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}