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
105 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

 

Welcome back. This is Part III of the "Implementing a GUI in C++ And DirectX" Article. (Follow these links to part one and part two of the series). Continuing with the overall theme (showing how I implemented a GUI for my upcoming game, Quaternion), this article will walk through the creation of a few common controls you'll need for your GUI. We'll take a close look at several different control types, including pushbuttons, listboxes, textboxes, etc.

This section of the article doesn't have as much code as the others - this is mainly because we programmers are fairly picky when it comes to the appearance of our GUI. We like to code things up so that our buttons, our textboxes, and our GUI appear unique, and fit our own aesthetic tastes. Consequently, everyone's control code will be slightly (or maybe drastically different), and it wouldn't make sense to include my particular drawing code. Besides, writing code to draw all the GUI elements is fun, in fact, in my opinion, it's the most fun you can have implementing a GUI. Go wild.

One very important thing, before we get started - make your gui_window destructor virtual. I didn't mention it in Part II, because at that point we weren't subclassing any windows from gui_window, but I'm mentioning it now - making your destructors virtual for gui_window and all of its derivatives is a very smart thing to do, as it will ensure that no memory is leaked because of derived destructors not being called. Be wary of the traps of C++.

That being said, let's start by determining which GUI controls we need.


Next : GUI Controls We'll Need