|
-
April 13th, 2011, 05:07 AM
#16
Re: Progress bar
 Originally Posted by galapogos
2. Can't seem to do it. Right clicked on the progress control in resource editor and "Add Variable" is grayed out.
What IDE are you using?
Victor Nijegorodov
-
April 13th, 2011, 05:10 AM
#17
-
April 13th, 2011, 05:30 AM
#18
Re: Progress bar
Change its ID from IDC_PROGRESS1 to something other (for example IDC_PROGRESS_TEST)
Victor Nijegorodov
-
April 13th, 2011, 07:23 AM
#19
Re: Progress bar
 Originally Posted by VictorN
What IDE are you using?
That usually means there's already a variable associated with it.
-
April 13th, 2011, 07:53 AM
#20
Re: Progress bar
 Originally Posted by GCDEF
That usually means there's already a variable associated with it.
Well although it may be one of the possible reasons, it was not the case of OP: he was working with a brand new project without any existent member variable.
I've just tested with a VS2008 (since I don't have 2005) and it seens to be a bug in IDE: after you drag/drop a progressbar to the dialog template (but only the first time!) and then tries to add a variable for it using the context menu - the menu item Add Variable is grayed. Only after you clicks somewhere on the properties window and go back the Add Variable item becomes enabled...
Victor Nijegorodov
-
April 13th, 2011, 07:55 PM
#21
Re: Progress bar
Still can't add variable after changing its name. Can I do it manually by adding it in MainDlg.h/cpp?
Edit: I just tried adding a progress control on another VS2005 project in resource view and "Add Variable" isn't grayed out. So I copied and pasted the variable definition as well as the DoDataExchange() definition from the other project over to MainDlg.h/cpp. Then, before the loop I showed the window using ShowWindow(SW_SHOW) and set the step using SetStep(100/number_of_iterations) and upon every loop iteration I called StepIt(). It works, except for non integer values of the step. Is there a better way of setting the step or must I manually set the position using SetPos((i+1)*(100/(float)number_of_iterations)) instead of StepIt()?
Last edited by galapogos; April 13th, 2011 at 08:27 PM.
-
April 13th, 2011, 08:37 PM
#22
Re: Progress bar
 Originally Posted by galapogos
I'm trying to add a progress bar in one of my dialogs, that will step upon every iteration of a loop until completion. ...
Any idea what I need to do?
In answer to your original question, two solutions are given in the following article, a first solution which involves pumping messages between each iteration, and a second solution which involves threads:
Paul DiLascia, "C++ Q&A" column from the July 1998 issue of MSJ, http://www.microsoft.com/msj/0798/c0798.aspx
The article uses a static text box that displays a string like "Working on Iteration 15 out of 100", but can be modified easily if you would prefer to use a standard progress bar.
Mike
-
April 14th, 2011, 01:49 AM
#23
Re: Progress bar
Is there a better way of setting the step or must I manually set the position using SetPos((i+1)*(100/(float)number_of_iterations)) instead of StepIt()?
Set progress range to number_of_iterations and step it?
Best regards,
Igor
-
April 14th, 2011, 04:40 AM
#24
Re: Progress bar
 Originally Posted by Igor Vartanov
Set progress range to number_of_iterations and step it? 
Doh...head slapping moment.
Thanks!
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
|