Browse Source

first pass at per window dpi, changes dynamically to dpi changes

sabrogden 7 years ago
parent
commit
7875f65a30
4 changed files with 19 additions and 13 deletions
  1. 12 5
      MainFrm.cpp
  2. 2 0
      MainFrm.h
  3. 2 8
      QPasteWnd.cpp
  4. 3 0
      QuickPaste.cpp

+ 12 - 5
MainFrm.cpp

@@ -110,10 +110,13 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 	m_PowerManager.Start(m_hWnd);
 
     ////Center the main window so message boxes are in the center
-    //CRect rcScreen;
-    //GetMonitorRect(0, &rcScreen);
-    //CPoint cpCenter = rcScreen.CenterPoint();
-    ////MoveWindow(cpCenter.x, cpCenter.x,  - 2,  - 2);
+    CRect rcScreen;
+    GetMonitorRect(0, &rcScreen);
+    CPoint cpCenter = rcScreen.CenterPoint();
+    MoveWindow(cpCenter.x, cpCenter.x,  1,  1);
+
+	m_startupScreenWidth = GetScreenWidth();
+	m_startupScreenHeight = GetScreenHeight();
 
     //Then set the main window to transparent so it's never shown
     //if it is shown then only the task tray icon
@@ -1359,7 +1362,11 @@ void CMainFrame::OnFirstFixupstickycliporder()
 
 LRESULT CMainFrame::OnResolutionChange(WPARAM wParam, LPARAM lParam)
 {
-	SetTimer(SCREEN_RESOLUTION_CHANGED, 1000, NULL);
+	if (m_startupScreenWidth != GetScreenWidth() ||
+		m_startupScreenHeight != GetScreenHeight())
+	{
+		SetTimer(SCREEN_RESOLUTION_CHANGED, 1000, NULL);
+	}
 
 	return TRUE;
 }

+ 2 - 0
MainFrm.h

@@ -73,6 +73,8 @@ public:
 	int m_doubleClickGroupId;
 	DWORD m_doubleClickGroupStartTime;
 	CPowerManager m_PowerManager;
+	int m_startupScreenWidth;
+	int m_startupScreenHeight;
 
     void DoDittoCopyBufferPaste(int nCopyBuffer);
     void DoFirstTenPositionsPaste(int nPos);

+ 2 - 8
QPasteWnd.cpp

@@ -6657,18 +6657,12 @@ LRESULT CQPasteWnd::OnDpiChanged(WPARAM wParam, LPARAM lParam)
 	m_ShowGroupsFolderBottom.Reset();
 	m_ShowGroupsFolderBottom.LoadStdImageDPI(m_DittoWindow.m_dpi.GetDPIX(), open_folder_24, open_folder_30, open_folder_36, open_folder_42, open_folder_48, _T("PNG"));
 	
-	m_search.OnDpiChanged();
-
-	int t = m_lstHeader.GetTopIndex();
-	m_lstHeader.EnsureVisible(0, FALSE);
-	
+	m_search.OnDpiChanged();		
 	m_lstHeader.OnDpiChanged();	
 
 	UpdateFont();
 	this->SetLinesPerRow(CGetSetOptions::GetLinesPerRow(), true);
-
-	m_lstHeader.EnsureVisible(t, FALSE);
-
+		
 	MoveControls();
 
 	m_lstHeader.RefreshVisibleRows();

+ 3 - 0
QuickPaste.cpp

@@ -348,6 +348,9 @@ void CQuickPaste::OnScreenResolutionChange()
 		CGetSetOptions::GetQuickPastePoint(point);
 		CGetSetOptions::GetQuickPasteSize(csSize);
 
+		csSize.cx = m_pwndPaste->m_DittoWindow.m_dpi.ScaleX(csSize.cx);
+		csSize.cy = m_pwndPaste->m_DittoWindow.m_dpi.ScaleY(csSize.cy);
+
 		m_pwndPaste->MoveWindow(point.x, point.y, csSize.cx, csSize.cy);
 	}
 	else