1
0
Эх сурвалжийг харах

Handle screen resolution changes better

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@821 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 10 жил өмнө
parent
commit
34cde9f8b6
5 өөрчлөгдсөн 31 нэмэгдсэн , 10 устгасан
  1. 7 1
      MainFrm.cpp
  2. 1 0
      MainFrm.h
  3. 11 3
      QuickPaste.cpp
  4. 3 0
      QuickPaste.h
  5. 9 6
      ToolTipEx.cpp

+ 7 - 1
MainFrm.cpp

@@ -696,6 +696,12 @@ void CMainFrame::OnTimer(UINT_PTR nIDEvent)
 				}
 			}
 			break;
+		case SCREEN_RESOLUTION_CHANGED:
+			{
+				KillTimer(SCREEN_RESOLUTION_CHANGED);
+				m_quickPaste.OnScreenResolutionChange();
+			}
+			break;
     }
 
     CFrameWnd::OnTimer(nIDEvent);
@@ -1302,7 +1308,7 @@ void CMainFrame::OnFirstFixupstickycliporder()
 
 LRESULT CMainFrame::OnResolutionChange(WPARAM wParam, LPARAM lParam)
 {
-	m_quickPaste.OnScreenResolutionChange();
+	SetTimer(SCREEN_RESOLUTION_CHANGED, 1000, NULL);
 
 	return TRUE;
 }

+ 1 - 0
MainFrm.h

@@ -20,6 +20,7 @@
 #define READ_RANDOM_DB_FILE				12
 #define GROUP_DOUBLE_CLICK				13
 #define CLOSE_POPUP_MSG_WND				14
+#define SCREEN_RESOLUTION_CHANGED		15
 
 class CMainFrame: public CFrameWnd
 {

+ 11 - 3
QuickPaste.cpp

@@ -20,6 +20,7 @@ static char THIS_FILE[]=__FILE__;
 
 CQuickPaste::CQuickPaste()
 {
+	m_forceResizeOnNextShow = false;
 	m_pwndPaste = NULL;
 }
 
@@ -122,7 +123,8 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, bool bAtPrevPos, bool bFromKeyboa
 	
 	//If it is a window get the rect otherwise get the saved point and size
 	if (IsWindow(m_pwndPaste->m_hWnd) &&
-		m_pwndPaste->IsIconic() == FALSE)
+		m_pwndPaste->IsIconic() == FALSE &&
+		m_forceResizeOnNextShow == false)
 	{
 		m_pwndPaste->GetWindowRect(rcPrev);
 		csSize = rcPrev.Size();
@@ -178,7 +180,7 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, bool bAtPrevPos, bool bFromKeyboa
 
 	CRect crRect = CRect(point, csSize);
 
-	bool forceMoveWindow = false;
+	bool forceMoveWindow = m_forceResizeOnNextShow;
 
 	if(g_Opt.m_bEnsureEntireWindowCanBeSeen)
 	{
@@ -317,7 +319,9 @@ bool CQuickPaste::IsWindowTopLevel()
 void CQuickPaste::OnScreenResolutionChange()
 {
 	if(m_pwndPaste != NULL &&
-		::IsWindow(m_pwndPaste->m_hWnd))
+		::IsWindow(m_pwndPaste->m_hWnd) &&
+		m_pwndPaste->IsIconic() == FALSE &&
+		IsWindowVisibleEx())
 	{
 		Log(StrF(_T("Window Position changed, moving window to position as of this screen resolution %dx%d"), GetScreenWidth(), GetScreenHeight()));
 		CPoint point;
@@ -328,4 +332,8 @@ void CQuickPaste::OnScreenResolutionChange()
 
 		m_pwndPaste->MoveWindow(point.x, point.y, csSize.cx, csSize.cy);
 	}
+	else
+	{
+		m_forceResizeOnNextShow = true;
+	}
 }

+ 3 - 0
QuickPaste.h

@@ -34,6 +34,9 @@ public:
 //protected:
 	CQPasteWnd *m_pwndPaste;
 
+protected:
+	bool m_forceResizeOnNextShow;
+
 };
 
 #endif // !defined(AFX_QUICKPASTE_H__1B4A98E6_B719_402C_BDD4_7F3F97CD0EB0__INCLUDED_)

+ 9 - 6
ToolTipEx.cpp

@@ -210,17 +210,20 @@ BOOL CToolTipEx::Hide()
 {
     DELETE_BITMAP 
 
+	if(::IsWindowVisible(m_hWnd))
+	{
+		CRect rect;
+		this->GetWindowRect(&rect);
+		CGetSetOptions::SetDescWndSize(rect.Size());
+		CGetSetOptions::SetDescWndPoint(rect.TopLeft());
+	}
+
     ShowWindow(SW_HIDE);
 
     m_csRTF = "";
     m_csText = "";
 	m_clipId = 0;
-	m_searchText = _T("");
-
-	CRect rect;
-	this->GetWindowRect(&rect);
-	CGetSetOptions::SetDescWndSize(rect.Size());
-	CGetSetOptions::SetDescWndPoint(rect.TopLeft());
+	m_searchText = _T("");	
 
     return TRUE;
 }