设置窗口透明化(VC)

来源:互联网 发布:网络推广的各种渠道 编辑:程序博客网 时间:2024/06/10 16:05

 

 

BOOL CTest::OnInitDialog() 

{

CDialog::OnInitDialog();

//设置窗口扩展风格

SetWindowLong(GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(GetSafeHwnd(),GWL_EXSTYLE)|0x80000);

typedef BOOL (WINAPI *FSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);

 

FSetLayeredWindowAttributes SetLayeredWindowAttributes ;

 

HINSTANCE hInst = LoadLibrary("User32.DLL");

 

SetLayeredWindowAttributes = (FSetLayeredWindowAttributes)GetProcAddress(hInst,"SetLayeredWindowAttributes");

 

if (SetLayeredWindowAttributes)

SetLayeredWindowAttributes(GetSafeHwnd(),RGB(0,0,0),238,2);

FreeLibrary(hInst);

 

return TRUE;  // return TRUE unless you set the focus to a control

                  // EXCEPTION: OCX Property Pages should return FALSE

}