본문 바로가기

Windows/MFC

반투명 윈도우 그리기

정말 저도 헤멨던 거라서, 이렇게 다른분께 도움이 되시라고 올립니다.
Windows2000에서 지원되고, MSDN홈페이지에서 새로운 SDK를 다운 받으시면
될것입니다.

먼저 필요한 상수들을 정의 하시고,
[code]
#define WS_EX_LAYERED         0x00080000
#define LWA_COLORKEY            0x00000001
#define LWA_ALPHA             0x00000002
#define ULW_COLORKEY            0x00000001
#define ULW_ALPHA             0x00000002
#define ULW_OPAQUE             0x00000004
[/code]

타입선언,

[code]
typedef BOOL(WINAPI *SLWA)(HWND, COLORREF, BYTE, DWORD);
[/code]

그리고 OnInitDialog()정도에서 아래의 함수를 기술합니다.
[code]
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 * 70) / 100, LWA_ALPHA);
[/code]

하시면, 멋진 반투명 레이어를 만드실 수 있습니다.
좋은 프로그래밍들 하세요.
-----------------------------------------
[code]
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
);[/code]

Requirements
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib

'Windows > MFC' 카테고리의 다른 글

메인 윈도우 타이틀을 변경 (Change Title)  (0) 2013.10.02
파일명 반환(return filename)  (0) 2013.10.02
상태바에 그림 출력  (0) 2013.10.02
자간 조절 하기  (0) 2013.10.02
포맷 format 하기  (0) 2013.10.02