#include "stdafx.h"
#include "clamav.h"
#include "progress.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
CProgress::CProgress(CWnd* pParent)
: CDialog(CProgress::IDD, pParent)
{
m_filename = _T("bar");
m_percent = _T("");
stopPressed = FALSE;
}
void CProgress::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_FileName, m_filename);
DDX_Text(pDX, IDC_Percent, m_percent);
}
void
CProgress::SetFilename(const CString& filename)
{
if(stopPressed)
return;
m_filename = _T(filename);
CStatic *text = (CStatic *)GetDlgItem(IDC_FileName);
if(text) {
text->SetWindowText(filename);
percent = -1; } else
AfxMessageBox("Can't find IDC_FileName");
}
void
CProgress::SetPercent(int p)
{
if((p < 0) || (p > 100))
return;
if(p == percent)
return;
char buf[5];
sprintf(buf, "%d%%", p);
CStatic *text = (CStatic *)GetDlgItem(IDC_Percent);
if(text) {
text->SetWindowText(buf);
percent = p;
} else
AfxMessageBox("Can't find IDC_Percent");
}
const BOOL
CProgress::IsStopPressed(void)
{
return stopPressed;
}
BEGIN_MESSAGE_MAP(CProgress, CDialog)
ON_BN_CLICKED(IDSTOP, OnStop)
END_MESSAGE_MAP()
void CProgress::OnStop()
{
stopPressed = TRUE;
CButton *stopButton = (CButton *)GetDlgItem(IDSTOP);
if(stopButton)
stopButton->EnableWindow(FALSE);
}