HyperLink.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-1999 (cmaunder@mail.com)
  8. // Feel free to use and distribute. May not be sold for profit.
  9. // 2/29/00 -- P. Shaffer standard font mod.
  10. #if !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_)
  11. #define AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_
  12. #if _MSC_VER >= 1000
  13. #pragma once
  14. #endif // _MSC_VER >= 1000
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CHyperLink window
  17. class CHyperLink : public CStatic
  18. {
  19. // Construction/destruction
  20. public:
  21. CHyperLink();
  22. virtual ~CHyperLink();
  23. public:
  24. enum UnderLineOptions { ulHover = -1, ulNone = 0, ulAlways = 1};
  25. // Attributes
  26. public:
  27. void SetURL(CString strURL);
  28. CString GetURL() const;
  29. void SetColours(COLORREF crLinkColour, COLORREF crVisitedColour,
  30. COLORREF crHoverColour = -1);
  31. COLORREF GetLinkColour() const;
  32. COLORREF GetVisitedColour() const;
  33. COLORREF GetHoverColour() const;
  34. void SetVisited(BOOL bVisited = TRUE);
  35. BOOL GetVisited() const;
  36. void SetLinkCursor(HCURSOR hCursor);
  37. HCURSOR GetLinkCursor() const;
  38. void SetUnderline(int nUnderline = ulHover);
  39. int GetUnderline() const;
  40. void SetAutoSize(BOOL bAutoSize = TRUE);
  41. BOOL GetAutoSize() const;
  42. // Overrides
  43. // ClassWizard generated virtual function overrides
  44. //{{AFX_VIRTUAL(CHyperLink)
  45. public:
  46. virtual BOOL PreTranslateMessage(MSG* pMsg);
  47. virtual BOOL DestroyWindow();
  48. protected:
  49. virtual void PreSubclassWindow();
  50. //}}AFX_VIRTUAL
  51. // Implementation
  52. protected:
  53. HINSTANCE GotoURL(LPCTSTR url, int showcmd);
  54. void ReportError(int nError);
  55. LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
  56. void PositionWindow();
  57. void SetDefaultCursor();
  58. // Protected attributes
  59. protected:
  60. COLORREF m_crLinkColour, m_crVisitedColour; // Hyperlink colours
  61. COLORREF m_crHoverColour; // Hover colour
  62. BOOL m_bOverControl; // cursor over control?
  63. BOOL m_bVisited; // Has it been visited?
  64. int m_nUnderline; // underline hyperlink?
  65. BOOL m_bAdjustToFit; // Adjust window size to fit text?
  66. CString m_strURL; // hyperlink URL
  67. CFont m_UnderlineFont; // Font for underline display
  68. CFont m_StdFont; // Standard font
  69. HCURSOR m_hLinkCursor; // Cursor for hyperlink
  70. CToolTipCtrl m_ToolTip; // The tooltip
  71. UINT m_nTimerID;
  72. // Generated message map functions
  73. protected:
  74. //{{AFX_MSG(CHyperLink)
  75. afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
  76. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  77. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  78. afx_msg void OnTimer(UINT nIDEvent);
  79. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  80. //}}AFX_MSG
  81. afx_msg void OnClicked();
  82. DECLARE_MESSAGE_MAP()
  83. };
  84. /////////////////////////////////////////////////////////////////////////////
  85. //{{AFX_INSERT_LOCATION}}
  86. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  87. #endif // !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_)