Home arrow C++ arrow Page 2 - Using MFC in C++ Part 4: Controls, DDX and DDV

Using MFC in C++ Part 4: Controls, DDX and DDV

In this article, Mitchell will describe how to add several controls to your dialog windows, including the edit box, group box, check box, list box and radio button. He will also describe what DDX and DDV functions are, and show you how to use them to automatically get and set the values of the controls on a dialog.

Author Info:
By: Mitchell Harper
Rating: 4 stars4 stars4 stars4 stars4 stars / 62
December 17, 2001
  1. · Using MFC in C++ Part 4: Controls, DDX and DDV
  2. · Controls explained
  3. · The push button control
  4. · The check box control
  5. · The radio button control
  6. · The list box control
  7. · The group box control
  8. · DDX and DDV explained
  9. · Conclusion

print this article

Using MFC in C++ Part 4: Controls, DDX and DDV - Controls explained
(Page 2 of 9 )

Controls are the building blocks of an application hierarchy, and are used to provide users with a way to easily enter input. Some controls are bi-directional (accept input, and display out), while others are uni-directional (only accept input or only display output). Controls are created as part of a dialog box in a resource file.

The EDITTEXT control

One of the most popular controls in C++ is the edit box. The edit box is represented in C++ through MFC as the EDITTEXT control. The syntax of the EDITTEXT resource looks like this:

EDITTEXT [Control Id], [X Pos], [Y Pos], [Width], [Height], [Style Options]

The Control Id is a user #defined numerical value, which is usually stored in a separate file. Because we are creating an edit box, the ID should be prefixed with “IDE_”, such as “IDE_NAME”. The x pos, y pos, width and height are self-explanatory. The style options define how the edit box will be displayed. Some default styles, such as WS_VISIBLE, WS_BORDER, WS_CHILD and WS_TABSTOP should be used. Also, to allow a user to scroll the edit box, the ES_AUTOHSCROLL style macro should be used. Style macros can be Ored together. A sample EDITTEXT control would be declared like this:


The EDITTEXT control has a number of functions, which can be used to manipulate its contents, check for valid values, etc. But before I describe them, let’s talk about buttons.
blog comments powered by Disqus

- Intel Threading Building Blocks
- Threading Building Blocks with C++
- Video Memory Programming in Text Mode
- More Tricks to Gain Speed in Programming Con...
- Easy and Efficient Programming for Contests
- Preparing For Programming Contests
- Programming Contests: Why Bother?
- Polymorphism in C++
- Overview of Virtual Functions
- Inheritance in C++
- Extending the Basic Streams in C++
- Using Stringstreams in C++
- Custom Stream Manipulation in C++
- General Stream Manipulation in C++
- Serialize Your Class into Streams in C++

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials