From 006808a9d073389f682b85f748c099379f55caab Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Fri, 1 Apr 2011 03:57:34 +0200 Subject: [PATCH] show status in taskbar icon on Win7 Signed-off-by: Sven Strickroth --- src/TortoiseProc/ImportPatchDlg.cpp | 44 +++++++++++++++++++++++++++++++++++-- src/TortoiseProc/ImportPatchDlg.h | 4 ++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/TortoiseProc/ImportPatchDlg.cpp b/src/TortoiseProc/ImportPatchDlg.cpp index d023bba71..83dc4d471 100644 --- a/src/TortoiseProc/ImportPatchDlg.cpp +++ b/src/TortoiseProc/ImportPatchDlg.cpp @@ -96,7 +96,26 @@ void CImportPatchDlg::SetSplitterRange() BOOL CImportPatchDlg::OnInitDialog() { CResizableStandAloneDialog::OnInitDialog(); - + + // Let the TaskbarButtonCreated message through the UIPI filter. If we don't + // do this, Explorer would be unable to send that message to our window if we + // were running elevated. It's OK to make the call all the time, since if we're + // not elevated, this is a no-op. + CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) }; + typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct); + HMODULE hUser = ::LoadLibrary(_T("user32.dll")); + if (hUser) + { + ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx"); + if (pfnChangeWindowMessageFilterEx) + { + pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs); + } + FreeLibrary(hUser); + } + m_pTaskbarList.Release(); + m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList); + CRect rectDummy; GetClientRect(m_DlgOrigRect); @@ -196,6 +215,7 @@ BEGIN_MESSAGE_MAP(CImportPatchDlg, CResizableStandAloneDialog) ON_WM_SIZE() ON_BN_CLICKED(IDCANCEL, &CImportPatchDlg::OnBnClickedCancel) ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_PATCH, &CImportPatchDlg::OnHdnItemchangedListPatch) + ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED, OnTaskbarBtnCreated) END_MESSAGE_MAP() @@ -294,6 +314,12 @@ UINT CImportPatchDlg::PatchThread() for(i=m_CurrentItem;iSetProgressState(m_hWnd, TBPF_NORMAL); + m_pTaskbarList->SetProgressValue(m_hWnd, i+1, m_cList.GetItemCount()); + } + m_cList.SetItemData(i, CPatchListCtrl::STATUS_APPLYING|m_cList.GetItemData(i)); if(m_bExitThread) @@ -305,6 +331,9 @@ UINT CImportPatchDlg::PatchThread() while(path.HasRebaseApply()) { + if (m_pTaskbarList) + m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR); + int ret = CMessageBox::Show(NULL, _T("previous rebase directory rebase-apply still exists but mbox given\n\n Do you want to"), _T("TortoiseGit"), 1,IDI_ERROR ,_T("&Abort"), _T("&Skip"),_T("&Resolved")); @@ -367,6 +396,8 @@ UINT CImportPatchDlg::PatchThread() m_cList.SetItemData(i, CPatchListCtrl::STATUS_APPLY_FAIL|CPatchListCtrl::STATUS_APPLYING); this->AddLogString(output); this->AddLogString(_T("Fail")); + if (m_pTaskbarList) + m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR); break; }else @@ -392,8 +423,10 @@ UINT CImportPatchDlg::PatchThread() this->m_cList.GetItemRect(m_CurrentItem,&rect,LVIR_BOUNDS); this->m_cList.InvalidateRect(rect); + if (m_pTaskbarList) + m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS); + UpdateOkCancelText(); - } //in case am fail, need refresh finial item status @@ -605,3 +638,10 @@ void CImportPatchDlg::OnHdnItemchangedListPatch(NMHDR * /*pNMHDR*/, LRESULT *pRe } } } + +LRESULT CImportPatchDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/) +{ + m_pTaskbarList.Release(); + m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList); + return 0; +} \ No newline at end of file diff --git a/src/TortoiseProc/ImportPatchDlg.h b/src/TortoiseProc/ImportPatchDlg.h index b2b808da2..9460ab5e3 100644 --- a/src/TortoiseProc/ImportPatchDlg.h +++ b/src/TortoiseProc/ImportPatchDlg.h @@ -29,6 +29,7 @@ #include "Balloon.h" #include "GitLogList.h" #include "MenuButton.h" +#include "Win7.h" #define MSG_REBASE_UPDATE_UI (WM_USER+151) @@ -121,6 +122,9 @@ public: afx_msg void OnSize(UINT nType, int cx, int cy); protected: virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); + + afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam); + CComPtr m_pTaskbarList; public: afx_msg void OnBnClickedCancel(); virtual BOOL PreTranslateMessage(MSG* pMsg); -- 2.11.4.GIT