summaryrefslogtreecommitdiff
path: root/plugins/!Deprecated/W7UI/src/dwmwindow.h
blob: e795823247d6339d6b5b89e4b5b632e636321144 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef dwmwindow_h__
#define dwmwindow_h__

class CDwmWindow
{
public:
	CDwmWindow();
	virtual ~CDwmWindow() {}

	HWND hwnd() { return m_hwnd; }

	template<class TWindow>
	static TWindow *GetWindow(HWND hwnd)
	{
		return (TWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
	}

protected:
	// events
	virtual void OnActivate(HWND hwndFrom) {}
	virtual void OnClose() {}
	virtual void OnRenderThumbnail(int mzxWidth, int maxHeight) {}
	virtual void OnRenderPreview() {}
	virtual void OnTimer(int id) {}
	virtual void OnToolbar(int id, INT_PTR data) {}

	// timer stuff
	void SetTimer(int id, int timeout);
	void KillTimer(int id);

	// manage thumbnail and aero peek
	void InvalidateThumbnail();
	void SetPreview(HBITMAP hbmp, int x, int y);
	void SetThumbnail(HBITMAP hbmp);

	// manage toolbar
	bool AddButton(HICON hIcon, TCHAR *text, INT_PTR data, DWORD flags = THBF_ENABLED);
	void UpdateButtons(ITaskbarList3 *p);

	//utilities
	static HBITMAP CreateDwmBitmap(int width, int height);
	static void MakeBitmapOpaque(HBITMAP hBmp);
	static void DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1);

private:
	HWND m_hwnd;

	bool m_btnInitialized;
	int m_btnCount;
	THUMBBUTTON m_btnInfo[7];
	INT_PTR m_btnData[7];

	LRESULT CALLBACK WndProc(UINT msg, WPARAM wParam, LPARAM lParam);

	static void GlobalInitWndClass();
	static LRESULT CALLBACK GlobalWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
};

#endif // dwmwindow_h__