Browse Source

handle always on top and wrap text from main window for description window

sabrogden 8 years ago
parent
commit
2aa24c5577
14 changed files with 391 additions and 183 deletions
  1. 14 0
      Accels.cpp
  2. 2 0
      Accels.h
  3. 20 0
      ActionEnums.cpp
  4. 2 0
      ActionEnums.h
  5. 110 3
      DittoWindow.cpp
  6. 6 0
      DittoWindow.h
  7. 34 1
      QListCtrl.cpp
  8. 5 0
      QListCtrl.h
  9. 45 7
      QPasteWnd.cpp
  10. 2 0
      QPasteWnd.h
  11. 128 48
      ToolTipEx.cpp
  12. 11 0
      ToolTipEx.h
  13. 10 120
      WndEx.cpp
  14. 2 4
      WndEx.h

+ 14 - 0
Accels.cpp

@@ -137,6 +137,20 @@ bool CAccels::OnMsg(MSG *pMsg, CAccel &a)
     return false;
 }
 
+bool CAccels::ContainsKey(int vKey)
+{
+	CString cmdShortcutText;
+	for (multimap<DWORD, CAccel>::iterator it = m_multiMap.begin(); it != m_multiMap.end(); ++it)
+	{
+		if (LOBYTE(it->second.Key) == vKey || LOBYTE(it->second.Key2) == vKey)
+		{
+			return true;
+		}
+	}
+
+	return false;
+}
+
 BYTE CAccels::GetKeyStateModifiers()
 {
     BYTE m = 0;

+ 2 - 0
Accels.h

@@ -47,6 +47,8 @@ public:
     // returns a pointer to the internal CAccel if it matches the given key or NULL
     bool OnMsg(MSG *pMsg, CAccel &a);
 
+	bool ContainsKey(int vKey);
+
 	bool m_handleRepeatKeys;
 	bool m_checkModifierKeys;
 

+ 20 - 0
ActionEnums.cpp

@@ -290,6 +290,8 @@ CString ActionEnums::EnumDescription(ActionEnumValues value)
 	case MOVE_SELECTION_DOWN:
 		val = "Move Selection Down";
 		break;
+	case TOGGLE_DESCRIPTION_WORD_WRAP:
+		val = "Toggle Description Word Wrap";
 	}
 
 	CString translatedValue = theApp.m_Language.GetQuickPasteKeyboardString(value, val);
@@ -361,6 +363,8 @@ int ActionEnums::GetDefaultShortCutKeyA(ActionEnumValues value, int pos)
 			return ACCEL_MAKEKEY('0', HOTKEYF_CONTROL);
 		case CLOSEWINDOW:
 			return VK_ESCAPE;
+		case TOGGLE_DESCRIPTION_WORD_WRAP:
+			return 'W';
 		}
 		break;
 	case 1:
@@ -428,4 +432,20 @@ bool ActionEnums::UserConfigurable(ActionEnumValues value)
 	}
 
 	return true;
+}
+
+bool ActionEnums::ToolTipAction(ActionEnumValues value)
+{
+	switch (value)
+	{
+	case ActionEnums::NEXTDESCRIPTION:
+	case ActionEnums::PREVDESCRIPTION:
+	case ActionEnums::TOGGLESHOWPERSISTANT:
+	case ActionEnums::TOGGLE_DESCRIPTION_WORD_WRAP:
+	case ActionEnums::CLOSEWINDOW:
+
+		return true;
+	}
+
+	return false;
 }

+ 2 - 0
ActionEnums.h

@@ -98,6 +98,7 @@ public:
 		TOGGLE_CLIPBOARD_CONNECTION,
 		MOVE_SELECTION_UP,
 		MOVE_SELECTION_DOWN,
+		TOGGLE_DESCRIPTION_WORD_WRAP,
 
 		LAST_ACTION
 	};
@@ -107,5 +108,6 @@ public:
 	static int GetDefaultShortCutKeyA(ActionEnumValues value, int pos);
 	static int GetDefaultShortCutKeyB(ActionEnumValues value, int pos);
 	static bool UserConfigurable(ActionEnumValues value);
+	static bool ToolTipAction(ActionEnumValues value);
 };
 

+ 110 - 3
DittoWindow.cpp

@@ -36,10 +36,8 @@ CDittoWindow::CDittoWindow(void)
 	m_sendWMClose = true;
 	m_customWindowTitle = _T("");
 	m_useCustomWindowTitle = false;
-
 	m_buttonDownOnCaption = false;
-
-	
+	m_crFullSizeWindow.SetRectEmpty();	
 }
 
 CDittoWindow::~CDittoWindow(void)
@@ -906,4 +904,113 @@ void CDittoWindow::SnapToEdge(CWnd *pWnd, WINDOWPOS* lpwndpos)
 			lpwndpos->y = (rect.bottom - lpwndpos->cy);
 		}
 	}
