Mercurial > vba-linux
comparison src/win32/Hyperlink.cpp @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 // Hyperlink.cpp : implementation file | |
2 // | |
3 | |
4 #include "stdafx.h" | |
5 #include "Hyperlink.h" | |
6 | |
7 ///////////////////////////////////////////////////////////////////////////// | |
8 // Hyperlink | |
9 | |
10 Hyperlink::Hyperlink() | |
11 { | |
12 m_over = false; | |
13 } | |
14 | |
15 Hyperlink::~Hyperlink() | |
16 { | |
17 m_underlineFont.DeleteObject(); | |
18 } | |
19 | |
20 | |
21 BEGIN_MESSAGE_MAP(Hyperlink, CStatic) | |
22 //{{AFX_MSG_MAP(Hyperlink) | |
23 ON_WM_CTLCOLOR_REFLECT() | |
24 ON_WM_ERASEBKGND() | |
25 ON_WM_MOUSEMOVE() | |
26 //}}AFX_MSG_MAP | |
27 ON_CONTROL_REFLECT(STN_CLICKED, OnClicked) | |
28 END_MESSAGE_MAP() | |
29 | |
30 ///////////////////////////////////////////////////////////////////////////// | |
31 // Hyperlink message handlers | |
32 | |
33 void Hyperlink::PreSubclassWindow() | |
34 { | |
35 DWORD dwStyle = GetStyle(); | |
36 ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY); | |
37 | |
38 // 32649 is the hand cursor | |
39 m_cursor = LoadCursor(NULL, MAKEINTRESOURCE(32649)); | |
40 | |
41 CFont *font = GetFont(); | |
42 | |
43 LOGFONT lg; | |
44 font->GetLogFont(&lg); | |
45 | |
46 lg.lfUnderline = TRUE; | |
47 | |
48 m_underlineFont.CreateFontIndirect(&lg); | |
49 SetFont(&m_underlineFont); | |
50 | |
51 CStatic::PreSubclassWindow(); | |
52 } | |
53 | |
54 void Hyperlink::OnClicked() | |
55 { | |
56 CString url; | |
57 GetWindowText(url); | |
58 ::ShellExecute(0, _T("open"), url, | |
59 0, 0, SW_SHOWNORMAL); | |
60 } | |
61 | |
62 HBRUSH Hyperlink::CtlColor(CDC* pDC, UINT nCtlColor) | |
63 { | |
64 pDC->SetTextColor(RGB(0,0,240)); | |
65 | |
66 return (HBRUSH)GetStockObject(NULL_BRUSH); | |
67 } | |
68 | |
69 BOOL Hyperlink::OnEraseBkgnd(CDC* pDC) | |
70 { | |
71 CRect rect; | |
72 GetClientRect(rect); | |
73 pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE)); | |
74 | |
75 return TRUE; | |
76 } | |
77 | |
78 void Hyperlink::OnMouseMove(UINT nFlags, CPoint point) | |
79 { | |
80 if(!m_over) { | |
81 m_over = true; | |
82 SetCapture(); | |
83 ::SetCursor(m_cursor); | |
84 } else { | |
85 CRect r; | |
86 GetClientRect(&r); | |
87 | |
88 if(!r.PtInRect(point)) { | |
89 m_over = false; | |
90 ReleaseCapture(); | |
91 } | |
92 } | |
93 } |