Browse Source

handle hyperlinks in description window

scott brogden 8 years ago
parent
commit
d90b009371
2 changed files with 26 additions and 1 deletions
  1. 25 1
      ToolTipEx.cpp
  2. 1 0
      ToolTipEx.h

+ 25 - 1
ToolTipEx.cpp

@@ -4,6 +4,7 @@
 #include "BitmapHelper.h"
 #include "Options.h"
 #include "ActionEnums.h"
+#include "HyperLink.h"
 #include <Richedit.h>
 
 #ifdef _DEBUG
@@ -100,6 +101,9 @@ BOOL CToolTipEx::Create(CWnd *pParentWnd)
     m_RichEdit.SetReadOnly();
     m_RichEdit.SetBackgroundColor(FALSE, g_Opt.m_Theme.DescriptionWindowBG());
 
+	m_RichEdit.SetEventMask(m_RichEdit.GetEventMask() | ENM_SELCHANGE | ENM_LINK);
+	m_RichEdit.SetAutoURLDetect(TRUE);
+
 	ApplyWordWrap();
 
     SetLogFont(GetSystemToolTipFont(), FALSE);
@@ -1114,4 +1118,24 @@ void CToolTipEx::OnFirstAlwaysontop()
 	}
 
 	::SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);	
-}
+}
+
+BOOL CToolTipEx::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
+{
+	switch (((LPNMHDR)lParam)->code)
+	{
+		case EN_LINK:
+		{
+			ENLINK *enLinkInfo = (ENLINK *)lParam; // pointer to a ENLINK structure
+			if (enLinkInfo->msg == WM_LBUTTONUP)
+			{
+				CString s;
+				m_RichEdit.GetTextRange(enLinkInfo->chrg.cpMin, enLinkInfo->chrg.cpMax, s);
+				CHyperLink::GotoURL(s, SW_SHOW);
+			}
+		}
+		break;
+	}
+
+	return CWnd::OnNotify(wParam, lParam, pResult);
+}

+ 1 - 0
ToolTipEx.h

@@ -127,4 +127,5 @@ public:
 	afx_msg void OnFirstWraptext();
 	afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
 	afx_msg void OnFirstAlwaysontop();
+	virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
 };