Browse Source

check if ditto window is in a valid monitor when showing ditto

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@112 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 21 years ago
parent
commit
9c8270099a
3 changed files with 20 additions and 2 deletions
  1. 1 0
      Misc.cpp
  2. 18 2
      QuickPaste.cpp
  3. 1 0
      QuickPaste.h

+ 1 - 0
Misc.cpp

@@ -1532,6 +1532,7 @@ int GetMonitorFromRect(LPRECT lpMonitorRect)
 	ZeroMemory(&EnumParam, sizeof(EnumParam));
 	EnumParam.lFlags = MONITOR_SEARCH_METOHD;
 	EnumParam.pVirtualRect = lpMonitorRect;
+	EnumParam.iMonitor = -1;
 	
 	// Enum Displays
 	EnumDisplayMonitors(NULL, NULL, MyMonitorEnumProc, (long)&EnumParam);

+ 18 - 2
QuickPaste.cpp

@@ -133,11 +133,13 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, BOOL bAtPrevPos)
 	
 	m_pwndPaste->MinMaxWindow(FORCE_MAX);
 	
+	CRect crRect = CRect(point, csSize);
 	if((nPosition == POS_AT_CARET) ||
 		(nPosition == POS_AT_CURSOR) ||
-		(bAtPrevPos))
+		(bAtPrevPos) ||
+		EnsureVisible(&crRect))
 	{
-		m_pwndPaste->MoveWindow(CRect(point, csSize));
+		m_pwndPaste->MoveWindow(crRect);
 	}
 	
 	// Show the window
@@ -145,6 +147,20 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, BOOL bAtPrevPos)
 	m_pwndPaste->SetForegroundWindow();
 }
 
+BOOL CQuickPaste::EnsureVisible(CRect *pcrRect)
+{
+	if(GetMonitorFromRect(pcrRect) < 0)
+	{
+		GetMonitorRect(0, pcrRect);
+		pcrRect->right = pcrRect->left + 300;
+		pcrRect->bottom = pcrRect->top + 300;
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
 void CQuickPaste::HideQPasteWnd()
 {
 	// Hide the window

+ 1 - 0
QuickPaste.h

@@ -22,6 +22,7 @@ public:
 	void HideQPasteWnd();
 	BOOL CloseQPasteWnd();
 	BOOL IsWindowVisibleEx();
+	BOOL EnsureVisible(CRect *pcrRect);
 
 //protected:
 	CQPasteWnd *m_pwndPaste;