Browse Source

Set focus to richtext on mouse active so the first click works to select text and click on hyperlinks

sabrogden 8 years ago
parent
commit
6b0087466d
2 changed files with 21 additions and 1 deletions
  1. 20 1
      ToolTipEx.cpp
  2. 1 0
      ToolTipEx.h

+ 20 - 1
ToolTipEx.cpp

@@ -61,6 +61,7 @@ ON_COMMAND(ID_FIRST_HIDEDESCRIPTIONWINDOWONM, &CToolTipEx::OnFirstHidedescriptio
 ON_COMMAND(ID_FIRST_WRAPTEXT, &CToolTipEx::OnFirstWraptext)
 ON_WM_WINDOWPOSCHANGING()
 ON_COMMAND(ID_FIRST_ALWAYSONTOP, &CToolTipEx::OnFirstAlwaysontop)
+ON_NOTIFY(EN_MSGFILTER, 1, &CToolTipEx::OnEnMsgfilterRichedit21)
 END_MESSAGE_MAP()
 
 
@@ -101,9 +102,10 @@ 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.SetEventMask(m_RichEdit.GetEventMask() | ENM_SELCHANGE | ENM_LINK | ENM_MOUSEEVENTS | ENM_SCROLLEVENTS);
 	m_RichEdit.SetAutoURLDetect(TRUE);
 
+
 	ApplyWordWrap();
 
     SetLogFont(GetSystemToolTipFont(), FALSE);
@@ -1143,3 +1145,20 @@ BOOL CToolTipEx::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
 
 	return CWnd::OnNotify(wParam, lParam, pResult);
 }
+
+
+void CToolTipEx::OnEnMsgfilterRichedit21(NMHDR *pNMHDR, LRESULT *pResult)
+{
+	MSGFILTER *pMsgFilter = reinterpret_cast<MSGFILTER *>(pNMHDR);
+	if (pMsgFilter != NULL)
+	{
+		switch (pMsgFilter->msg)
+		{
+			case WM_MOUSEACTIVATE:
+				m_RichEdit.SetFocus();
+				break;
+		}
+	}
+
+	*pResult = 0;
+}

+ 1 - 0
ToolTipEx.h

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