Hi,
My suggestions
1. Do not create m_dlg dialog in SaveAll function in View Class. Instead of doing this, you can simply create a thread.
2. Declare two Global Variables,
int CurrentProgressCount;
CString CurrentFile;
This would change your SaveAll function and it may appear like.
//SaveAllImage() in View Class.
CurrentProgressCount = 0;
CurrentFile = "";
CString temp=m_SavePath;
int num=pDoc->GetNoOfImages(); //Get Total num of loaded images
[B]/[COLOR="Red"]/Create a Thread routine.
(HANDLE)_beginthreadex( NULL, 0, &ProgressDlgThread, (void *) this, 0, 0);[/COLOR]
[/B]
for(int i=0;i<=num;i++) // loop for start image to end image
{
CString ImageName=pDoc->m_ImageNames[i]; // Get Image name
m_SavePath=m_SavePath+"\\"+ImageName+"_DepthMap"+p Doc->GetImageExten(); // Get Image Path
GoldImage Test;
Test.SetImage(m_DMapImage);
Test.SaveImage(m_DMapSavePath); // Save Image
m_SavePath=temp;
[B][COLOR="Red"]CurrentFile = ImageName;
CurrentProgressCount = (i * 100) / num; //this would tell a percentage of files that has been processed
Sleep(700); //put this sleep to make sure that current file name appears on progress dlg for once
[/COLOR][/B]}
Your thread routine function should look like this.
UINT ProgressDlgThread(void *arg)
{
[B][COLOR="Red"] //NOTE: I'm assuming that the name of your progressBar Dialog is CProgressBarDlg
[/COLOR][/B]
CProgressBarDlg *m_progressDlg = new CProgressBarDlg((CWnd *)arg);
m_progressDlg->DoModal(); //this would bring the dialogbox in front of you main application window
delete m_progressDlg;
return 0;
}
In your ProgressBar Dialog Class, you need to create OnTimer function. I hope you know about how to overload an OnTimer Function in Dlg Class
Otherwise you can have a look on
MFC Controls - Timers
In OnInitDialog function you have to set a timer
SetTimer(100, 500); //this would cause your OnTimer Function to be called after every 500 milli seconds
Your OnTimer Function should be like
KillTimer(100);
SetStepCount(CurrentProgressCount);
SetWindowText (CurrentFile + " Saving.....");
SetTimer(100, 500);
I'm hopeful that it should work. Let me know how does it goes.
Munir