Border 스타일이 None인 다이얼로그 윈도우(No Frame)에서 아래 코드로 그림자를 추가할 수 있다.
typedef HRESULT (WINAPI *lpfnDwmSetWindowAttribute)(HWND hWnd, DWORD dwAttribute, _In_ LPCVOID pvAttribute, DWORD cbAttribute); typedef HRESULT (WINAPI *lpfnDwmExtendFrameIntoClientArea)(HWND hWnd, _In_ const MARGINS *pMarInset); lpfnDwmSetWindowAttribute DwmSetWindowAttribute = 0; lpfnDwmExtendFrameIntoClientArea DwmExtendFrameIntoClientArea = 0; HRESULT DwmDropShadow(HWND hWnd) { int attr = 2; HRESULT hr = S_OK; DwmSetWindowAttribute = (lpfnDwmSetWindowAttribute)GetProcAddress(GetModuleHandle(_T("dwmapi.dll")), "DwmSetWindowAttribute"); DwmExtendFrameIntoClientArea = (lpfnDwmExtendFrameIntoClientArea)GetProcAddress(GetModuleHandle(_T("dwmapi.dll")), "DwmExtendFrameIntoClientArea"); if (DwmSetWindowAttribute == 0 || DwmExtendFrameIntoClientArea == 0) return S_FALSE; hr = DwmSetWindowAttribute(hWnd, 2, &attr, sizeof(int)); if (SUCCEEDED(hr)) { MARGINS margins = {-1, -1, -1 , -1}; hr = DwmExtendFrameIntoClientArea(hWnd, &margins); return hr; } return hr; }
Before
[PNG image (31.41 KB)]
After
[PNG image (50.42 KB)]
Desktop Window Manager (DWM)
DwmDropShadow
UI
Retrieved from http://hyacinth.byus.net/moniwiki/wiki.php/C++/DwmDropShadow
last modified 2014-11-24 19:21:52