How make infinite indeterminate progress bar in MFC Application?
There is my source but its not infinite as I want.
WaitProcessDlg::WaitProcessDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(WaitProcessDlg::IDD, pParent)
{
}
void WaitProcessDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
}
BEGIN_MESSAGE_MAP(WaitProcessDlg, CDialogEx)
ON_WM_TIMER()
END_MESSAGE_MAP()
BOOL WaitProcessDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
str = pApp->GetProfileString(_T("Process"), _T("Process"));
if(tempHWND = ::FindWindow(NULL, str)){
EndDialog( 0 );
}else{
CMFCRibbonProgressBar* pProgressBar = new CMFCRibbonProgressBar(IDC_PROGRESS1, pProgressBar);
pProgressBar->SetInfiniteMode(m_bInfiniteProgressMode);
pProgressBar->SetRange(0, 200);
pProgressBar->SetPos(200, true);
m_Progress.SetInfiniteMode(m_bInfiniteProgressMode);
m_Progress.SetRange(0, 100);
SetTimer(IDC_PROGRESS1, 0, NULL);
}
return TRUE;
}
void WaitProcessDlg::OnTimer(UINT nIDEvent)
{
while (m_Progress.GetPos() != 100){
if (tempHWND = ::FindWindow(NULL, str)){
EndDialog(0);
KillTimer(IDC_PROGRESS1);
}
m_Progress.OffsetPos(1);
}
while (m_Progress.GetPos() != 0){
if (tempHWND = ::FindWindow(NULL, str)){
EndDialog(0);
KillTimer(IDC_PROGRESS1);
}
m_Progress.OffsetPos(-1);
}
CDialog::OnTimer(nIDEvent);
}
I need some example or what on how to create a Indeterminate progress bars on MFC like so: Progress bar
In order to create an indeterminate progress bar (called a Marquee), you need to set the Marquee property of the progress bar to True in your dialog editor.

Then, in your InitDialog method, you need to call the SetMarquee method on the progress bar:
BOOL CMFCApplication1Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_Progress.SetMarquee(TRUE, 1); // Start the marquee
return TRUE; // return TRUE unless you set the focus to a control
}
Here is the result:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With