+}
+
+void CDittoWindow::MinMaxWindow(CWnd *pWnd, long lOption)
+{
+	if ((m_bMinimized) && (lOption == FORCE_MIN))
+		return;
+
+	if ((m_bMinimized == false) && (lOption == FORCE_MAX))
+		return;
+
+	if (m_lRightBorder == m_captionBorderWidth)
+	{
+		if (m_bMinimized == false)
+		{
+			pWnd->GetWindowRect(m_crFullSizeWindow);
+			pWnd->MoveWindow(m_crFullSizeWindow.right - m_captionBorderWidth,
+				m_crFullSizeWindow.top, m_captionBorderWidth,
+				m_crFullSizeWindow.Height());
+			m_bMinimized = true;
+			m_TimeMinimized = COleDateTime::GetCurrentTime();
+		}
+		else
+		{
+			CRect cr;
+			pWnd->GetWindowRect(cr);
+			pWnd->MoveWindow(cr.right - m_crFullSizeWindow.Width(),
+				cr.top, m_crFullSizeWindow.Width(), cr.Height());
+
+			m_crFullSizeWindow.SetRectEmpty();
+			m_bMinimized = false;
+			m_TimeMaximized = COleDateTime::GetCurrentTime();
+			::SetForegroundWindow(pWnd->GetSafeHwnd());
+		}
+	}
+	if (m_lLeftBorder == m_captionBorderWidth)
+	{
+		if (m_bMinimized == false)
+		{
+			pWnd->GetWindowRect(m_crFullSizeWindow);
+			pWnd->MoveWindow(m_crFullSizeWindow.left,
+				m_crFullSizeWindow.top, m_captionBorderWidth,
+				m_crFullSizeWindow.Height());
+			m_bMinimized = true;
+			m_TimeMinimized = COleDateTime::GetCurrentTime();
+		}
+		else
+		{
+			CRect cr;
+			pWnd->GetWindowRect(cr);
+			pWnd->MoveWindow(cr.left, cr.top,
+				m_crFullSizeWindow.Width(), cr.Height());
+
+			m_crFullSizeWindow.SetRectEmpty();
+			m_bMinimized = false;
+			m_TimeMaximized = COleDateTime::GetCurrentTime();
+			::SetForegroundWindow(pWnd->GetSafeHwnd());
+		}
+	}
+	else if (m_lTopBorder == m_captionBorderWidth)
+	{
+		if (m_bMinimized == false)
+		{
+			pWnd->GetWindowRect(m_crFullSizeWindow);
+			pWnd->MoveWindow(m_crFullSizeWindow.left,
+				m_crFullSizeWindow.top,
+				m_crFullSizeWindow.Width(),
+				m_captionBorderWidth);
+			m_bMinimized = true;
+			m_TimeMinimized = COleDateTime::GetCurrentTime();
+		}
+		else
+		{
+			CRect cr;
+			pWnd->GetWindowRect(cr);
+			pWnd->MoveWindow(cr.left, cr.top,
+				cr.Width(), m_crFullSizeWindow.Height());
+
+			m_crFullSizeWindow.SetRectEmpty();
+			m_bMinimized = false;
+			m_TimeMaximized = COleDateTime::GetCurrentTime();
+			::SetForegroundWindow(pWnd->GetSafeHwnd());
+		}
+	}
+	else if (m_lBottomBorder == m_captionBorderWidth)
+	{
+		if (m_bMinimized == false)
+		{
+			pWnd->GetWindowRect(m_crFullSizeWindow);
+			pWnd->MoveWindow(m_crFullSizeWindow.left,
+				m_crFullSizeWindow.bottom - m_captionBorderWidth,
+				m_crFullSizeWindow.Width(),
+				m_captionBorderWidth);
+			m_bMinimized = true;
+			m_TimeMinimized = COleDateTime::GetCurrentTime();
+		}
+		else
+		{
+			CRect cr;
+			pWnd->GetWindowRect(cr);
+			pWnd->MoveWindow(cr.left,
+				cr.bottom - m_crFullSizeWindow.Height(),
+				cr.Width(), m_crFullSizeWindow.Height());
+
+			m_crFullSizeWindow.SetRectEmpty();
+			m_bMinimized = false;
+			m_TimeMaximized = COleDateTime::GetCurrentTime();
+			::SetForegroundWindow(pWnd->GetSafeHwnd());
+		}
+	}
 }

+ 6 - 0
DittoWindow.h

@@ -34,6 +34,8 @@ public:
 	bool SetCaptionColors(COLORREF left, COLORREF right, COLORREF border);
 	void SetCaptionTextColor(COLORREF color);
 
+	void MinMaxWindow(CWnd *pWnd, long lOption);
+
 	void SetTitleTextHeight(CWnd *pWnd);
 
 	void SnapToEdge(CWnd *pWnd, WINDOWPOS* lpwndpos);
