Sir,i want that each time i execute this code written below(which is written in a button)the progress bar should progress and it should look like that, but
after 1st execute the progress bar is filled and next time it looks that it is not progressing.pls help me how can i make it look progress after 1st execute.
//Read from merge file to Buffer
//Write from Buffer to merge file
//Current Position of New file
With this you set the range of your progress bar from 0 to 1, so it has only one step !
With this you set the position of the progress bar to 1, which is the end boundary of the progress bar you've set with SetRange(0,1);
What you need to do is following :
1. Compute the number of times you will call the function you want to monitor with the progress bar (let's say it is 'n')
2. Initialize the progress bar with m_mprogress.SetRange(0,n);
3. Everytime you want to incremente the progress bar, call m_mprogress.StepIt();
If you don't manipulate the progress bar it always looks disabled. Well the progress bar does only give visual feedback to the user and nothing else and user cannot interact with the progress bar. So check if progress bar is enabled before manipulating it.
i am working on a dialog base application there is a main dialog in which several button on one button i am calling another dialog which start downloading file using a thread and evry thing successfully done
but this dialog also have "cancel" button in between downloading if i clicked cancel button on this button I handle a event and call suspend thread and enddialog function but this time it give runtime error and also when i use terminate thread there is same problem.
if anybody have idea about this,please tell me what should i have to do.
Never call SuspendThread - Unless you're a threading expert it's just too dangerous. This is a common threading error, up there with calling TerminateThread. Here's a common failure scenario of how calling SuspendThread causes problems:
1- The worker thread enters a Win32 API function, this function calls EnterCriticalSection.
2- Another thread calls SuspendThread and stalls the worker thread before it can call LeaveCriticalSection.
3- Another thread calls the same API, when it calls EnterCriticalSection it stalls waiting form the critical section to be released - It never is.
Any thread that calls this API now hangs.
This kind of bug is real, hard to reproduce and hard to find. Failure will be of a different nature depending on what the worker thread is doing at the time it is suspended. SuspendThread, TerminateThread and friends are only intended for experts and debuggers - Mere mortals should not use them.
I'm not sure of the exact nature of your problem, but I would start by removing calls such as SuspendThread and TerminateThread - I'm not just making this stuff up, these two API really do cause havoc.
In your handler for the cancel button, you should set a flag (or an event) that can be read in the worker thread that tells it you have cancelled.
Inside the thread, have it finish whatever it's doing and simply allow itself to exit after all necessary cleanup. Just before it exits, it can set another flag (or event) to signify that it is exiting the thread
Back in the main thread, wait for the signal from the thread that it is exiting, then you can safely let the main thread die (by calling your EndDialog).