-
Notifications
You must be signed in to change notification settings - Fork 16
/
windoweffect.cpp
46 lines (39 loc) · 1008 Bytes
/
windoweffect.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "stdafx.h"
#include "windoweffect.h"
#include <dwmapi.h>
namespace WindowEffect
{
void moveWindow(HWND hWnd)
{
ReleaseCapture();
SendMessage(hWnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
void addShadowEffect(HWND hWnd)
{
DWMNCRENDERINGPOLICY ncrp = DWMNCRP_ENABLED;
::DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp));
MARGINS margins = { -1 };
::DwmExtendFrameIntoClientArea(hWnd, &margins);
}
void removeShadowEffect(HWND hWnd)
{
DWMNCRENDERINGPOLICY ncrp = DWMNCRP_DISABLED;
::DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp));
}
void removeMenuShadowEffect(HWND hWnd)
{
DWORD style = GetClassLong(hWnd, GCL_STYLE);
style &= ~0x00020000; // CS_DROPSHADOW;
SetClassLong(hWnd, GCL_STYLE, style);
}
void addWindowAnimation(HWND hWnd)
{
DWORD style = GetWindowLong(hWnd, GWL_STYLE);
SetWindowLong(hWnd, GWL_STYLE, style
| WS_MAXIMIZEBOX
| WS_CAPTION
| CS_DBLCLKS
| WS_THICKFRAME
);
}
}