Basic Programming/Winows API
Win API - 투명한 윈도우 만들기
Stayner
2017. 4. 19. 13:49
728x90
Windows API 중에 SetLayeredWindowAttributes()를 이용하여 윈도우를 투명하게 바꿀 수 있다.
// make it transparent
long l = GetWindowLong(m_hWnd, WL_EXSTYLE);
l |= WS_EX_LAYERED;
SetWindowLong(m_hWnd, GWL_EXSTYLE, l);
SetLayeredWindowAttributes(m_hWnd, 0, nOpacity, LWA_ALPHA);
이 API를 이용하면, 프레임 드랍이 굉장히 심하다...
그래서 구글에서 검색해본 결과, Windows의 Aero 기능을 활용하는 방법이 있었다.
DWM(Desktop Window Manager)가 실행되어 있어야하므로, 프로세스에 dwm.exe가 실행되어 있어야 한다.
// Set margins, extending the bottom margin
MARGINS margins = { -1, -1, -1, -1 };
int val = 0; // 2;
hr = DwmSetWindowAttribute(m_hWnd, 2, &val, 4);
// Extend frame on the bottom of client area
hr = DwmExtendFrameIntoClientArea(m_hWnd, &margins);
위의 코드를 활용한다면, Aero 기능을 활용하기 때문에 SetLayeredWindowAttributes() 보다는 쓸만 했다.
728x90