Pārlūkot izejas kodu

show balloon tooltip on start and on error messages

ScottBrogden 8 gadi atpakaļ
vecāks
revīzija
7a0b132ea1
5 mainītis faili ar 26 papildinājumiem un 18 dzēšanām
  1. 2 0
      Debug/Language/English.xml
  2. 10 17
      MainFrm.cpp
  3. 1 1
      NTray.h
  4. 10 0
      Options.cpp
  5. 3 0
      Options.h

+ 2 - 0
Debug/Language/English.xml

@@ -411,6 +411,8 @@
 		
 		<Item English_Text = "[Disconnected]" ID = "disconnected"></Item>
 		
+		<Item English_Text = "Ditto is running minimized, Ditto can be opened by hot keys or by clicking the task tray icon" ID = "StartuMsg"></Item>
+		
 				
 	</Ditto_String_Table>
 	<Ditto_Options_Sheet>

+ 10 - 17
MainFrm.cpp

@@ -133,6 +133,9 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 	m_trayIcon.SetDefaultMenuItem(ID_FIRST_SHOWQUICKPASTE, FALSE);	    
     m_trayIcon.MinimiseToTray(this);
 
+	CString msg = theApp.m_Language.GetString(_T("StartupMsg"), _T("Ditto is running minimized, Ditto can be opened by hot keys or by clicking the task tray icon"));
+	m_trayIcon.SetBalloonDetails(msg, _T("Ditto"), CTrayNotifyIcon::BalloonStyle::Info, CGetSetOptions::GetBalloonTimeout());
+
 	theApp.m_Language.UpdateTrayIconRightClickMenu(&m_trayIcon.GetMenu());
 	
     //Only if in release
@@ -170,6 +173,12 @@ LRESULT CMainFrame::OnTrayNotification(WPARAM wParam, LPARAM lParam)
 	{
 		theApp.m_activeWnd.TrackActiveWnd(true);
 	}
+
+	//click on balloon
+	if (lParam == 0x405)
+	{
+		m_quickPaste.ShowQPasteWnd(this, false, false, FALSE);
+	}
 	
 	m_trayIcon.OnTrayNotification(wParam, lParam);
 	return 0L;
@@ -981,23 +990,7 @@ void CMainFrame::OnFirstHelp()
 void CMainFrame::ShowErrorMessage(CString csTitle, CString csMessage)
 {
     Log(StrF(_T("ShowErrorMessage %s - %s"), csTitle, csMessage));
-
-    CToolTipEx *pErrorWnd = new CToolTipEx;
-    pErrorWnd->Create(this);
-    pErrorWnd->SetToolTipText(csTitle + "\n\n" + csMessage);
-
-    CPoint pt;
-    CRect rcScreen;
-    GetMonitorRect(0, &rcScreen);
-    pt = rcScreen.BottomRight();
-
-    CRect cr = pErrorWnd->GetBoundsRect();
-
-    pt.x -= max(cr.Width() + 50, 150);
-    pt.y -= max(cr.Height() + 50, 150);
-
-    pErrorWnd->Show(pt);
-    pErrorWnd->HideWindowInXMilliSeconds(4000);
+	m_trayIcon.SetBalloonDetails(csMessage, csTitle, CTrayNotifyIcon::BalloonStyle::Error, CGetSetOptions::GetBalloonTimeout());
 }
 
 void CMainFrame::OnFirstImport()

+ 1 - 1
NTray.h

@@ -239,7 +239,7 @@ public:
   BOOL IsHidden() const { return m_bHidden; };
 
 //Sets or gets the Balloon style tooltip settings
-  BOOL         SetBalloonDetails(_In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ BalloonStyle style, _In_ UINT nTimeout, _In_ HICON hUserIcon = NULL, _In_ BOOL bNoSound = FALSE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_ HICON hBalloonIcon = NULL);
+  BOOL         SetBalloonDetails(_In_ LPCTSTR pszBalloonText, _In_ LPCTSTR pszBalloonCaption, _In_ BalloonStyle style, _In_ UINT nTimeout, _In_ HICON hUserIcon = NULL, _In_ BOOL bNoSound = TRUE, _In_ BOOL bLargeIcon = FALSE, _In_ BOOL bRealtime = FALSE, _In_ HICON hBalloonIcon = NULL);
   String       GetBalloonText() const;
   String       GetBalloonCaption() const;
   BalloonStyle GetBalloonStyle() const;

+ 10 - 0
Options.cpp

@@ -2402,4 +2402,14 @@ BOOL CGetSetOptions::GetCheckMd5OnFileTransfers()
 void CGetSetOptions::SetCheckMd5OnFileTransfers(int val)
 {
 	SetProfileLong(_T("CheckMd5OnFileTransfers"), val);
+}
+
+int CGetSetOptions::GetBalloonTimeout()
+{
+	return GetProfileLong(_T("BalloonTimeout"), 2500);
+}
+
+void CGetSetOptions::SetBalloonTimeout(int val)
+{
+	SetProfileLong(_T("BalloonTimeout"), val);
 }

+ 3 - 0
Options.h

@@ -543,6 +543,9 @@ public:
 
 	static BOOL GetCheckMd5OnFileTransfers();
 	static void SetCheckMd5OnFileTransfers(int val);
+
+	static int GetBalloonTimeout();
+	static void SetBalloonTimeout(int val);
 };
 
 // global for easy access and for initialization of fast access variables