1、創(chuàng)建一個(gè)基于對(duì)話框的MFC EXE
2、在對(duì)話框的 OnInitDialog 函數(shù) 中,設(shè)置對(duì)話框擴(kuò)展屬性 為:WS_EX_LAYERED
const WS_EX_LAYERED = 0x80000;
::SetWindowLong(GetSafeHwnd(),GWL_EXSTYLE,
GetWindowLong(GetSafeHwnd(),GWL_EXSTYLE)|WS_EX_LAYERED);
3、在對(duì)話框的 OnInitDialog 函數(shù) 中,設(shè)置對(duì)話框透明
HINSTANCE hInst;
const LWA_COLORKEY = 0x00001;
const LWA_ALPHA = 0x00002;
typedef BOOL (WINAPI *FSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
FSetLayeredWindowAttributes SetLayeredWindowAttributes;
hInst = LoadLibrary("User32.dll");
SetLayeredWindowAttributes = (FSetLayeredWindowAttributes)
GetProcAddress(hInst,"SetLayeredWindowAttributes");
SetLayeredWindowAttributes(GetSafeHwnd(),RGB(0,0,0),150,LWA_ALPHA);
FreeLibrary(hInst);
聯(lián)系客服