forked from paulhoad/gp2trackeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHyperLinkButton.cpp
More file actions
executable file
·94 lines (77 loc) · 2 KB
/
Copy pathHyperLinkButton.cpp
File metadata and controls
executable file
·94 lines (77 loc) · 2 KB
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
// HyperLinkButton.cpp : implementation file
//
#include "stdafx.h"
#include "HyperLinkButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHyperLinkButton
CHyperLinkButton::CHyperLinkButton()
{
m_Over = false;
m_OverColor = RGB(0, 0, 0xFF);
m_NotOverColor = RGB(0, 0, 0x90);
}
CHyperLinkButton::~CHyperLinkButton() {}
BEGIN_MESSAGE_MAP(CHyperLinkButton, CButton)
//{{AFX_MSG_MAP(CHyperLinkButton)
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHyperLinkButton message handlers
void CHyperLinkButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rcItem(lpDrawItemStruct->rcItem);
if (m_Over)
pDC->SetTextColor(m_OverColor);
else
pDC->SetTextColor(m_NotOverColor);
CString str;
GetWindowText(str);
pDC->TextOut(0, 0, str);
}
void CHyperLinkButton::OnLButtonUp(UINT nFlags, CPoint point)
{
CString str;
GetWindowText(str);
HINSTANCE h = ShellExecute(NULL, (LPCTSTR) "open", (LPCSTR)str, NULL, NULL, SW_SHOWNORMAL);
if ((UINT)h > 32) {
// visited
} else {
MessageBeep(0);// unable to execute file!
}
CButton::OnLButtonUp(nFlags, point);
}
void CHyperLinkButton::OnMouseMove(UINT nFlags, CPoint point)
{
CRect rect;
GetClientRect(rect);
if (!rect.PtInRect(point)) {
if (m_Over) {
ReleaseCapture();
m_Over = false;
InvalidateRect(NULL);
}
} else {
if (!m_Over) {
SetCapture();
m_Over = true;
InvalidateRect(NULL);
}
}
CButton::OnMouseMove(nFlags, point);
}
void CHyperLinkButton::SetOverColor(COLORREF colour)
{
m_OverColor = colour;
}
void CHyperLinkButton::SetNormalColour(COLORREF colour)
{
m_NotOverColor = colour;
}