-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDeskClock.h
104 lines (82 loc) · 3.38 KB
/
DeskClock.h
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include <windows.h>
#include <shlobj.h> // for IDeskband2, IObjectWithSite, IPesistStream, and IInputObject
#include <objidl.h>
#include <gdiplus.h>
using namespace Gdiplus;
#include <map>
#include <atlstr.h>
#include <atlwin.h>
using namespace std;
#include "resource.h"
class CDeskClock: public IDeskBand2,
public IPersistStream,
public IObjectWithSite,
public IInputObject
{
public:
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IOleWindow
STDMETHODIMP GetWindow(HWND *phwnd);
STDMETHODIMP ContextSensitiveHelp(BOOL);
// IDockingWindow
STDMETHODIMP ShowDW(BOOL fShow);
STDMETHODIMP CloseDW(DWORD);
STDMETHODIMP ResizeBorderDW(const RECT *, IUnknown *, BOOL);
// IDeskBand (needed for all deskbands)
STDMETHODIMP GetBandInfo(DWORD dwBandID, DWORD, DESKBANDINFO *pdbi);
// IDeskBand2 (needed for glass deskband)
STDMETHODIMP CanRenderComposited(BOOL *pfCanRenderComposited);
STDMETHODIMP SetCompositionState(BOOL fCompositionEnabled);
STDMETHODIMP GetCompositionState(BOOL *pfCompositionEnabled);
// IPersist
STDMETHODIMP GetClassID(CLSID *pclsid);
// IPersistStream
STDMETHODIMP IsDirty();
STDMETHODIMP Load(IStream *pStm);
STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty);
STDMETHODIMP GetSizeMax(ULARGE_INTEGER *pcbSize);
// IObjectWithSite
STDMETHODIMP SetSite(IUnknown *pUnkSite);
STDMETHODIMP GetSite(REFIID riid, void **ppv);
// IInputObject
STDMETHODIMP UIActivateIO(BOOL fActivate, MSG *);
STDMETHODIMP HasFocusIO();
STDMETHODIMP TranslateAcceleratorIO(MSG *);
CDeskClock();
protected:
~CDeskClock();
void SetTime(SYSTEMTIME* time);
void Draw(HDC dc, RECT rc);
void DrawBackground(HDC dc, RECT rc);
HANDLE m_clockThread;
DWORD m_clockThreadID;
bool m_running;
HINSTANCE m_hInstance;
CString m_installDir;
static DWORD WINAPI ClockThread(void* This);
void ClockTick(void);
static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void OnFocus(const BOOL fFocus);
void OnPaint(const HDC hdcIn);
private:
LONG m_cRef; // ref count of deskband
IInputObjectSite* m_pSite; // parent site that contains deskband
BOOL m_fHasFocus; // whether deskband window currently has focus
BOOL m_fIsDirty; // whether deskband setting has changed
BOOL m_fCompositionEnabled; // whether glass is currently enabled in deskband
DWORD m_dwBandID; // ID of deskband
HWND m_hwnd; // main window of deskband
HWND m_hwndParent; // parent window of deskband
Image* m_backgroundImage;
unsigned int m_width, m_height;
Point m_center;
int m_clockX, m_clockY;
unsigned int m_clockSize;
SYSTEMTIME m_currentTime;
GdiplusStartupInput m_gdiplusStartupInput;
ULONG_PTR m_gdiplusToken;
};