Click here to Skip to main content
15,887,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help................................ Pin
Jon Hulatt15-May-02 0:12
Jon Hulatt15-May-02 0:12 
GeneralReadFile function Pin
14-May-02 22:54
suss14-May-02 22:54 
GeneralRe: ReadFile function Pin
Niklas L14-May-02 23:24
Niklas L14-May-02 23:24 
GeneralMultiThreaded Progress bar Pin
SamirSood14-May-02 22:36
SamirSood14-May-02 22:36 
GeneralRe: MultiThreaded Progress bar Pin
Jon Hulatt14-May-02 23:57
Jon Hulatt14-May-02 23:57 
GeneralRe: MultiThreaded Progress bar Pin
SamirSood15-May-02 0:14
SamirSood15-May-02 0:14 
GeneralRe: MultiThreaded Progress bar Pin
Todd Smith15-May-02 7:31
Todd Smith15-May-02 7:31 
Generalcode for MultiThreaded Progress bar Pin
Hesham Amin15-May-02 0:45
Hesham Amin15-May-02 0:45 
Hi..
I know two ways to do so:
The first:
to pass a handle of a progress bar to the worker thread and use it as follows

1. Create a helper class that will hold data passed to the worker thread:
<br />
class CData<br />
{<br />
HWND m_hWnd;<br />
//Athor class members..<br />
}<br />

2. In the dialog class create a member variable of type CData:
private:
CData MyData;

3. Before the call to AfxBeginThread() fill members of CData :
<br />
{<br />
//..<br />
//.. some of your code<br />
MyData.m_hWnd=(GetDlgItem(IDC_PROGRESS))->m_hWnd; //where IDC_PROGRESS <br />
<br />
is the ID of the progress bar..<br />
<br />
//now call AfxBeginThread<br />
AfxBeginThread(WorkerFn,&MyData, /*Ather args..*/);<br />
}<br />


4. In the Worker thread function write the following code:
<br />
UINT WorkerFn(LPVOID pData)<br />
{<br />
CData* data=(CData*)pData;<br />
CProgressCtrl* progBar=CWnd::FromHandle(data->m_hWnd);<br />
<br />
//Now use progBar as you wish!<br />
progBar->SetRange(0,100);<br />
//etc<br />
<br />
}<br />


The second:
Pass the handle of the dialog enstead of the progress bar then use:
<br />
::PostMessage(data->m_hWnd,WM_USER+1,0,0)<br />

and handle the message in the dialog..

Send again if you find any problems..
GeneralRe: code for MultiThreaded Progress bar Pin
Stephen C. Steel16-May-02 11:59
Stephen C. Steel16-May-02 11:59 
QuestionWriting a driver? Pin
karanba14-May-02 22:21
karanba14-May-02 22:21 
AnswerRe: Writing a driver? Pin
Jon Hulatt14-May-02 23:58
Jon Hulatt14-May-02 23:58 
Generalincloming socket address Pin
Kristian3314-May-02 22:09
Kristian3314-May-02 22:09 
GeneralRe: incloming socket address Pin
Rickard Andersson2014-May-02 22:20
Rickard Andersson2014-May-02 22:20 
GeneralRe: incloming socket address Pin
Nish Nishant14-May-02 22:21
sitebuilderNish Nishant14-May-02 22:21 
GeneralRe: incloming socket address Pin
markkuk14-May-02 22:21
markkuk14-May-02 22:21 
GeneralRe: incloming socket address Pin
Orbital^14-May-02 22:26
Orbital^14-May-02 22:26 
GeneralRe: incloming socket address Pin
Kristian3314-May-02 22:45
Kristian3314-May-02 22:45 
GeneralSTL program Pin
Orbital^14-May-02 21:41
Orbital^14-May-02 21:41 
GeneralRe: STL program Pin
Christian Graus14-May-02 22:00
protectorChristian Graus14-May-02 22:00 
GeneralRe: STL program Pin
markkuk14-May-02 22:08
markkuk14-May-02 22:08 
GeneralRe: STL program Pin
Orbital^14-May-02 22:19
Orbital^14-May-02 22:19 
GeneralRe: STL program Pin
Nish Nishant14-May-02 22:23
sitebuilderNish Nishant14-May-02 22:23 
GeneralRe: STL program Pin
Orbital^14-May-02 22:29
Orbital^14-May-02 22:29 
GeneralRe: STL program Pin
Nish Nishant14-May-02 22:33
sitebuilderNish Nishant14-May-02 22:33 
GeneralRe: STL program Pin
markkuk14-May-02 22:26
markkuk14-May-02 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.