視窗啟動 透明等處理

2021-09-30 09:28:08 字數 1696 閱讀 6135

視窗的動畫效果其實我們只要會用乙個windows的api就可以了,下面我來介紹一下這個api

函式原型:

bool animatewindow(hwnd hwnd,dword dwtime,dword dwflags)

函式功能:

能在視窗開啟或者隱藏時產生動畫效果。

引數含義:

hwnd:指定產生動畫效果的視窗控制代碼。

dwtime:指明動畫持續時間(以毫秒計算),動畫的標準時間應該為200毫秒。

dwflags:指定動畫型別。這個引數可以是乙個或者多個標誌的組合。以下是該引數的取值:

aw_slide:使用滑動型別。預設則為滾動型別。當使用aw_center標誌時,這個標誌被忽略。

aw_activate:啟用視窗。在使用了aw_hide標誌後不能使用這個標誌。

aw_blend:實現淡出效果。只有當hwnd為頂層視窗的時候才可以使用此標誌。

aw_hide:隱藏視窗,預設則為顯示視窗。

aw_center:若使用了aw_hide標誌,則使視窗向內重疊,即收縮視窗;若未使用aw_hide標誌,則使視窗向外擴充套件,即展開視窗;

aw_hor_positive:自左向右顯示視窗。該標誌可以在滾動動畫和滑動動畫中使用。當使用aw_center標誌時,該標誌被忽略;

aw_ver_positive:自頂向下顯示視窗。該標誌可以在滾動動畫和滑動動畫中使用。當使用aw_center標誌時,該標誌被忽略;

aw_ver_negative:自下向上顯示視窗。該標誌可以在滾動動畫和滑動動畫中使用。當使用aw_center標誌時,該標誌被忽略;

如果函式呼叫成功,則返回非零值,否則返回值為零。

在單文件中

/

// cmainframe message handlers

int cmainframe::oncreate(lpcreatestruct lpcreatestruct)

void cmainframe::onclose()

在對話方塊中 需要去掉 控制代碼即可

bool winapi drawanimatedrects(hwnd hwnd, int idani, const rect * lprcfrom, const rect * lprcto);

eg:

bool m_bshow = false;  //區分彈出還是彈入    

bool winanimation()

bool callback my_find(hwnd hwnd, lparam lparam)

//尋找托盤位置

// 當找到時鐘視窗時表示可以結束了

if (_tcscmp(szclassname, _t("trayclockwclass")) == 0)

return true;

}

設定透明

setwindowlong(this->getsafehwnd(),gwl_exstyle,

getwindowlong(this->getsafehwnd(),gwl_exstyle)^0x80000);

hinstance hinst = loadlibrary(l"user32.dll");

if(hinst)

使視窗透明

define lwa colorkey 0x00000001 use color as the transparency color.define ws ex layered 0x00080000 define lwa alpha 2 use balpha to determine the opac...

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...