Skip to content

Commit d422b48

Browse files
committed
Updated About dialog with GPLv3 notice.
1 parent 41c6572 commit d422b48

11 files changed

+769
-7
lines changed

HyperlinkStatic.cpp

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// HyperlinkStatic.cpp : implementation file
2+
//
3+
4+
#include "stdafx.h"
5+
#include "HyperlinkStatic.h"
6+
7+
#ifdef _DEBUG
8+
#define new DEBUG_NEW
9+
#undef THIS_FILE
10+
static char THIS_FILE[] = __FILE__;
11+
#endif
12+
13+
/////////////////////////////////////////////////////////////////////////////
14+
// CHyperlinkStatic
15+
16+
CHyperlinkStatic::CHyperlinkStatic()
17+
{
18+
_strCaption = _strHyperlink = _T("");
19+
_bMouseInControl = _bCreateFont = _bGetCaptionSize = false;
20+
21+
_hHandCursor = ::LoadCursor(nullptr, IDC_HAND);
22+
_hArrowCursor = ::LoadCursor(nullptr, IDC_ARROW);
23+
}
24+
25+
CHyperlinkStatic::~CHyperlinkStatic()
26+
{
27+
}
28+
29+
BEGIN_MESSAGE_MAP(CHyperlinkStatic, CStatic)
30+
//{{AFX_MSG_MAP(CHyperlinkStatic)
31+
ON_WM_LBUTTONDOWN()
32+
ON_WM_PAINT()
33+
ON_WM_DESTROY()
34+
ON_WM_MOUSEMOVE()
35+
//}}AFX_MSG_MAP
36+
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
37+
END_MESSAGE_MAP()
38+
39+
/////////////////////////////////////////////////////////////////////////////
40+
// CHyperlinkStatic message handlers
41+
42+
void CHyperlinkStatic::SetHyperlink(CString strHyperlink)
43+
{
44+
_strHyperlink = strHyperlink;
45+
}
46+
47+
void CHyperlinkStatic::SetCaption(CString strCaption)
48+
{
49+
_strCaption = strCaption;
50+
_bGetCaptionSize = false;
51+
}
52+
53+
void CHyperlinkStatic::OnLButtonDown(UINT nFlags, CPoint point)
54+
{
55+
if ( _bGetCaptionSize == false )
56+
GetCaptionSize();
57+
if (InCaptionRange(point))
58+
ShellExecute(0, _T("open"), _strHyperlink, 0, 0, SW_SHOWNORMAL);
59+
CStatic::OnLButtonDown(nFlags, point);
60+
}
61+
62+
void CHyperlinkStatic::OnPaint()
63+
{
64+
if ( _bCreateFont == false )
65+
CreateFont();
66+
CPaintDC dc(this);
67+
CFont *pOldFont = (CFont*)dc.SelectObject(&_fontCaption);
68+
dc.SetBkMode(TRANSPARENT);
69+
dc.SetTextColor(RGB(0,0,255));
70+
dc.TextOut(0, 0, _strCaption);
71+
dc.SelectObject(pOldFont);
72+
}
73+
74+
void CHyperlinkStatic::OnDestroy()
75+
{
76+
CStatic::OnDestroy();
77+
_fontCaption.DeleteObject();
78+
}
79+
80+
void CHyperlinkStatic::PreSubclassWindow()
81+
{
82+
ModifyStyle(0, SS_NOTIFY, TRUE);
83+
GetWindowText(_strCaption);
84+
_bGetCaptionSize = false;
85+
CStatic::PreSubclassWindow();
86+
}
87+
88+
LRESULT CHyperlinkStatic::OnMouseLeave(WPARAM wParam, LPARAM lParam)
89+
{
90+
UNREFERENCED_PARAMETER(wParam);
91+
UNREFERENCED_PARAMETER(lParam);
92+
_bMouseInControl = false;
93+
::SetCursor(_hArrowCursor);
94+
return 0;
95+
}
96+
97+
void CHyperlinkStatic::OnMouseMove(UINT nFlags, CPoint point)
98+
{
99+
if ( _bMouseInControl == false ) {
100+
//Track the mouse leave event
101+
TRACKMOUSEEVENT tme;
102+
tme.cbSize = sizeof(tme);
103+
tme.hwndTrack = GetSafeHwnd();
104+
tme.dwFlags = TME_LEAVE;
105+
_TrackMouseEvent(&tme);
106+
_bMouseInControl = true;
107+
}
108+
else {
109+
if ( _bGetCaptionSize == false )
110+
GetCaptionSize();
111+
::SetCursor((InCaptionRange(point))?_hHandCursor:_hArrowCursor);
112+
}
113+
CStatic::OnMouseMove(nFlags, point);
114+
}
115+
116+
void CHyperlinkStatic::CreateFont()
117+
{
118+
CFont* pFontParent = GetParent()->GetFont();
119+
if ( pFontParent ) {
120+
LOGFONT lf;
121+
pFontParent->GetObject(sizeof(lf), &lf);
122+
lf.lfUnderline = TRUE;
123+
_fontCaption.CreateFontIndirect(&lf);
124+
_bCreateFont = true;
125+
}
126+
}
127+
128+
void CHyperlinkStatic::GetCaptionSize()
129+
{
130+
if (( _bGetCaptionSize == false ) && ( _bCreateFont )) {
131+
CClientDC dc(this);
132+
CFont *pOldFont = dc.SelectObject(&_fontCaption);
133+
_sizeCaption = dc.GetTextExtent(_strCaption);
134+
dc.SelectObject(pOldFont);
135+
_bGetCaptionSize = true;
136+
}
137+
}
138+
139+
bool CHyperlinkStatic::InCaptionRange(CPoint &point)
140+
{
141+
if ( _bGetCaptionSize == false )
142+
return false;
143+
return (( point.x >= 0 )&&( point.x < _sizeCaption.cx ) &&
144+
( point.y >= 0 )&&( point.y < _sizeCaption.cy ));
145+
}

