
Modeless Dialog with Progress Bar
I have written an application which puts up a modal dialog
box and prompts the user for some input information. I
then create a modeless dialog box with a progress bar. I
then start running some code which can take a long time
to run. This code sends progress data to the modeless dialog
box to update the progress bar. This all works fine but
I would like to add an abort button in the modeless dialog.
I have tried this I can't get the abort button to work. Does
anyone know how to get this to work? Below is an example of
how I put the application together.
One other thing I noticed is I get the hour glass if I do
not call the modal dialog before calling DriverMain.
Thanks.
#include "CDriver.h"
#include "CDriverDlg.h"
#include "utility.h"
CDriverApp gcDriverApp;
CDriverApp *gcpApplication;
BEGIN_MESSAGE_MAP(CDriverApp, CWinApp)
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
CDriverApp::CDriverApp()
{
gcpApplication = this;
}
BOOL CDriverApp::InitInstance()
{
CDriverDlg cDriverDlg;
cDriverDlg.m_strStartTime = m_strStartTime;
cDriverDlg.m_strEndTime = m_strEndTime ;
cDriverDlg.m_strFrequency = m_strFrequency;
if (IDOK == cDriverDlg.DoModal())
{
m_strStartTime = cDriverDlg.m_strStartTime;
m_strEndTime = cDriverDlg.m_strEndTime ;
m_strFrequency = cDriverDlg.m_strFrequency;
DriverMain();
}
return FALSE;
}
BOOL CDriverApp::DriverMain()
{
CExecuteDlg cDlg;
cDlg.Create(IDD_EXECUTE);
cDlg.UpdateWindow();
for (m_cClock.m_iTimeCounter = m_cClock.m_iStartCounter;
m_cClock.m_iTimeCounter <= m_cClock.m_iEndCounter ;
m_cClock.m_iTimeCounter++)
{
DO SOME STUFF HERE
INT iTimeRatio = INT(100.0F * (m_fTime / m_fEndTime));
SendMessage(cDlg.m_hWnd, WM_COMMAND, IDC_UPDATE_TIME,
LPARAM(iTimeRatio));
}
cDlg.DestroyWindow();
return FALSE;
}
--
Remove the PPP for the correct email address.