CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24

Thread: Progress bar

  1. #16
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Progress bar

    Quote Originally Posted by galapogos View Post
    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

  2. #17
    Join Date
    Feb 2005
    Posts
    331

    Re: Progress bar

    Vs2005.

  3. #18
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Progress bar

    Change its ID from IDC_PROGRESS1 to something other (for example IDC_PROGRESS_TEST)
    Victor Nijegorodov

  4. #19
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Progress bar

    Quote Originally Posted by VictorN View Post
    What IDE are you using?
    That usually means there's already a variable associated with it.

  5. #20
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Progress bar

    Quote Originally Posted by GCDEF View Post
    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

  6. #21
    Join Date
    Feb 2005
    Posts
    331

    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.

  7. #22
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Progress bar

    Quote Originally Posted by galapogos View Post
    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

  8. #23
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    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

  9. #24
    Join Date
    Feb 2005
    Posts
    331

    Re: Progress bar

    Quote Originally Posted by Igor Vartanov View Post
    Set progress range to number_of_iterations and step it?
    Doh...head slapping moment.

    Thanks!

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured