HyperLink.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // HyperLink.h : header file
  2. //
  3. //
  4. // HyperLink static control. Will open the default browser with the given URL
  5. // when the user clicks on the link.
  6. //
  7. // Copyright Chris Maunder, 1997, 1998
  8. // Feel free to use and distribute. May not be sold for profit.
  9. #if !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_)
  10. #define AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_
  11. #if _MSC_VER >= 1000
  12. #pragma once
  13. #endif // _MSC_VER >= 1000
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CHyperLink window
  16. class CHyperLink : public CStatic
  17. {
  18. // Construction/destruction
  19. public:
  20. CHyperLink();
  21. virtual ~CHyperLink();
  22. // Attributes
  23. public:
  24. // Operations
  25. public:
  26. void SetURL(CString strURL);
  27. CString GetURL() const;
  28. void SetColours(COLORREF crLinkColour, COLORREF crVisitedColour,
  29. COLORREF crHoverColour = -1);
  30. COLORREF GetLinkColour() const;
  31. COLORREF GetVisitedColour() const;
  32. COLORREF GetHoverColour() const;
  33. void SetVisited(BOOL bVisited = TRUE);
  34. BOOL GetVisited() const;
  35. void SetLinkCursor(HCURSOR hCursor);
  36. HCURSOR GetLinkCursor() const;
  37. void SetUnderline(BOOL bUnderline = TRUE);
  38. BOOL GetUnderline() const;
  39. void SetAutoSize(BOOL bAutoSize = TRUE);
  40. BOOL GetAutoSize() const;
  41. // Overrides
  42. // ClassWizard generated virtual function overrides
  43. //{{AFX_VIRTUAL(CHyperLink)
  44. public:
  45. virtual BOOL PreTranslateMessage(MSG* pMsg);
  46. protected:
  47. virtual void PreSubclassWindow();
  48. //}}AFX_VIRTUAL
  49. // Implementation
  50. protected:
  51. HINSTANCE GotoURL(LPCTSTR url, int showcmd);
  52. void ReportError(int nError);
  53. LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
  54. void PositionWindow();
  55. void SetDefaultCursor();
  56. // Protected attributes
  57. protected:
  58. COLORREF m_crLinkColour, m_crVisitedColour; // Hyperlink colours
  59. COLORREF m_crHoverColour; // Hover colour
  60. BOOL m_bOverControl; // cursor over control?
  61. BOOL m_bVisited; // Has it been visited?
  62. BOOL m_bUnderline; // underline hyperlink?
  63. BOOL m_bAdjustToFit; // Adjust window size to fit text?
  64. CString m_strURL; // hyperlink URL
  65. CFont m_Font; // Underline font if necessary
  66. HCURSOR m_hLinkCursor; // Cursor for hyperlink
  67. CToolTipCtrl m_ToolTip; // The tooltip
  68. // Generated message map functions
  69. protected:
  70. //{{AFX_MSG(CHyperLink)
  71. afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
  72. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  73. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  74. //}}AFX_MSG
  75. afx_msg void OnClicked();
  76. DECLARE_MESSAGE_MAP()
  77. };
  78. /////////////////////////////////////////////////////////////////////////////
  79. //{{AFX_INSERT_LOCATION}}
  80. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  81. #endif // !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_)