-
Notifications
You must be signed in to change notification settings - Fork 1
/
HyperLink.h
157 lines (121 loc) · 4.37 KB
/
HyperLink.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#pragma once
// CHyperLink
class CHyperLink : public CStatic
{
DECLARE_DYNAMIC(CHyperLink)
private:
TCHAR* m_lpLinkText;
TCHAR* m_lpLinkUrl;
BOOL m_bUnderlineAlways;
BOOL m_bIsLink;
BOOL m_bLockInPosition;
BOOL m_bMultiline;
CFont m_hFont;
COLORREF m_crLinkUp;
COLORREF m_crLinkHover;
COLORREF m_crLinkDown;
//BackGround color
COLORREF m_crBackGround;
COLORREF m_crBorder;
int m_nBorderSize;
int m_nBorderStyle;
HCURSOR m_hReg;
HCURSOR m_hHand;
HICON m_hIconUp;
HICON m_hIconHover;
HICON m_hIconDown;
HICON m_hIconDisabled;
UINT m_uShowIcon;
BOOL m_bAutoGenerateDisabled;
BOOL m_bAutoGenerated;
enum {
SI_ICONUP_ON = 0x0001, //Show icon when mouse Up (normal)
SI_ICONUP_LEFT = 0x0002, //Show icon when mouse up on the left
SI_ICONUP_RIGHT = 0x0004, //Show icon when mouse up on the right
//
SI_ICONHOVER_ON = 0x0010, //Show icon when mouse hover
SI_ICONHOVER_LEFT = 0x0020, //Show icon when mouse hover on the left
SI_ICONHOVER_RIGHT = 0x0040, //Show icon when mouse hover on the right
//
SI_ICONDOWN_ON = 0x0100, //Show icon when mouse down
SI_ICONDOWN_LEFT = 0x0200, //Show icon when mouse down on the left
SI_ICONDOWN_RIGHT = 0x0400, //Show icon when mouse down on the right
//
SI_ICONDISABLED_ON = 0x1000, //Show icon when hyperlink is disabled
SI_ICONDISABLED_LEFT = 0x2000, //Show icon when hyperlink is disabled on the left
SI_ICONDISABLED_RIGHT = 0x4000 //Show icon when hyperlink is disabled on the right
};
CToolTipCtrl m_ToolTip;
CToolTipCtrl* m_pToolTip;
private:
//Status and Mouse control variables
BOOL m_bDisabled;
BOOL m_bMouseIn;
BOOL m_bMouseDown;
BOOL m_bMovingWindow;
RECT m_rcCapture;
COLORREF m_dwszGrayScalePalette[256];
private:
void Initialize();
int OpenUrl();
SIZE GetBiggestIcon();
SIZE GetFirstIcon();
void CreatePalette();
HICON CreateGrayscaleIcon(HICON hIcon);
public:
TCHAR* GetLinkText();
void SetLinkText(TCHAR* lpText);
TCHAR* GetLinkUrl();
void SetLinkUrl(TCHAR* lpUrl);
void LockInPosition(BOOL bLockInPosition = FALSE);
BOOL IsMultiline() { return m_bMultiline; }
void SetMultiline(BOOL bMultiline);
void IsLink(BOOL bIsLink = TRUE);
void UnderlineAlways(BOOL bUnderlineAlways = FALSE);
COLORREF GetUpColor() { return m_crLinkUp; }
COLORREF GetHoverColor() { return m_crLinkHover; }
COLORREF GetDownColor() { return m_crLinkDown; }
COLORREF GetBackgroundColor() { return m_crBackGround; }
void SetColors(COLORREF crLinkUp, COLORREF crLinkHover, COLORREF crLinkDown, COLORREF crBackGround = ::GetSysColor(COLOR_BTNFACE));
void SetBackgroundColor(COLORREF crBackGround = ::GetSysColor(COLOR_BTNFACE));
COLORREF GetBorderColor() { return m_crBorder; }
void SetBorderColor(COLORREF crBorder = RGB(0,0,0));
int GetBorderSize() { return m_nBorderSize; }
void SetBorderSize(int nSize);
int GetBorderStyle() { return m_nBorderStyle; }
void SetBorderStyle(int nStyle);
UINT GetShowIconsOpt() { return m_uShowIcon; }
void SetIcons(HICON hIconUp, HICON hIconHover, HICON hIconDown, UINT uShowIcons, HICON hIconDisabled = NULL);
void SetIconUp(int nIconUp, int dx = 0, int dy = 0);
void SetIconHover(int nIconHover, int dx = 0, int dy = 0);
void SetIconDown(int nIconDown, int dx = 0, int dy = 0);
void SetIconDisabled(int nIconDisabled, int dx = 0, int dy = 0);
void SetShowIcons(UINT uShowIcons);
BOOL GetAutoGenerateDisabled() { return m_bAutoGenerateDisabled; }
void SetAutoGenerateDisabled(BOOL bAutoGenerate);
BOOL SetFont(TCHAR* lpFaceName = L"MS Shell Dlg", int nSize = 14, int nWeight = FW_NORMAL, BOOL bItalic = FALSE);
BOOL SetFont(const LPLOGFONT lpFont);
void Disable(BOOL bDisable = FALSE);
CToolTipCtrl* GetTooltip();
void SetTooltip(CToolTipCtrl* pToolTip);
public:
CHyperLink();
virtual ~CHyperLink();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnPaint();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
LRESULT OnMouseLeave(WPARAM, LPARAM);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnCaptureChanged(CWnd* pWnd);
afx_msg void OnTimer(UINT_PTR nIDEvent);
protected:
virtual void PreSubclassWindow();
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};