16,472
社区成员
发帖
与我相关
我的任务
分享
typedef BOOL (CALLBACK* SETLAYEREDWINDOWATTRIBUTES)(HWND, COLORREF, BYTE,
DWORD);
// then update the initdialog to make the dialog transparent
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// add this code into this section somewhere
// make it possible to be transparent
SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE)
| WS_EX_LAYERED);
// then make it transparent
SETLAYEREDWINDOWATTRIBUTES pLayered; // function pointer
HMODULE hDll;
hDll = LoadLibrary( "user32.dll" );
pLayered = (SETLAYEREDWINDOWATTRIBUTES)GetProcAddress (hDll,
"SetLayeredWindowAttributes");
BOOL bResult = pLayered ((HWND) m_hWnd,
(COLORREF) (RGB(236,233,216)), // insert the
colour to be made transparent here
(BYTE) 200,
(DWORD) (LWA_COLORKEY|LWA_ALPHA));
FreeLibrary( hDll );
// and to make it topmost
SetWindowPos (&CWnd::wndTopMost,0, 0, 0, 0,
SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
}