C++
  Home arrow C++ arrow Page 5 - Using MFC in C++ Part 4: Controls, DDX and...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C++

Using MFC in C++ Part 4: Controls, DDX and DDV
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 38
    2001-12-17

    Table of Contents:
  • Using MFC in C++ Part 4: Controls, DDX and DDV
  • Controls explained
  • The push button control
  • The check box control
  • The radio button control
  • The list box control
  • The group box control
  • DDX and DDV explained
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using MFC in C++ Part 4: Controls, DDX and DDV - The radio button control


    (Page 5 of 9 )

    The radio button control is used to provide a user with a mutually exclusive set of options, which are accessible programmatically (just like the edit box and check box controls). We create radio buttons as part of our resource file. The syntax of our radio button is exactly the same as the CHECKBOX and AUTOCHECKBOX controls:

    [AUTO]RADIOBUTTON [Caption], [Control Id], [X Pos], [Y Pos], [Width], [Height], [Style Options]

    As with the CHECKBOX and AUTOCHECKBOX controls, we can prefix the definition with the “AUTO” keyword, to let windows handle the changing of the options automatically. Radio buttons should be used when one and only one option in a group will be selected. You can retrieve the value of a radio button like this:

    int radioState;

    CButton* pRadio = (CButton*)GetDlgItem(IDRB_1);

    radioState = pRadio->GetCheck();


    Once again, the radio button control is part of the CButton class, and we cast it to a pointer-to-CButton using the GetDlgItem function. As with the check box control, the GetCheck returns 0 for off, or 1 for on.

    The CTEXT control

    Another very simple control is the CTEXT control. The CTEXT control acts like a label, and is primarily used for display purposes only. The CTEXT control has the following syntax:

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

    We would add a label to a dialog boxes resource definition like this:

    CTEXT "This is a label", IDCT_1, 10, 90, 60, 15, WS_VISIBLE | WS_CHILD | WS_TABSTOP

    One of the more interesting and advanced control is the list box. Let’s take a look at the list box now.

    More C++ Articles
    More By Mitchell Harper


     

    C++ ARTICLES

    - Paths and Files
    - Directories in C++
    - Focusing on C++ Files
    - Const Correctness in C++
    - Manipulating Streams and Files with C++
    - Streams and Files
    - Multiplying Large Numbers with Karatsuba`s A...
    - Large Numbers
    - Dijkstra`s Shunting Algorithm with STL and C...
    - Brief Introduction to the STL Containers
    - The Standard Template Library
    - Templates in C++
    - C++ Programmer Alerts
    - C++ Programming Tips
    - First Steps in (C) Programming, conclusion






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT