使視窗透明

2021-05-01 10:44:55 字數 1181 閱讀 6692

#define lwa_colorkey 0x00000001  // use color as the transparency color.

#define ws_ex_layered 0x00080000

#define lwa_alpha 2   // use balpha to determine the opacity of the layer

typedef bool (winapi *lpfnsetlayeredwindowattributes)(hwnd hwnd, colorref crkey, byte balpha, dword dwflags);

lpfnsetlayeredwindowattributes mysetlayeredwindowattributes;

視窗半透明

hmodule huser32 = getmodulehandle("user32.dll");

mysetlayeredwindowattributes = (lpfnsetlayeredwindowattributes)getprocaddress(huser32,"setlayeredwindowattributes");

if(mysetlayeredwindowattributes == null)

::setwindowlong(getsafehwnd(), gwl_exstyle, getwindowlong(getsafehwnd(), gwl_exstyle) ^ ws_ex_layered);

mysetlayeredwindowattributes(getsafehwnd(), 0,

130, //這個引數是控制視窗透明的層度, 為0時視窗全透明,包括標題欄. 為255時,不透明

lwa_alpha);//lwa_colorkey

freelibrary(huser32);

使對話方塊視窗的客戶區全透明

colorref maskcolor= 14215660; 這是顏色掩碼,與這個顏色相同的將不被顯示出來

setwindowlong(getsafehwnd(), gwl_exstyle, getwindowlong(getsafehwnd(), gwl_exstyle) | ws_ex_layered);

mysetlayeredwindowattributes(getsafehwnd(), maskcolor, 10, lwa_colorkey);

directx 透明視窗

第一步 新增類class cuimagedc hbitmap getbmphandle void dword getbits void protected hbitmap m hbmp hdc m hdc char m pbits cuimagedc cuimagedc cuimagedc cuim...

透明框架視窗

如何讓整個視窗具有透明效果呢?使用如下的類 class clayeredimpl layered window template class atl no vtable clayeredimpl virtual clayeredimpl long setlayeredstyle bool setla...

超酷透明視窗

本文分析了windows環境下使用mfc實現透明視窗,以及浮動視窗的方法 win2000以上作業系統,vc 6.0。如何實現透明視窗 setlayeredwindowattributes的函式原型如下 bool setlayeredwindowattributes hwnd hwnd,handle ...