@@ -89,4 +91,8 @@ public:
 	int m_titleTextHeight;
 
 	bool m_buttonDownOnCaption;
+
+	CRect m_crFullSizeWindow;
+	COleDateTime m_TimeMinimized;
+	COleDateTime m_TimeMaximized;
 };

+ 34 - 1
QListCtrl.cpp

@@ -73,6 +73,8 @@ CQListCtrl::CQListCtrl()
 
 	m_showIfClipWasPasted = TRUE;
 	m_bShowTextForFirstTenHotKeys = true;
+
+	m_pToolTipActions = NULL;
 }
 
 CQListCtrl::~CQListCtrl()
@@ -993,7 +995,7 @@ bool CQListCtrl::ShowFullDescription(bool bFromAuto, bool fromNextPrev)
 	else if(VALID_TOOLTIP)
 	{
 		CRect r;
-		m_pToolTip->GetWindowRect(r);
+		m_pToolTip->GetWindowRectEx(r);
 		pt = r.TopLeft();
 
 		m_pToolTip->SetBitmap(NULL);
@@ -1004,6 +1006,7 @@ bool CQListCtrl::ShowFullDescription(bool bFromAuto, bool fromNextPrev)
 	
 	if(VALID_TOOLTIP)
 	{
+		m_pToolTip->SetTooltipActions(m_pToolTipActions);
 		m_pToolTip->SetClipId(clipId);
 		m_pToolTip->SetClipRow(clipRow);
 		m_pToolTip->SetSearchText(m_searchText);
@@ -1591,8 +1594,38 @@ BOOL CQListCtrl::IsToolTipWindowVisible()
 	return ::IsWindowVisible(m_toolTipHwnd); 
 }
 
+void CQListCtrl::ToggleToolTipShowPersistant()
+{
+	if (VALID_TOOLTIP)
+	{
+		m_pToolTip->ToggleShowPersistant();		
+	}
+}
+
+bool CQListCtrl::ToggleToolTipWordWrap()
+{
+	bool didWordWrap = false;
+	if (VALID_TOOLTIP)
+	{
+		didWordWrap = m_pToolTip->ToggleWordWrap();
+	}
+
+	return didWordWrap;
+}
+
+
 BOOL CQListCtrl::IsToolTipWindowFocus()
 {
 	return ::GetFocus() == m_toolTipHwnd ||
 		::GetParent(::GetFocus()) == m_toolTipHwnd;
+}
+
+bool CQListCtrl::IsToolTipShowPersistant()
+{
+	if (VALID_TOOLTIP)
+	{
+		return m_pToolTip->GetShowPersistant();
+	}
+
+	return false;
 }

+ 5 - 0
QListCtrl.h

@@ -136,6 +136,10 @@ public:
 	BOOL SetItemCountEx(int iCount, DWORD dwFlags = 0);
 
 	void HidePopup(bool checkShowPersistant);
+	void ToggleToolTipShowPersistant();
+	bool ToggleToolTipWordWrap();
+	void SetTooltipActions(CAccels *pToolTipActions) { m_pToolTipActions = pToolTipActions; }
+	bool IsToolTipShowPersistant();
 
 	void SetLogFont(LOGFONT &font);
 
@@ -183,6 +187,7 @@ protected:
 	int m_rowHeight;
 	CString m_searchText;
 	BOOL m_showIfClipWasPasted;
+	CAccels *m_pToolTipActions;
 
 
 	// Generated message map functions

+ 45 - 7
QPasteWnd.cpp

@@ -464,6 +464,7 @@ void CQPasteWnd::LoadShortcuts()
 	m_modifierKeyActions.AddAccel(ActionEnums::MODIFIER_ACTVE_MOVELAST, VK_END);
 
 	m_actions.RemoveAll();
+	m_toolTipActions.RemoveAll();
 
 	m_actions.AddAccel(ActionEnums::NEXTTABCONTROL, VK_TAB);
 	m_actions.AddAccel(ActionEnums::PREVTABCONTROL, ACCEL_MAKEKEY(VK_TAB, HOTKEYF_CONTROL));
@@ -487,10 +488,17 @@ void CQPasteWnd::LoadShortcuts()
 				{
 					int b = g_Opt.GetActionShortCutB(action, i);
 					m_actions.AddAccel(action, a, b);
+
+					if (ActionEnums::ToolTipAction(action))
+					{
+						m_toolTipActions.AddAccel(action, a, b);
+					}
 				}
 			}
 		}
 	}
+
+	m_lstHeader.SetTooltipActions(&m_toolTipActions);
 }
 
 void CQPasteWnd::SetSearchImages()
