HRESULT CSaveTaskDlg::OnTimer(_In_ long lTime) { static UINT sizeUnits[] = { IDS_SIZE_UNIT_K, IDS_SIZE_UNIT_M, IDS_SIZE_UNIT_G }; static UINT speedUnits[] = { IDS_SPEED_UNIT_K, IDS_SPEED_UNIT_M, IDS_SPEED_UNIT_G }; if (pGB && pMS) { CString str; REFERENCE_TIME pos = 0, dur = 0; pMS->GetCurrentPosition(&pos); pMS->GetDuration(&dur); REFERENCE_TIME time = 0; CComQIPtr<IMediaSeeking>(pGB)->GetCurrentPosition(&time); REFERENCE_TIME speed = time > 0 ? pos*10000000/time : 0; double dPos = pos / 1024.; unsigned int unitPos = AdaptUnit(dPos, _countof(sizeUnits)); double dDur = dur / 1024.; unsigned int unitDur = AdaptUnit(dDur, _countof(sizeUnits)); double dSpeed = speed / 1024.; unsigned int unitSpeed = AdaptUnit(dSpeed, _countof(speedUnits)); str.Format(_T("%.2lf %s / %.2lf %s , %.2lf %s"), dPos, ResStr(sizeUnits[unitPos]), dDur, ResStr(sizeUnits[unitDur]), dSpeed, ResStr(speedUnits[unitSpeed])); if (speed > 0) { str.Append(_T(",")); REFERENCE_TIME sec = (dur-pos) / speed; DVD_HMSF_TIMECODE tcDur = { (BYTE)(sec / 3600), (BYTE)(sec / 60 % 60), (BYTE)(sec % 60), 0 }; if (tcDur.bHours > 0) { str.AppendFormat(_T(" %0.2dh"), tcDur.bHours); } if (tcDur.bMinutes > 0) { str.AppendFormat(_T(" %0.2dm"), tcDur.bMinutes); } if (tcDur.bSeconds > 0) { str.AppendFormat(_T(" %0.2ds"), tcDur.bSeconds); } } SetContent(str); SetProgressBarPosition(dur > 0 ? (int)(100*pos/dur) : 0); if (dur && pos >= dur) { ::SendMessage(m_TaskDlgHwnd, TDM_CLICK_BUTTON, static_cast<WPARAM>(TDCBF_CANCEL_BUTTON), 0); return S_FALSE; } } return S_OK; }
CSaveTaskDlg::CSaveTaskDlg(CString in, CString name, CString out) : CTaskDialog(_T(""), name + _T("\n") + out, ResStr(IDS_SAVE_FILE), TDCBF_CANCEL_BUTTON, TDF_CALLBACK_TIMER|TDF_POSITION_RELATIVE_TO_WINDOW) , m_in(in) , m_out(out) , m_TaskDlgHwnd(0) { m_hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); if (m_hIcon != NULL) { SetMainIcon(m_hIcon); } SetProgressBarMarquee(); SetProgressBarRange(0, 100); SetProgressBarPosition(0); SetDialogWidth(250); InitFileCopy(); }
void CMainFrame::IncrProgressBarPosition() { m_nCurrentPos++; SetProgressBarPosition(m_nCurrentPos); }