Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
106 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Introduction
 GUI Controls
 We'll Need

 Breaking It Down
 Static Controls
 Pushbuttons
 Carets and The
 Textbox Control

 Progress Bars
 Sliders and
 Scrollbars

 Listbox Control
 Conclusion

 Printable version

 


  The Series

 Part I
 Part II
 Part III
 Part IV

 

Progress Bars

Progess bars are just about as easy as static controls to implement, since they only take a few messages.

Basically, you need to do two things with a progress bar - you need to tell it a min/max range, and you need to tell it to "step" some number of units. For example, say I wanted to put up a "Loading…" progress bar, because I had to load 100 different game resources. I would create a progress bar with a range of 0 to 100. I would initially set the progress bar to zero, then, whenever I loaded a game resource, I would "step" the progress bar by one unit. Whenever the progress bar was stepped, it would redraw itself, showing graphically how far along it was by displaying a bar whose length was proportionate to its client area.

Progress bars are very similar to scroll bars; in fact, it might make sense to implement your progress bars in terms of your scroll bars. I made my progress bar separate from my scroll bars simply because I wanted the two to have drastically different appearances and slightly different behaviors - your needs may be different.


Next : Sliders and Scrollbars