Mercurial > vba-clojure
view src/win32/Hyperlink.cpp @ 8:08a8e09ca414
add files required by automake
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:54:39 -0600 |
parents | f9f4f1b99eed |
children |
line wrap: on
line source
1 // Hyperlink.cpp : implementation file2 //4 #include "stdafx.h"5 #include "Hyperlink.h"7 /////////////////////////////////////////////////////////////////////////////8 // Hyperlink10 Hyperlink::Hyperlink()11 {12 m_over = false;13 }15 Hyperlink::~Hyperlink()16 {17 m_underlineFont.DeleteObject();18 }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_MAP27 ON_CONTROL_REFLECT(STN_CLICKED, OnClicked)28 END_MESSAGE_MAP()30 /////////////////////////////////////////////////////////////////////////////31 // Hyperlink message handlers33 void Hyperlink::PreSubclassWindow()34 {35 DWORD dwStyle = GetStyle();36 ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);38 // 32649 is the hand cursor39 m_cursor = LoadCursor(NULL, MAKEINTRESOURCE(32649));41 CFont *font = GetFont();43 LOGFONT lg;44 font->GetLogFont(&lg);46 lg.lfUnderline = TRUE;48 m_underlineFont.CreateFontIndirect(&lg);49 SetFont(&m_underlineFont);51 CStatic::PreSubclassWindow();52 }54 void Hyperlink::OnClicked()55 {56 CString url;57 GetWindowText(url);58 ::ShellExecute(0, _T("open"), url,59 0, 0, SW_SHOWNORMAL);60 }62 HBRUSH Hyperlink::CtlColor(CDC* pDC, UINT nCtlColor)63 {64 pDC->SetTextColor(RGB(0,0,240));66 return (HBRUSH)GetStockObject(NULL_BRUSH);67 }69 BOOL Hyperlink::OnEraseBkgnd(CDC* pDC)70 {71 CRect rect;72 GetClientRect(rect);73 pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE));75 return TRUE;76 }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);88 if(!r.PtInRect(point)) {89 m_over = false;90 ReleaseCapture();91 }92 }93 }