Bläddra i källkod

Re add the taskbar icon when explorer is restarted

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@771 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 10 år sedan
förälder
incheckning
32dff04bd3
9 ändrade filer med 90 tillägg och 7 borttagningar
  1. 2 0
      CP_Main.vcxproj
  2. 12 2
      CP_Main.vcxproj.filters
  3. 13 3
      MainFrm.cpp
  4. 1 0
      MainFrm.h
  5. 1 0
      Misc.h
  6. 4 1
      SystemTray.cpp
  7. 3 1
      SystemTray.h
  8. 38 0
      TrayWnd.cpp
  9. 16 0
      TrayWnd.h

+ 2 - 0
CP_Main.vcxproj

@@ -1630,6 +1630,7 @@
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
+    <ClCompile Include="TrayWnd.cpp" />
     <ClCompile Include="UAC_Helper.cpp" />
     <ClCompile Include="UAC_Thread.cpp" />
     <ClCompile Include="WildCardMatch.cpp" />
@@ -1872,6 +1873,7 @@
     <ClInclude Include="sqlite\sqlite3.h" />
     <ClInclude Include="sqlite\sqlite3ext.h" />
     <ClInclude Include="ToolTipEx.h" />
+    <ClInclude Include="TrayWnd.h" />
     <ClInclude Include="UAC_Helper.h" />
     <ClInclude Include="UAC_Thread.h" />
     <ClInclude Include="WildCardMatch.h" />

+ 12 - 2
CP_Main.vcxproj.filters

@@ -385,10 +385,15 @@
     <ClCompile Include="QRCodeViewer.cpp">
       <Filter>source</Filter>
     </ClCompile>
-    <ClCompile Include="SpecialPasteOptions.cpp" />
     <ClCompile Include="DrawHTML.C">
       <Filter>source</Filter>
     </ClCompile>
+    <ClCompile Include="TrayWnd.cpp">
+      <Filter>source</Filter>
+    </ClCompile>
+    <ClCompile Include="SpecialPasteOptions.cpp">
+      <Filter>source</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="sqlite\CppSQLite3.h">
@@ -826,10 +831,15 @@
     <ClInclude Include="QRCodeViewer.h">
       <Filter>header</Filter>
     </ClInclude>
-    <ClInclude Include="SpecialPasteOptions.h" />
     <ClInclude Include="DrawHTML.h">
       <Filter>header</Filter>
     </ClInclude>
+    <ClInclude Include="SpecialPasteOptions.h">
+      <Filter>header</Filter>
+    </ClInclude>
+    <ClInclude Include="TrayWnd.h">
+      <Filter>header</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="CP_Main.rc">

+ 13 - 3
MainFrm.cpp

@@ -26,8 +26,7 @@
 
 #define WM_ICON_NOTIFY			WM_APP+10
 #define MYWM_NOTIFYICON (WM_USER+1)
-
-
+	
 IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
 
 	BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
@@ -64,6 +63,7 @@ IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
 	ON_MESSAGE(WM_DELETE_CLIPS_CLOSED, OnDeleteClipDataClosed)
 	ON_COMMAND(ID_FIRST_SAVECURRENTCLIPBOARD, &CMainFrame::OnFirstSavecurrentclipboard)
 	ON_MESSAGE(WM_SAVE_CLIPBOARD, &CMainFrame::OnSaveClipboardMessage)
+	ON_MESSAGE(WM_READD_TASKBAR_ICON, OnReAddTaskBarIcon)
 	END_MESSAGE_MAP()
 
 	static UINT indicators[] = 
@@ -103,7 +103,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
     CRect rcScreen;
     GetMonitorRect(0, &rcScreen);
     CPoint cpCenter = rcScreen.CenterPoint();
-    MoveWindow(cpCenter.x, cpCenter.x,  - 2,  - 2);
+    //MoveWindow(cpCenter.x, cpCenter.x,  - 2,  - 2);
 
     //Then set the main window to transparent so it's never shown
     //if it is shown then only the task tray icon
