LRESULT CGitProgressDlg::OnCmdEnd(WPARAM wParam, LPARAM /*lParam*/) { DialogEnableWindow(IDCANCEL, FALSE); DialogEnableWindow(IDOK, TRUE); switch(wParam) { case CGitProgressList::GitProgress_Add: case CGitProgressList::GitProgress_Revert: if (DidErrorsOccur()) break; this->GetDlgItem(IDC_LOGBUTTON)->SetWindowText(CString(MAKEINTRESOURCE(IDS_COMMITBUTTON))); this->GetDlgItem(IDC_LOGBUTTON)->ShowWindow(SW_SHOW); break; } CWnd * pWndOk = GetDlgItem(IDOK); if (pWndOk && ::IsWindow(pWndOk->GetSafeHwnd())) { SendMessage(DM_SETDEFID, IDOK); GetDlgItem(IDOK)->SetFocus(); } return 0; }
UINT CGitProgressList::ProgressThread() { // The SetParams function should have loaded something for us CString temp; CString sWindowTitle; bool bSuccess = false; if(m_pPostWnd) m_pPostWnd->PostMessage(WM_PROG_CMD_START, (WPARAM)m_Command); if(m_pProgressLabelCtrl) { m_pProgressLabelCtrl->ShowWindow(SW_SHOW); m_pProgressLabelCtrl->SetWindowText(_T("")); } // SetAndClearProgressInfo(m_hWnd); m_itemCount = m_itemCountTotal; InterlockedExchange(&m_bThreadRunning, TRUE); iFirstResized = 0; bSecondResized = FALSE; m_bFinishedItemAdded = false; DWORD startTime = GetCurrentTime(); if (m_pTaskbarList && m_pPostWnd) m_pTaskbarList->SetProgressState(m_pPostWnd->GetSafeHwnd(), TBPF_INDETERMINATE); m_TotalBytesTransferred = 0; if (m_Command) bSuccess = m_Command->Run(this, sWindowTitle, m_itemCountTotal, m_itemCount); else bSuccess = false; if (!bSuccess) temp.LoadString(IDS_PROGRS_TITLEFAILED); else temp.LoadString(IDS_PROGRS_TITLEFIN); sWindowTitle = sWindowTitle + _T(" ") + temp; if (m_bSetTitle && m_pPostWnd) ::SetWindowText(m_pPostWnd->GetSafeHwnd(), sWindowTitle); KillTimer(TRANSFERTIMER); KillTimer(VISIBLETIMER); if (m_pTaskbarList && m_pPostWnd) { if (DidErrorsOccur()) { m_pTaskbarList->SetProgressState(m_pPostWnd->GetSafeHwnd(), TBPF_ERROR); m_pTaskbarList->SetProgressValue(m_pPostWnd->GetSafeHwnd(), 100, 100); } else m_pTaskbarList->SetProgressState(m_pPostWnd->GetSafeHwnd(), TBPF_NOPROGRESS); } if (m_pInfoCtrl) { CString info; if (!bSuccess) info.LoadString(IDS_PROGRS_INFOFAILED); else // this implies that command is not nullptr info = BuildInfoString(); m_pInfoCtrl->SetWindowText(info); } ResizeColumns(); DWORD time = GetCurrentTime() - startTime; CString sFinalInfo; if (!m_sTotalBytesTransferred.IsEmpty()) { temp.Format(IDS_PROGRS_TIME, (time / 1000) / 60, (time / 1000) % 60); sFinalInfo.Format(IDS_PROGRS_FINALINFO, m_sTotalBytesTransferred, (LPCTSTR)temp); if (m_pProgressLabelCtrl) m_pProgressLabelCtrl->SetWindowText(sFinalInfo); } else { if (m_pProgressLabelCtrl) m_pProgressLabelCtrl->ShowWindow(SW_HIDE); } if (m_pProgControl) m_pProgControl->ShowWindow(SW_HIDE); if (!m_bFinishedItemAdded) { CString log, str; if (bSuccess) str.LoadString(IDS_SUCCESS); else str.LoadString(IDS_FAIL); log.Format(_T("%s (%lu ms @ %s)"), str, time, CLoglistUtils::FormatDateAndTime(CTime::GetCurrentTime(), DATE_SHORTDATE, true, false)); // there's no "finished: xxx" line at the end. We add one here to make // sure the user sees that the command is actually finished. ReportString(log, CString(MAKEINTRESOURCE(IDS_PROGRS_FINISHED)), bSuccess? RGB(0,0,255) : RGB(255,0,0)); } int count = GetItemCount(); if ((count > 0)&&(m_bLastVisible)) EnsureVisible(count-1, FALSE); CLogFile logfile(g_Git.m_CurrentDir); if (logfile.Open()) { logfile.AddTimeLine(); for (size_t i = 0; i < m_arData.size(); ++i) { NotificationData * data = m_arData[i]; temp.Format(_T("%-20s : %s"), (LPCTSTR)data->sActionColumnText, (LPCTSTR)data->sPathColumnText); logfile.AddLine(temp); } if (!sFinalInfo.IsEmpty()) logfile.AddLine(sFinalInfo); logfile.Close(); } m_bCancelled = TRUE; InterlockedExchange(&m_bThreadRunning, FALSE); if (m_pPostWnd) m_pPostWnd->PostMessage(WM_PROG_CMD_FINISH, (WPARAM)m_Command, 0L); //Don't do anything here which might cause messages to be sent to the window //The window thread is probably now blocked in OnOK if we've done an auto close return 0; }