@@ -3078,11 +3086,23 @@ bool CQPasteWnd::DoAction(DWORD actionId)
 	case ActionEnums::MOVE_SELECTION_DOWN:
 		ret = DoActionMoveSelectionDown();
 		break;
+	case ActionEnums::TOGGLE_DESCRIPTION_WORD_WRAP:
+		ret = DoActionToggleDescriptionWordWrap();
+		break;
 	}
 
 	return ret;
 }
 
+bool CQPasteWnd::DoActionToggleDescriptionWordWrap()
+{
+	if (m_lstHeader.IsToolTipWindowVisible() == FALSE)
+		return false;
+
+	bool ret = m_lstHeader.ToggleToolTipWordWrap();
+	return (ret == true);
+}
+
 bool CQPasteWnd::DoActionShowDescription()
 {
 	bool ret = m_lstHeader.ShowFullDescription(false, false);
@@ -3249,7 +3269,8 @@ bool CQPasteWnd::DoActionCloseWindow()
 	}
 	else
 	{
-		if (m_lstHeader.IsToolTipWindowVisible())
+		if (m_lstHeader.IsToolTipShowPersistant() == false &&
+			m_lstHeader.IsToolTipWindowVisible())
 		{
 			m_lstHeader.HidePopup(true);
 		}
@@ -3444,15 +3465,22 @@ bool CQPasteWnd::DoActionBackGroup()
 
 bool CQPasteWnd::DoActionToggleShowPersistant()
 {
-	theApp.ShowPersistent(!g_Opt.m_bShowPersistent);
-	if (g_Opt.m_bShowPersistent)
+	if (m_lstHeader.IsToolTipWindowVisible())
 	{
-		::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
+		m_lstHeader.ToggleToolTipShowPersistant();
 	}
+	else
+	{
+		theApp.ShowPersistent(!g_Opt.m_bShowPersistent);
+		if (g_Opt.m_bShowPersistent)
+		{
+			::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
+		}
 
-	MoveControls();
+		MoveControls();
 
-	UpdateStatus();
+		UpdateStatus();
+	}
 	return true;
 }
 
@@ -5106,7 +5134,17 @@ void CQPasteWnd::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
         switch(g_Opt.m_bDoubleClickingOnCaptionDoes)
         {
             case TOGGLES_ALLWAYS_ON_TOP:				
-				DoAction(ActionEnums::TOGGLESHOWPERSISTANT);                
+			{
+				theApp.ShowPersistent(!g_Opt.m_bShowPersistent);
+				if (g_Opt.m_bShowPersistent)
+				{
+					::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
+				}
+
+				MoveControls();
+
+				UpdateStatus();
+			}
                 break;
             case TOGGLES_ALLWAYS_SHOW_DESCRIPTION:
 				DoAction(ActionEnums::SHOWDESCRIPTION);    

+ 2 - 0
QPasteWnd.h

@@ -162,6 +162,7 @@ public:
 	CF_NoDibTypeMap m_cf_NO_rtfCache;
     CCriticalSection m_CritSection;
     CAccels m_actions;
+	CAccels m_toolTipActions;
 	CAccels m_modifierKeyActions;
 	bool m_showScrollBars;
 	int m_leftSelectedCompareId;
@@ -234,6 +235,7 @@ public:
 	bool DoActionNewClip();
 	bool DoActionEditClip();
 	bool DoActionMoveSelectionDown();
+	bool DoActionToggleDescriptionWordWrap();
 	bool DoActionMoveSelectionUp();
 	bool DoModifierActiveActionSelectionUp();
 	bool DoModifierActiveActionSelectionDown();

+ 128 - 48
ToolTipEx.cpp

@@ -3,6 +3,7 @@
 #include "ToolTipEx.h"
 #include "BitmapHelper.h"
 #include "Options.h"
+#include "ActionEnums.h"
 #include <Richedit.h>
 
 #ifdef _DEBUG
@@ -21,6 +22,7 @@ m_imageViewer.m_pBitmap = NULL;		\
 #define HIDE_WINDOW_TIMER 1
 #define SAVE_SIZE 2
 #define TIMER_BUTTON_UP 3
+#define TIMER_AUTO_MAX		4
 
 /////////////////////////////////////////////////////////////////////////////
 // CToolTipEx
@@ -30,6 +32,9 @@ CToolTipEx::CToolTipEx(): m_dwTextStyle(DT_EXPANDTABS | DT_EXTERNALLEADING |
                         m_pNotifyWnd(NULL), m_clipId(0), m_clipRow(-1)
 {
 	m_showPersistant = false;
+	m_pToolTipActions = NULL;
+	m_bMaxSetTimer = false;
+	m_lDelayMaxSeconds = 2;
 }
 
 CToolTipEx::~CToolTipEx()
@@ -93,7 +98,7 @@ BOOL CToolTipEx::Create(CWnd *pParentWnd)
 	m_DittoWindow.SetCaptionOn(this, CGetSetOptions::GetCaptionPos(), true, g_Opt.m_Theme.GetCaptionSize(), g_Opt.m_Theme.GetCaptionFontSize());
 	m_DittoWindow.m_bDrawMaximize = false;
 	m_DittoWindow.m_bDrawMinimize = false;
-	m_DittoWindow.m_bDrawChevron = false;
+	m_DittoWindow.m_bDrawChevron = true;
 	m_DittoWindow.m_sendWMClose = false;
 
     m_RichEdit.Create(_T(""), _T(""), WS_CHILD | WS_VISIBLE | WS_VSCROLL |
@@ -230,6 +235,12 @@ BOOL CToolTipEx::Show(CPoint point)
 
 	m_clipDataStatic.SetWindowText(m_clipData);	
 
+	if (m_DittoWindow.m_bMinimized)
+	{
+		//m_DittoWindow.MinMaxWindow(this, FORCE_MAX);
+		m_DittoWindow.m_bMinimized = false;
+	}
+
 	m_saveWindowLockout = true;
 	MoveWindow(rect);	
 	ShowWindow(SW_SHOWNA);	
@@ -241,6 +252,17 @@ BOOL CToolTipEx::Show(CPoint point)
     return TRUE;
 }
 
+void CToolTipEx::GetWindowRectEx(LPRECT lpRect)
+{
+	if (m_DittoWindow.m_bMinimized)
+	{
+		*lpRect = m_DittoWindow.m_crFullSizeWindow;
+		return;
+	}
+
+	CWnd::GetWindowRect(lpRect);
+}
+
 BOOL CToolTipEx::Hide()
 {
 	DELETE_BITMAP
@@ -275,7 +297,16 @@ void CToolTipEx::SaveWindowSize()
 	if (::IsWindowVisible(m_hWnd))
 	{
 		CRect rect;
-		this->GetWindowRect(&rect);
+
+		if (m_DittoWindow.m_bMinimized)
+		{
+			rect = m_DittoWindow.m_crFullSizeWindow;
+		}
+		else
+		{
+			this->GetWindowRect(&rect);
+		}		
+		
 		CGetSetOptions::SetDescWndSize(rect.Size());
 		CGetSetOptions::SetDescWndPoint(rect.TopLeft());
 
@@ -300,20 +331,6 @@ BOOL CToolTipEx::PreTranslateMessage(MSG *pMsg)
 
             switch(pMsg->wParam)
             {
-            case VK_ESCAPE:
-                Hide();
-                return TRUE;
-			case 'W':
-				OnFirstWraptext();				
-				return TRUE;
-				break;
-			case VK_SPACE:
-				if (GetKeyState(VK_CONTROL) & 0x8000)
-				{
-					OnFirstAlwaysontop();
-					return TRUE;
-				}
-				break;
             case 'C':
                 if(GetKeyState(VK_CONTROL) &0x8000)
                 {
@@ -339,6 +356,27 @@ BOOL CToolTipEx::PreTranslateMessage(MSG *pMsg)
 			break;
     }
 
+	if (m_pToolTipActions != NULL)
+	{
+		CAccel a;
+		if (m_pToolTipActions->OnMsg(pMsg, a))
+		{
+			switch (a.Cmd)
+			{
+			case ActionEnums::CLOSEWINDOW:
+				if (this->m_showPersistant &&
+					m_DittoWindow.m_bMinimized == false)
+				{
+					m_DittoWindow.MinMaxWindow(this, FORCE_MIN);
+					theApp.m_activeWnd.ReleaseFocus();
+
+					return TRUE;
+				}
+				break;
+			}
+		}
+	}
+
     return CWnd::PreTranslateMessage(pMsg);
 }
 
@@ -369,21 +407,13 @@ BOOL CToolTipEx::OnMsg(MSG *pMsg)
         case WM_KEYDOWN:
             {
                 WPARAM vk = pMsg->wParam;
-                if(vk == VK_ESCAPE)
-                {
-                    Hide();
-                    return TRUE;
-                }
-                else if(vk == VK_TAB)
+                
+                if(vk == VK_TAB)
                 {
                     m_RichEdit.SetFocus();
                     return TRUE;
                 }
-				else if(vk == 'N')
-				{
-					return FALSE;
-				}
-				else if (vk == 'P')
+				else if (vk == VK_CONTROL || vk == VK_SHIFT)
 				{
 					return FALSE;
 				}
@@ -395,23 +425,13 @@ BOOL CToolTipEx::OnMsg(MSG *pMsg)
 				{
 					return FALSE;
 				}
-				else if(vk == VK_F3)
-				{
-					DoSearch();
 
-					return TRUE;
-				}
-				else if(vk == VK_SHIFT)
+				if (m_pToolTipActions != NULL)
 				{
-					return FALSE;
-				}
-				else if(vk == VK_NEXT)
-				{
-					return FALSE;
-				}
-				else if (vk == VK_PRIOR)
-				{
-					return FALSE;
+					if (m_pToolTipActions->ContainsKey(vk))
+					{
+						return FALSE;
+					}
 				}
 
 				if (m_showPersistant == false)
@@ -823,6 +843,31 @@ void CToolTipEx::OnTimer(UINT_PTR nIDEvent)
 			}
 			break;
 		}
+		case TIMER_AUTO_MAX:
+		{
+			if (m_DittoWindow.m_bMinimized)
+			{
+				CPoint cp;
+				GetCursorPos(&cp);
+
+				UINT nHitTest = (UINT)OnNcHitTest(cp);
+
+				ScreenToClient(&cp);
+
+				if (nHitTest == HTCAPTION)
+				{
+					if (m_DittoWindow.m_crCloseBT.PtInRect(cp) == false)
+					{
+						if (m_DittoWindow.m_crMinimizeBT.PtInRect(cp) == false)
+						{
+							m_DittoWindow.MinMaxWindow(this, FORCE_MAX);
+						}
+					}
+				}
+			}
+			KillTimer(TIMER_AUTO_MAX);
+			m_bMaxSetTimer = false;
+		}
 
     }
 
@@ -872,6 +917,10 @@ void CToolTipEx::OnNcLButtonUp(UINT nHitTest, CPoint point)
 	case BUTTON_CLOSE:
 		Hide();
 		break;
+	case BUTTON_CHEVRON:
+		m_DittoWindow.MinMaxWindow(this, SWAP_MIN_MAX);
+		OnNcPaint();
+		break;
 	}
 
 	KillTimer(TIMER_BUTTON_UP);
@@ -883,6 +932,16 @@ void CToolTipEx::OnNcMouseMove(UINT nHitTest, CPoint point)
 {
 	m_DittoWindow.DoNcMouseMove(this, nHitTest, point);
 
+	if ((m_bMaxSetTimer == false) && m_DittoWindow.m_bMinimized)
+	{
+		COleDateTimeSpan sp = COleDateTime::GetCurrentTime() - m_DittoWindow.m_TimeMinimized;
+		if (sp.GetTotalSeconds() >= m_lDelayMaxSeconds)
+		{
+			SetTimer(TIMER_AUTO_MAX, CGetSetOptions::GetTimeBeforeExpandWindow(), NULL);
+			m_bMaxSetTimer = true;
+		}
+	}
+
 	CWnd::OnNcMouseMove(nHitTest, point);
 }
 
@@ -923,18 +982,27 @@ void CToolTipEx::OnOptions()
 		if (m_showPersistant)
 			cmSubMenu->CheckMenuItem(ID_FIRST_ALWAYSONTOP, MF_CHECKED);
 
+		UpdateMenuShortCut(cmSubMenu, ID_FIRST_WRAPTEXT, ActionEnums::TOGGLE_DESCRIPTION_WORD_WRAP);
+		UpdateMenuShortCut(cmSubMenu, ID_FIRST_ALWAYSONTOP, ActionEnums::TOGGLESHOWPERSISTANT);
+		
+		cmSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, pp.x, pp.y, this, NULL);
+	}
+}
+
+void CToolTipEx::UpdateMenuShortCut(CMenu *subMenu, int id, DWORD action)
+{
+	if (m_pToolTipActions != NULL)
+	{
 		CString cs;
-		cmSubMenu->GetMenuString(ID_FIRST_WRAPTEXT, cs, MF_BYCOMMAND);
-		CString shortcutText = 'W';
+		subMenu->GetMenuString(id, cs, MF_BYCOMMAND);
+		CString shortcutText = m_pToolTipActions->GetCmdKeyText(action);
 		if (shortcutText != _T("") &&
 			cs.Find("\t" + shortcutText) < 0)
 		{
 			cs += "\t";
 			cs += shortcutText;
-			cmSubMenu->ModifyMenu(ID_FIRST_WRAPTEXT, MF_BYCOMMAND, ID_FIRST_WRAPTEXT, cs);
+			subMenu->ModifyMenu(id, MF_BYCOMMAND, id, cs);
 		}
-		
-		cmSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, pp.x, pp.y, this, NULL);
 	}
 }
 
