Home / Tips / VC++ Tips / VC++: How a dialog box works?

“Chishiki” is Japanese for “knowledge.” e-chishiki.com aims to bring software developers, information security professionals, IT executives and other IT pros a rich body of knowledge in the form of articles, interviews, tutorials and technical discussions. Our contributors are among the biggest names in the Indian IT industry and include noted authors, educators and practitioners.

VC++: How a dialog box works?


How a dialog box works?


DoModal( ) function creates and displays the dialog box. Just after creation of the dialog box and before displaying it Windows sends the dialog box WM_INITDIALOG message. This message activates OnInitDialog( ) handler. In this handler we should call base class's OnInitDialog( ) because it calls CWnd::UpdateData( ) function with a FALSE parameter. UpdateData( ) in turn creates a CDataExchange object and calls dialog class's DoDataExchange( ), passing it a pointer to CDataExchange object. In this function macros like DDX_Text( ), DDX_Check( ) etc. are used to initialize a control to the value of the dialog box when it is displayed.

If we wish to extract data from the controls or validate the data we must override OnOK( ) handler. In our implementation we must call CDialog's OnOK( ) function. When the user clicks OK, OnOK( ) handler calls UpdateData( ) with TRUE parameter. So when DoDataExchange( ) is called values entered in the controls get collected in the associated variables. OnOK( ) calls EndDialog( ) functions to dismiss the dialog box.

Comments

Log in or create a user account to comment.

On Sale From April 2008

Let Us C
8th Ed.
C programming classic & best seller. 1 million+ copies sold!

Y. Kanetkar

On Sale From April 2008

Introduction to Object Oriented Programming & C++

Y. Kanetkar

On Sale From Fall 2008

Microsoft .NET Framework: Web Application Security

Vijay Mukhi

On Sale From Nolvember 2008

Quest C++ Courseware
12+ hours of instructional audio and animated slides.

Y. Kanetkar Asang Dani

On Sale From November 2008

A Programmer's Guide to Web Application Security

Vijay Mukhi

Latest Forum Posts