Control management
hi,
i have a problem to be solved.
i am using a progress bar control which runs from 1 to 100. it is initiated by a start button control. now during the process of progress bar movement i want to control it by stoping the progress bar and also stopping the start button event at that moment. this should be done by another button stop.
i tried doing it but i couldn't. i tried using timer event also, but the timer event is taken up only after finishing the start button event. is there any help?
-dan
[532 byte] By [
danandu] at [2007-11-19 9:00:29]

# 1 Re: Control management
Use two buttons Stop and Start. You can use a timer that you start and stop and in the handler increment the progress. Something like this
OnInitDialog
GetDlgItem(IDC_BUTTON_START)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_STOP)->EnableWindow(FALSE);
Handler for Start
GetDlgItem(IDC_BUTTON_START)->EnableWindow(FALSE);
GetDlgItem(IDC_BUTTON_STOP)->EnableWindow(TRUE);
SetTimer();
Handler for Stop
GetDlgItem(IDC_BUTTON_START)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_STOP)->EnableWindow(FALSE);
KillTimer();
Timer procedure
if(not-at-the-end)
StepIt();
else
{
KillTimer();
GetDlgItem(IDC_BUTTON_START)->EnableWindow(TRUE);
GetDlgItem(IDC_BUTTON_STOP)->EnableWindow(FALSE);
}
cilu at 2007-11-11 0:21:55 >

# 2 Re: Control management
i had already implemented the way u described. And i am satisfied with that implementation. But u know one thing i found that we are not able to control or intervene inbetween a button's event and stop that event from some other button's event. Can we do it!.
thnx for ur reply,
with regards
-dan
# 3 Re: Control management
You could use multi-threading. When you click your first button, launch a thread that will do something. You can then let the other button signal the thread to stop working.
Marc G at 2007-11-11 0:24:02 >