@@ -998,6 +1066,18 @@ void CToolTipEx::OnFirstHidedescriptionwindowonm()
 	CGetSetOptions::SetMouseClickHidesDescription(!CGetSetOptions::GetMouseClickHidesDescription());
 }
 
+bool CToolTipEx::ToggleWordWrap()
+{
+	bool didWordWrap = false;
+	if (m_RichEdit.IsWindowVisible())
+	{
+		OnFirstWraptext();
+		didWordWrap = true;
+	}
+
+	return didWordWrap;
+}
+
 void CToolTipEx::OnFirstWraptext()
 {
 	CGetSetOptions::SetWrapDescriptionText(!CGetSetOptions::GetWrapDescriptionText());	
@@ -1036,7 +1116,7 @@ void CToolTipEx::OnFirstAlwaysontop()
 	{
 		m_DittoWindow.m_customWindowTitle = _T("[Always on top]");
 		m_DittoWindow.m_useCustomWindowTitle = true;
-		::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
+		::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE);
 	}
 	else
 	{

+ 11 - 0
ToolTipEx.h

@@ -6,6 +6,7 @@
 #include "GdipButton.h"
 #include "ImageViewer.h"
 #include "GroupStatic.h"
+#include "Accels.h"
 
 class CToolTipEx : public CWnd
 {
@@ -40,6 +41,13 @@ public:
 	void SetClipData(CString data) { m_clipData = data; }
 
 	bool GetShowPersistant() { return m_showPersistant; }
+	void ToggleShowPersistant() { OnFirstAlwaysontop(); }
+	bool ToggleWordWrap();
+	void SetTooltipActions(CAccels *pToolTipActions) { m_pToolTipActions = pToolTipActions; }
+
+	void GetWindowRectEx(LPRECT lpRect);
+
+	void UpdateMenuShortCut(CMenu *subMenu, int id, DWORD action);
 
 // Overrides
 	// ClassWizard generated virtual function overrides
@@ -75,6 +83,9 @@ protected:
 	bool m_saveWindowLockout;
 	int m_clipRow;
 	bool m_showPersistant;
+	CAccels *m_pToolTipActions;
+	bool m_bMaxSetTimer;
+	int m_lDelayMaxSeconds;
 
 protected:
 	CString GetFieldFromString(CString ref, int nIndex, TCHAR ch);

+ 10 - 120
WndEx.cpp

@@ -24,7 +24,6 @@ static char THIS_FILE[] = __FILE__;
 CWndEx::CWndEx()
 {	
 	SetCaptionColorActive(false, TRUE);
-	m_crFullSizeWindow.SetRectEmpty();
 	m_lDelayMaxSeconds = 2;
 }
 
@@ -41,7 +40,7 @@ void CWndEx::GetWindowRectEx(LPRECT lpRect)
 {
 	if(m_DittoWindow.m_bMinimized)
 	{
-		*lpRect = m_crFullSizeWindow;
+		*lpRect = m_DittoWindow.m_crFullSizeWindow;
 		return;
 	}
 	
@@ -183,7 +182,8 @@ void CWndEx::OnNcLButtonUp(UINT nHitTest, CPoint point)
 	{
 		if(lRet == BUTTON_CHEVRON)
 		{
-			MinMaxWindow();
+			MinMaxWindow(SWAP_MIN_MAX);
+			OnNcPaint();
 		}
 		return;
 	}
@@ -193,122 +193,7 @@ void CWndEx::OnNcLButtonUp(UINT nHitTest, CPoint point)
 	CWnd::OnNcLButtonUp(nHitTest, point);
 }
 
-void CWndEx::MinMaxWindow(long lOption)
-{
-	if((m_DittoWindow.m_bMinimized) && (lOption == FORCE_MIN))
-		return;
-	
-	if((m_DittoWindow.m_bMinimized == false) && (lOption == FORCE_MAX))
-		return;
-	
-	if(m_DittoWindow.m_lRightBorder == m_DittoWindow.m_captionBorderWidth)
-	{		
-		if(m_DittoWindow.m_bMinimized == false)
-		{
-			GetWindowRect(m_crFullSizeWindow);
-			MoveWindow(m_crFullSizeWindow.right - m_DittoWindow.m_captionBorderWidth,
-				m_crFullSizeWindow.top, m_DittoWindow.m_captionBorderWidth,
-				m_crFullSizeWindow.Height());
-			m_DittoWindow.m_bMinimized = true;
-			m_TimeMinimized = COleDateTime::GetCurrentTime();
-			OnNcPaint();
-		}
-		else
-		{
-			CRect cr;
-			GetWindowRect(cr);
-			MoveWindow(cr.right - m_crFullSizeWindow.Width(),
-				cr.top, m_crFullSizeWindow.Width(), cr.Height());
-			
-			m_crFullSizeWindow.SetRectEmpty();
-			m_DittoWindow.m_bMinimized = false;
-			m_TimeMaximized = COleDateTime::GetCurrentTime();
-			::SetForegroundWindow(this->GetSafeHwnd());
-			OnNcPaint();
-		}
-	}
-	if(m_DittoWindow.m_lLeftBorder == m_DittoWindow.m_captionBorderWidth)
-	{
-		if(m_DittoWindow.m_bMinimized == false)
-		{
-			GetWindowRect(m_crFullSizeWindow);
-			MoveWindow(m_crFullSizeWindow.left,
-				m_crFullSizeWindow.top, m_DittoWindow.m_captionBorderWidth,
-				m_crFullSizeWindow.Height());
-			m_DittoWindow.m_bMinimized = true;
-			m_TimeMinimized = COleDateTime::GetCurrentTime();
-			OnNcPaint();
-		}
-		else
-		{
-			CRect cr;
-			GetWindowRect(cr);
-			MoveWindow(cr.left, cr.top, 
-				m_crFullSizeWindow.Width(), cr.Height());
-			
-			m_crFullSizeWindow.SetRectEmpty();
-			m_DittoWindow.m_bMinimized = false;
-			m_TimeMaximized = COleDateTime::GetCurrentTime();
-			::SetForegroundWindow(this->GetSafeHwnd());
-			OnNcPaint();
-		}
-	}
-	else if(m_DittoWindow.m_lTopBorder == m_DittoWindow.m_captionBorderWidth)
-	{
-		if(m_DittoWindow.m_bMinimized == false)
-		{
-			GetWindowRect(m_crFullSizeWindow);
-			MoveWindow(m_crFullSizeWindow.left,
-				m_crFullSizeWindow.top, 
-				m_crFullSizeWindow.Width(), 
-				m_DittoWindow.m_captionBorderWidth);
-			m_DittoWindow.m_bMinimized = true;
-			m_TimeMinimized = COleDateTime::GetCurrentTime();
-			OnNcPaint();
-		}
-		else
-		{
-			CRect cr;
-			GetWindowRect(cr);
-			MoveWindow(cr.left, cr.top, 
-				cr.Width(), m_crFullSizeWindow.Height());
-			
-			m_crFullSizeWindow.SetRectEmpty();
-			m_DittoWindow.m_bMinimized = false;
-			m_TimeMaximized = COleDateTime::GetCurrentTime();
-			::SetForegroundWindow(this->GetSafeHwnd());
-			OnNcPaint();
-		}
-	}
-	else if(m_DittoWindow.m_lBottomBorder == m_DittoWindow.m_captionBorderWidth)
-	{
-		if(m_DittoWindow.m_bMinimized == false)
-		{
-			GetWindowRect(m_crFullSizeWindow);
-			MoveWindow(m_crFullSizeWindow.left,
-				m_crFullSizeWindow.bottom - m_DittoWindow.m_captionBorderWidth,
-				m_crFullSizeWindow.Width(), 
-				m_DittoWindow.m_captionBorderWidth);
-			m_DittoWindow.m_bMinimized = true;
-			m_TimeMinimized = COleDateTime::GetCurrentTime();
-			OnNcPaint();
-		}
-		else
-		{
-			CRect cr;
-			GetWindowRect(cr);
-			MoveWindow(cr.left, 
-				cr.bottom - m_crFullSizeWindow.Height(), 
-				cr.Width(), m_crFullSizeWindow.Height());
-			
-			m_crFullSizeWindow.SetRectEmpty();
-			m_DittoWindow.m_bMinimized = false;
-			m_TimeMaximized = COleDateTime::GetCurrentTime();
-			::SetForegroundWindow(this->GetSafeHwnd());
-			OnNcPaint();
-		}
-	}
-}
+
 
 void CWndEx::OnNcMouseMove(UINT nHitTest, CPoint point) 
 {
@@ -316,7 +201,7 @@ void CWndEx::OnNcMouseMove(UINT nHitTest, CPoint point)
 
 	if((m_bMaxSetTimer == false) && m_DittoWindow.m_bMinimized)
 	{
-		COleDateTimeSpan sp = COleDateTime::GetCurrentTime() - m_TimeMinimized;
+		COleDateTimeSpan sp = COleDateTime::GetCurrentTime() - m_DittoWindow.m_TimeMinimized;
 		if(sp.GetTotalSeconds() >= m_lDelayMaxSeconds)
 		{
 			SetTimer(TIMER_AUTO_MAX, CGetSetOptions::GetTimeBeforeExpandWindow(), NULL);
@@ -419,4 +304,9 @@ void CWndEx::SetCustomWindowTitle(CString title)
 	{
 		this->InvalidateNc();
 	}
+}
+
+void CWndEx::MinMaxWindow(long lOption)
+{
+	m_DittoWindow.MinMaxWindow(this, lOption);
 }

+ 2 - 4
WndEx.h

@@ -51,10 +51,8 @@ public:
 
 protected:
 	CDittoWindow m_DittoWindow;
-	CRect m_crFullSizeWindow;
-	bool m_bMaxSetTimer;
-	COleDateTime m_TimeMinimized;
-	COleDateTime m_TimeMaximized;
+	
+	bool m_bMaxSetTimer;	
 	int m_lDelayMaxSeconds;
 	CToolTipCtrl m_toolTip;