Jelajahi Sumber

Improved drawing speed, Fixed "multiple repaints on first show" bug

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@63 595ec19a-5cb4-439b-94a8-42fb3063c22c
ingenuus 22 tahun lalu
induk
melakukan
05a2e8f8d1
7 mengubah file dengan 56 tambahan dan 13 penghapusan
  1. 1 1
      CP_Main.cpp
  2. 22 0
      Changes.txt
  3. 14 2
      QListCtrl.cpp
  4. 15 7
      QPasteWnd.cpp
  5. 1 0
      QPasteWnd.h
  6. 2 2
      QuickPaste.cpp
  7. 1 1
      WndEx.cpp

+ 1 - 1
CP_Main.cpp

@@ -209,7 +209,7 @@ void CCP_MainApp::SendPaste()
 {
 	if( !ActivateTarget() )
 	{
-		SetStatus("SendPaste FAILED!");
+		SetStatus("SendPaste FAILED!",TRUE);
 		return;
 	}
 

+ 22 - 0
Changes.txt

@@ -1,3 +1,25 @@
+04 Jan 20
+---------
+! Fixed "multiple repaints on first show" bug.
+  * CQuickPaste::ShowQPasteWnd:
+    - m_pwndPaste->ShowWindow(SW_SHOW)
+      . This caused premature drawing and activation of the window.
+        It was replaced by a call to:
+    + m_pwndPaste->ShowQPasteWindow()
+    
+  * CQPasteWnd:
+    + bool m_bAllowRepaintImmediately:
+      . This acts as an override for RefreshNc's bRepaintImmediately parameter,
+        thereby stopping the status (titlebar) from being repeatedly redrawn
+        during ShowQPasteWindow.
+
+* Misc. Painting Improvements:
+  ! CWndEx::InvalidateNc(): redraw with RDW_NOCHILDREN
+    . The client area was being invalidated without this.
+  * CQListCtrl::OnEraseBkgnd(): faster when shift-scrolling.
+  * CQListCtrl::OnSelectionChange(): delayed SetStatus for faster selection.
+
+
 03 Sept 22
 ----------
 + Shared Data: Data can now be shared amongst multiple Clips.

+ 14 - 2
QListCtrl.cpp

@@ -512,7 +512,19 @@ void CQListCtrl::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
 
 BOOL CQListCtrl::OnEraseBkgnd(CDC* pDC) 
 {
-//	return TRUE;
+	// Simply returning TRUE seems OK since we do custom item
+	//	painting.  However, there is a pixel buffer around the
+	//	border of this control (not within the item rects)
+	//	which becomes visually corrupt if it is not erased.
+
+	// In most cases, I do not notice the erasure, so I have kept
+	//	the call to CListCtrl::OnEraseBkgnd(pDC);
+
+	// However, for some reason, bulk erasure is very noticeable when
+	//	shift-scrolling the page to select a block of items, so
+	//	I made a special case for that:
+	if( GetSelectedCount() >= 2 )
+		return TRUE;
 	return CListCtrl::OnEraseBkgnd(pDC);
 }
 
@@ -867,7 +879,7 @@ void CQListCtrl::OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult)
 			SetTimer(TIMER_SHOW_PROPERTIES, 300, NULL);
 		}
 		if(GetSelectedCount() > 0 )
-			theApp.SetStatus(NULL, TRUE);
+			theApp.SetStatus(NULL, FALSE);
 	}
 }
 

+ 15 - 7
QPasteWnd.cpp

@@ -36,6 +36,7 @@ CQPasteWnd::CQPasteWnd()
 	m_Title = QPASTE_TITLE;
 	m_bHideWnd = true;
 	m_strSQLSearch = "";
+	m_bAllowRepaintImmediately = true;
 }
 
 CQPasteWnd::~CQPasteWnd()
@@ -323,6 +324,9 @@ BOOL CQPasteWnd::ShowQPasteWindow(BOOL bFillList)
 	//Set the flag so we can't open this up again
 	theApp.m_bShowingQuickPaste = true;
 	SetCaptionColorActive( !g_Opt.m_bShowPersistent );
+
+	// use invalidation to avoid unnecessary repainting
+	m_bAllowRepaintImmediately = false;
 	UpdateStatus();
 
 	m_lstHeader.DestroyAndCreateAccelerator(TRUE);
@@ -350,14 +354,16 @@ BOOL CQPasteWnd::ShowQPasteWindow(BOOL bFillList)
 	m_lstHeader.SetShowTextForFirstTenHotKeys(CGetSetOptions::GetShowTextForFirstTenHotKeys());
 	
 	if(bFillList)
-		FillList();
-	
-	MoveControls();
+		FillList();	// FillList calls MoveControls
+	else
+		MoveControls();
 	
-	ShowWindow(SW_SHOW);
+	// from now on, for interactive use, we can repaint immediately
+	m_bAllowRepaintImmediately = true;
 
 	// always on top... for persistent showing (g_Opt.m_bShowPersistent)
-	::SetWindowPos( m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
+	// SHOWWINDOW was also integrated into this function rather than calling it separately
+	::SetWindowPos( m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW );
 
 	return TRUE;
 }
@@ -517,7 +523,7 @@ void CQPasteWnd::RefreshNc( bool bRepaintImmediately )
 	if( !theApp.m_bShowingQuickPaste )
 		return;
 
-	if( bRepaintImmediately )
+	if( bRepaintImmediately && m_bAllowRepaintImmediately )
 		OnNcPaint();
 	else
 		InvalidateNc();
@@ -647,7 +653,9 @@ BOOL CQPasteWnd::FillList(CString csSQLSearch/*=""*/)
 		{
 			m_Recset.MoveLast();
 			m_lstHeader.SetItemCountEx(m_Recset.GetRecordCount());
-		}	
+		}
+		else
+			m_lstHeader.SetItemCountEx(0);
 	}
 	catch(CDaoException* e)
 	{

+ 1 - 0
QPasteWnd.h

@@ -67,6 +67,7 @@ public:
 	CGroupTree		m_GroupTree;
 	CBitmapButton	m_ShowGroupsFolderBottom;
 	CBitmapButton	m_ShowGroupsFolderTop;
+	bool			m_bAllowRepaintImmediately;
 
 	void RefreshNc( bool bRepaintImmediately = false );
 	void UpdateStatus( bool bRepaintImmediately = false );  // regenerates the status (caption) text

+ 2 - 2
QuickPaste.cpp

@@ -141,7 +141,7 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, BOOL bAtPrevPos)
 	}
 		
 	// Show the window
-	m_pwndPaste->ShowWindow(SW_SHOW);
+	m_pwndPaste->ShowQPasteWindow();
 	m_pwndPaste->SetForegroundWindow();
 }
 
@@ -151,6 +151,6 @@ void CQuickPaste::HideQPasteWnd()
 	if(m_pwndPaste)
 	{
 		if (IsWindow(m_pwndPaste->m_hWnd))
-			m_pwndPaste->ShowWindow(SW_SHOW);
+			m_pwndPaste->ShowWindow(SW_HIDE);
 	}
 }

+ 1 - 1
WndEx.cpp

@@ -41,7 +41,7 @@ CWndEx::~CWndEx()
 
 void CWndEx::InvalidateNc()
 {
-	::RedrawWindow( m_hWnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_NOINTERNALPAINT );
+	::RedrawWindow( m_hWnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_NOCHILDREN );
 }
 
 void CWndEx::GetWindowRectEx(LPRECT lpRect)