@@ -650,6 +650,7 @@ LRESULT CMainFrame::OnClipboardCopied(WPARAM wParam, LPARAM lParam)
 
 BOOL CMainFrame::PreTranslateMessage(MSG *pMsg)
 {
+	
     // target before mouse messages change the focus
 	/*if(theApp.m_bShowingQuickPaste && WM_MOUSEFIRST <= pMsg->message && pMsg->message <= WM_MOUSELAST)
 	{
@@ -1112,3 +1113,12 @@ void CMainFrame::OnFirstSavecurrentclipboard()
 	}
 	Log(_T("Start Saving the current clipboard to the database"));
 }
+
+LRESULT CMainFrame::OnReAddTaskBarIcon(WPARAM wParam, LPARAM lParam)
+{
+	if(CGetSetOptions::GetShowIconInSysTray())
+	{
+		m_TrayIcon.AddIcon();
+	}
+	return TRUE;
+}

+ 1 - 0
MainFrm.h

@@ -110,6 +110,7 @@ protected:
 	afx_msg LRESULT OnOptionsClosed(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnShowOptions(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnSaveClipboardMessage(WPARAM wParam, LPARAM lParam);
+	afx_msg LRESULT OnReAddTaskBarIcon(WPARAM wParam, LPARAM lParam);
 DECLARE_MESSAGE_MAP()public:
     virtual BOOL PreTranslateMessage(MSG *pMsg);
     afx_msg void OnClose();

+ 1 - 0
Misc.h

@@ -124,6 +124,7 @@ CString GetProcessName(HWND hWnd);
 #define WM_DELETE_CLIPS_CLOSED	WM_USER	+ 221
 #define WM_OPEN_CLOSE_WINDWOW WM_USER + 222
 #define WM_SAVE_CLIPBOARD WM_USER + 223
+#define WM_READD_TASKBAR_ICON WM_USER + 224
 
 
 #if !defined(_BITSET_)

+ 4 - 1
SystemTray.cpp

@@ -97,7 +97,7 @@ IMPLEMENT_DYNAMIC(CSystemTray, CWnd)
 const UINT CSystemTray::m_nTimerID    = 4567;
 UINT CSystemTray::m_nMaxTooltipLength  = 64;     // This may change...
 const UINT CSystemTray::m_nTaskbarCreatedMsg = ::RegisterWindowMessage(_T("TaskbarCreated"));
-CWnd  CSystemTray::m_wndInvisible;
+CTrayWnd  CSystemTray::m_wndInvisible;
 BOOL CSystemTray::m_bShowWndAnimation;
 
 /////////////////////////////////////////////////////////////////////////////
@@ -1073,7 +1073,10 @@ BOOL CSystemTray::RemoveTaskbarIcon(CWnd* pWnd)
 		if (!m_wndInvisible.CreateEx(0, pstrOwnerClass, _T(""), WS_POPUP,
 			CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
 			NULL, 0))
+		{
 			return FALSE;
+		}
+		
     }
 	
     pWnd->SetParent(&m_wndInvisible);

+ 3 - 1
SystemTray.h

@@ -48,6 +48,8 @@
 #include <afxtempl.h>
 #include <afxdisp.h>    // COleDateTime
 
+#include "TrayWnd.h"
+
 /////////////////////////////////////////////////////////////////////////////
 // CSystemTray window
 
@@ -176,7 +178,7 @@ protected:
     static const UINT m_nTimerID;
     static UINT  m_nMaxTooltipLength;
     static const UINT m_nTaskbarCreatedMsg;
-    static CWnd  m_wndInvisible;
+    static CTrayWnd  m_wndInvisible;
 	static BOOL	 m_bShowWndAnimation;
 
     static BOOL GetW2K();

+ 38 - 0
TrayWnd.cpp

@@ -0,0 +1,38 @@
+// TrayWnd.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "CP_Main.h"
+#include "TrayWnd.h"
+
+
+// CTrayWnd
+
+UINT WM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated"));
+
+IMPLEMENT_DYNAMIC(CTrayWnd, CWnd)
+
+CTrayWnd::CTrayWnd()
+{
+}
+
+CTrayWnd::~CTrayWnd()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CTrayWnd, CWnd)
+	ON_REGISTERED_MESSAGE(WM_TASKBARCREATED, OnTaskBarCreated)
+END_MESSAGE_MAP()
+
+LRESULT CTrayWnd::OnTaskBarCreated(WPARAM wParam, LPARAM lParam)
+{
+	if(theApp.m_pMainFrame != NULL)
+	{
+		theApp.m_pMainFrame->PostMessage(WM_READD_TASKBAR_ICON, 0, 0);
+	}
+	
+	return TRUE;
+}
+
+

+ 16 - 0
TrayWnd.h

@@ -0,0 +1,16 @@
+#pragma once
+
+class CTrayWnd : public CWnd
+{
+	DECLARE_DYNAMIC(CTrayWnd)
+
+public:
+	CTrayWnd();
+	virtual ~CTrayWnd();
+
+protected:
+	DECLARE_MESSAGE_MAP()
+	LRESULT OnTaskBarCreated(WPARAM wParam, LPARAM lParam);
+};
+
+