Browse Source

move changes to Ensuring window is visible with in monitors

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@734 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 11 years ago
parent
commit
2b27c32a58
1 changed files with 14 additions and 4 deletions
  1. 14 4
      Misc.cpp

+ 14 - 4
Misc.cpp

@@ -807,6 +807,7 @@ BOOL EnsureWindowVisible(CRect *pcrRect)
 	CRect crMonitor;
 	GetMonitorRect(nMonitor, crMonitor);
 
+	bool movedLeft = false;
 	//Validate the left
 	long lDiff = pcrRect->left - crMonitor.left;
 	if(lDiff < 0)
@@ -814,17 +815,22 @@ BOOL EnsureWindowVisible(CRect *pcrRect)
 		pcrRect->left += abs(lDiff);
 		pcrRect->right += abs(lDiff);
 		ret = TRUE;
+		movedLeft = true;
 	}
 
 	//Right side
 	lDiff = pcrRect->right - crMonitor.right;
 	if(lDiff > 0)
 	{
-		pcrRect->left -= abs(lDiff);
+		if(movedLeft == false)
+		{
+			pcrRect->left -= abs(lDiff);
+		}
 		pcrRect->right -= abs(lDiff);
 		ret = TRUE;
 	}
 
+	bool movedTop = false;
 	//Top
 	lDiff = pcrRect->top - crMonitor.top;
 	if(lDiff < 0)
@@ -832,14 +838,18 @@ BOOL EnsureWindowVisible(CRect *pcrRect)
 		pcrRect->top += abs(lDiff);
 		pcrRect->bottom += abs(lDiff);
 		ret = TRUE;
+		movedTop = true;
 	}
 
 	//Bottom
 	lDiff = pcrRect->bottom - crMonitor.bottom;
 	if(lDiff > 0)
-	{
-		pcrRect->top -= abs(lDiff);
-		pcrRect->bottom -= abs(lDiff);
+	{		
+		if(movedTop == false)
+		{
+			pcrRect->top -= abs(lDiff);
+		}
+		pcrRect->bottom -= abs(lDiff);		
 		ret = TRUE;
 	}