다이얼로그 투명하게..
C++ 2007. 10. 4. 11:29 |BOOL SetLayeredWindowAttributes(
HWND hwnd, // handle to the layered window
COLORREF crKey, // specifies the color key
BYTE bAlpha, // value for the blend function
DWORD dwFlags // action
);
typedef SLWA
선언:
typedef BOOL (WINAPI* SLWA)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
#ifndef WS_EX_LAYERED
#define WS_EX_LAYERED 0x00080000
#define LWA_ALPHA 0x00000002
#endif
코딩:
void CDlgTestDlg::SetTransparency(HWND hwnd, int percent)
{
SLWA pSetLayeredWindowAttributes = NULL; // 함수포인터 선언, 초기화.
HINSTANCE hmodUSER32 = LoadLibrary("USER32.DLL"); // 인스턴스 얻음.
pSetLayeredWindowAttributes=(SLWA)GetProcAddress(hmodUSER32,"SetLayeredWindowAttributes");
//함수포인터 얻음.
// HWND hwnd = this->m_hWnd; //다이얼로그의 핸들 얻음.
SetWindowLong(hwnd, GWL_EXSTYLE,GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
pSetLayeredWindowAttributes(hwnd, 0, (255 * percent) / 100, LWA_ALPHA);
}