/***********************************************************************/ /* Copyright (C) 2002 Definitive Solutions, Inc. All Rights Reserved. */ /* THIS COMPUTER PROGRAM IS PROPRIETARY AND CONFIDENTIAL TO DEFINITIVE */ /* SOLUTIONS, INC. AND ITS LICENSORS AND CONTAINS TRADE SECRETS OF */ /* DEFINITIVE SOLUTIONS, INC. THAT ARE PROVIDED PURSUANT TO A WRITTEN */ /* AGREEMENT CONTAINING RESTRICTIONS ON USE AND DISCLOSURE. ANY USE, */ /* REPRODUCTION, OR TRANSFER EXCEPT AS PROVIDED IN SUCH AGREEMENT */ /* IS STRICTLY PROHIBITED. */ /***********************************************************************/ ///////////////////////////////////////////////////////////////////////////// // How to add this class to your application. // // Add MyHyperlink.cpp, MyHyperlink.h, MyHyperlinkResource.h, MyHyperlink.rc2, // MyHyperlink.cur, and MyHyperlink.bmp to your project in the usual folders. // // Add this line to the top of your RC2 file: // #include "MyHyperlinkResource.h" // MyHyperlink resources. // // Add this line to the end of your RC2 file: // #include "MyHyperlink.rc2" // MyHyperlink resources. // // Add, if needed, the MyMenu and Generic classes to the project. Be sure to // check each of these classes' *.H file for instructions on how to include // them in your project. ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_MYHYPERLINK_H__F90A1769_7968_11D2_BC18_00805F718BD8__INCLUDED_) #define AFX_MYHYPERLINK_H__F90A1769_7968_11D2_BC18_00805F718BD8__INCLUDED_ #pragma once #include "MyToolTipCtrl.h" ///////////////////////////////////////////////////////////////////////////// // Structure used to get/set hyperlink colors. typedef struct tagHYPERLINKCOLORS { COLORREF crLink; COLORREF crVisited; COLORREF crHover; } HYPERLINKCOLORS; ///////////////////////////////////////////////////////////////////////////// // MyHyperlink // Declare the class depending on this file is in an EXE project or a DLL one. class #ifdef _WINDLL AFX_EXT_CLASS #endif MyHyperlink : public CStatic { DECLARE_DYNAMIC(MyHyperlink) // Construction. public: MyHyperlink(); virtual ~MyHyperlink(); // Link styles. public: static const DWORD StyleUnderline; // Underline the text. static const DWORD StyleUseHover; // Hand over coloring. static const DWORD StyleAutoSize; // Size control to text. static const DWORD StyleDownClick; // Down click mode. static const DWORD StyleGetFocusOnClick; // Get focus on click. static const DWORD StyleNoHandCursor; // No hand cursor. // Operations. public: static HINSTANCE GotoURL(LPCTSTR lpszUrl, int nShowCmd); static void GetColors(HYPERLINKCOLORS& linkColors); static HCURSOR GetLinkCursor(); static void SetLinkCursor(HCURSOR hCursor); static void SetColors(HYPERLINKCOLORS& colors); static void SetColors(COLORREF crLinkColor, COLORREF crVisitedColor, COLORREF crHoverColor = -1); void SetURL(const CString& sURL); DWORD GetLinkStyle() const; bool ModifyLinkStyle(DWORD dwRemove, DWORD dwAdd, bool bApply = true); void SetWindowText(LPCTSTR lpszText); void SetFont(CFont* pFont); bool IsVisited() const; void SetVisited(bool bVisited = true); // Use this if you want to subclass and also set different URL. BOOL SubclassDlgItem(UINT uiID, CWnd* pParent, LPCTSTR lpszURL = NULL) { m_sURL = lpszURL; return CStatic::SubclassDlgItem(uiID, pParent); } //{{AFX_VIRTUAL(MyHyperlink) public: virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void PreSubclassWindow(); //}}AFX_VIRTUAL // Implementation. protected: static void SetDefaultCursor(); static LONG GetRegKey(HKEY key, LPCTSTR lpszSubkey, LPTSTR lpszRetdata); void AdjustWindow(); void FollowLink(); void SwitchUnderline(); // Protected attributes. protected: static COLORREF crLinkColor; // Link normal color static COLORREF crVisitedColor; // Link visited color static COLORREF crHoverColor; // Hover color static HCURSOR hLinkCursor; // Hyperlink mouse cursor bool m_bOverControl; // Is cursor over control? bool m_bVisited; // Has link been visited? DWORD m_dwStyle; // Link styles. CString m_sURL; // Hyperlink URL string. CFont m_Font; // Underlined font (if required). MyToolTipCtrl m_ToolTip; // The link tooltip. // Generated message map functions protected: //{{AFX_MSG(MyHyperlink) afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg UINT OnNcHitTest(CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); afx_msg void OnEditCopy(); afx_msg void OnOpenUrl(); afx_msg void OnToggleVisited(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MYHYPERLINK_H__F90A1769_7968_11D2_BC18_00805F718BD8__INCLUDED_)