HyperlinkStatic.h

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#if !defined(AFX_HYPERLINKSTATIC_H__32A71426_1315_407C_9D90_A484C5589D80__INCLUDED_)
2+
#define AFX_HYPERLINKSTATIC_H__32A71426_1315_407C_9D90_A484C5589D80__INCLUDED_
3+
4+
#if _MSC_VER > 1000
5+
#pragma once
6+
#endif // _MSC_VER > 1000
7+
8+
// HyperlinkStatic.h : header file
9+
//
10+
#ifndef IDC_HAND
11+
#define IDC_HAND MAKEINTRESOURCE(32649)
12+
#endif
13+
14+
/////////////////////////////////////////////////////////////////////////////
15+
// CHyperlinkStatic window
16+
17+
class CHyperlinkStatic : public CStatic
18+
{
19+
// Construction
20+
public:
21+
CHyperlinkStatic();
22+
23+
// Attributes
24+
public:
25+
26+
// Operations
27+
public:
28+
29+
// Overrides
30+
// ClassWizard generated virtual function overrides
31+
//{{AFX_VIRTUAL(CHyperlinkStatic)
32+
protected:
33+
virtual void PreSubclassWindow();
34+
//}}AFX_VIRTUAL
35+
36+
// Implementation
37+
public:
38+
virtual ~CHyperlinkStatic();
39+
40+
// Generated message map functions
41+
protected:
42+
//{{AFX_MSG(CHyperlinkStatic)
43+
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
44+
afx_msg void OnPaint();
45+
afx_msg void OnDestroy();
46+
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
47+
//}}AFX_MSG
48+
afx_msg LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
49+
DECLARE_MESSAGE_MAP()
50+
public:
51+
void SetHyperlink(CString strHyperlink);
52+
void SetCaption(CString strCaption);
53+
private:
54+
CString _strCaption, _strHyperlink;
55+
CFont _fontCaption;
56+
CSize _sizeCaption;
57+
bool _bCreateFont, _bMouseInControl, _bGetCaptionSize;
58+
HCURSOR _hHandCursor, _hArrowCursor;
59+
60+
void CreateFont();
61+
void GetCaptionSize();
62+
bool InCaptionRange(CPoint &point);
63+
};
64+
65+
/////////////////////////////////////////////////////////////////////////////
66+
67+
//{{AFX_INSERT_LOCATION}}
68+
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
69+
70+
#endif // !defined(AFX_HYPERLINKSTATIC_H__32A71426_1315_407C_9D90_A484C5589D80__INCLUDED_)

Resource.h

368 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)