|
-
July 29th, 2008, 02:04 AM
#1
Updating a progress bar from within a user interface thread
Hi all,
I have set up a user interface thread which I call from my main dialog. The user interface thread I invoke starts a lengthy calculation which can take many minutes / hours to complete. Therefore I would like to show the progress by updating a progress bar belonging to the main dialog.
At the moment I have the following:
In the main dialog / class, I have the following function which calls my user interface thread:
void CFCMDlg::OnStartCalculateThread()
{
CalcThread* pThread;
pThread = new CalcThread();
pThread->CreateThread();
pThread->PostThreadMessage(WM_MYTHREADMESSAGE,NULL,NULL);
}
This calls the following function in another class called CalcThread:
void CalcThread::OnCalculate(WPARAM, LPARAM)
{
for(int year=0;year<a_big_number;year++)
{
// Many many many lines of code!
}
}
I want to somehow update a progress bar (defined in the main dialog window CFCMDlg with the variable name m_progress) from the function CalcThread::OnCalculate(..) as its loops through the loop as shown above. I have tried many things however I must admit I am not that good at C++ so any help would be much appreciated!
Thanks for looking,
Robbie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|