Преглед на файлове

Hide both the tooltip window and main window when the focus is on the tooltop window and they click to another window
[SAB]


git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@175 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden преди 20 години
родител
ревизия
bfa1f201a4
променени са 6 файла, в които са добавени 38 реда и са изтрити 1 реда
  1. 2 0
      QListCtrl.cpp
  2. 1 0
      QListCtrl.h
  3. 12 0
      QPasteWnd.cpp
  4. 1 0
      QPasteWnd.h
  5. 18 1
      ToolTipEx.cpp
  6. 4 0
      ToolTipEx.h

+ 2 - 0
QListCtrl.cpp

@@ -769,6 +769,8 @@ int CQListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
 
 
 	m_pToolTip = new CToolTipEx;
 	m_pToolTip = new CToolTipEx;
 	m_pToolTip->Create(this);
 	m_pToolTip->Create(this);
+
+	m_pToolTip->SetNotifyWnd(GetParent());
 	
 	
 	return 0;
 	return 0;
 }
 }

+ 1 - 0
QListCtrl.h

@@ -24,6 +24,7 @@
 #define NM_GET_CLIP_DATA	        WM_USER+0x111
 #define NM_GET_CLIP_DATA	        WM_USER+0x111
 #define CB_SEARCH					WM_USER+0x112
 #define CB_SEARCH					WM_USER+0x112
 #define CB_UPDOWN					WM_USER+0x113
 #define CB_UPDOWN					WM_USER+0x113
+#define NM_INACTIVE_TOOLTIPWND		WM_USER+0x114
 
 
 
 
 //#define NM_LIST_CUT			        WM_USER+0x111
 //#define NM_LIST_CUT			        WM_USER+0x111

+ 12 - 0
QPasteWnd.cpp

@@ -151,6 +151,7 @@ BEGIN_MESSAGE_MAP(CQPasteWnd, CWndEx)
 	ON_COMMAND(ID_BACK_BUTTON, OnBackButton)
 	ON_COMMAND(ID_BACK_BUTTON, OnBackButton)
 	ON_MESSAGE(NM_GET_CLIP_DATA, OnGetClipData)
 	ON_MESSAGE(NM_GET_CLIP_DATA, OnGetClipData)
 	ON_MESSAGE(CB_UPDOWN, OnUpDown)
 	ON_MESSAGE(CB_UPDOWN, OnUpDown)
+	ON_MESSAGE(NM_INACTIVE_TOOLTIPWND, OnToolTipWndInactive)
 
 
 END_MESSAGE_MAP()
 END_MESSAGE_MAP()
 
 
@@ -2233,3 +2234,14 @@ LRESULT CQPasteWnd::OnUpDown(WPARAM wParam, LPARAM lParam)
 
 
 	return TRUE;
 	return TRUE;
 }
 }
+
+LRESULT CQPasteWnd::OnToolTipWndInactive(WPARAM wParam, LPARAM lParam)
+{
+	CWnd *p = GetFocus();
+	if(p == NULL)
+	{
+		HideQPasteWindow();
+	}
+
+	return TRUE;
+}

+ 1 - 0
QPasteWnd.h

@@ -204,6 +204,7 @@ public:
 	afx_msg void OnBackButton();
 	afx_msg void OnBackButton();
 	afx_msg LRESULT OnGetClipData(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnGetClipData(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnUpDown(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnUpDown(WPARAM wParam, LPARAM lParam);
+	LRESULT OnToolTipWndInactive(WPARAM wParam, LPARAM lParam);
 };
 };
 
 
 
 

+ 18 - 1
ToolTipEx.cpp

@@ -25,7 +25,8 @@ static char THIS_FILE[] = __FILE__;
 CToolTipEx::CToolTipEx() :
 CToolTipEx::CToolTipEx() :
 	m_dwTextStyle(DT_EXPANDTABS|DT_EXTERNALLEADING|DT_NOPREFIX|DT_WORDBREAK),
 	m_dwTextStyle(DT_EXPANDTABS|DT_EXTERNALLEADING|DT_NOPREFIX|DT_WORDBREAK),
 	m_rectMargin(2, 2, 3, 3),
 	m_rectMargin(2, 2, 3, 3),
-	m_pBitmap(NULL)
+	m_pBitmap(NULL),
+	m_pNotifyWnd(NULL)
 {
 {
 }
 }
 
 
@@ -42,6 +43,7 @@ BEGIN_MESSAGE_MAP(CToolTipEx, CWnd)
 	ON_WM_PAINT()
 	ON_WM_PAINT()
 	ON_WM_SIZE()
 	ON_WM_SIZE()
 	ON_WM_NCHITTEST()
 	ON_WM_NCHITTEST()
+	ON_WM_ACTIVATE()
 	//}}AFX_MSG_MAP
 	//}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 END_MESSAGE_MAP()
 
 
@@ -484,3 +486,18 @@ UINT CToolTipEx::OnNcHitTest(CPoint point)
 
 
 	return CWnd::OnNcHitTest(point);
 	return CWnd::OnNcHitTest(point);
 }
 }
+
+void CToolTipEx::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
+{
+	CWnd::OnActivate(nState, pWndOther, bMinimized);
+	
+	if (nState == WA_INACTIVE)
+	{
+		Hide();
+
+		if(m_pNotifyWnd)
+		{
+			m_pNotifyWnd->PostMessage(NM_INACTIVE_TOOLTIPWND, 0, 0);
+		}
+	}
+}

+ 4 - 0
ToolTipEx.h

@@ -29,6 +29,7 @@ public:
 	void SetToolTipText(const CString &csText);
 	void SetToolTipText(const CString &csText);
 	void SetRTFText(const CString &csRTF);
 	void SetRTFText(const CString &csRTF);
 	void SetBitmap(CBitmap *pBitmap);
 	void SetBitmap(CBitmap *pBitmap);
+	void SetNotifyWnd(CWnd *pNotify)		{ m_pNotifyWnd = pNotify;	}
 
 
 // Overrides
 // Overrides
 	// ClassWizard generated virtual function overrides
 	// ClassWizard generated virtual function overrides
@@ -52,6 +53,8 @@ protected:
 
 
 	CRichEditCtrlEx m_RichEdit;
 	CRichEditCtrlEx m_RichEdit;
 
 
+	CWnd *m_pNotifyWnd;
+
 	
 	
 
 
 protected:
 protected:
@@ -67,6 +70,7 @@ protected:
 	afx_msg void OnPaint();
 	afx_msg void OnPaint();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	afx_msg UINT OnNcHitTest(CPoint point);
 	afx_msg UINT OnNcHitTest(CPoint point);
+	afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
 	//}}AFX_MSG
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 	DECLARE_MESSAGE_MAP()
 };
 };