Thursday, March 8, 2007

How to Create a Dialog Box in MFC SDI Environment?


In a SDI application to launch a dialog box you have to launch it from the menu or toolbar.

Listed below are the procedures by which you can accomplish the above.

First Creates a menu item and dialog box.

Now Create a class for the dialog box.

Once you create a dialog box and right click it, it will show a window where you can name your class for the new dialog.

However it will be derived from CDialog.

For Example Imagine you have a new dialog and you have created a new class named CTest.

Then In the Class wizard create a function for the Menu or Tool Bar item, which when clicked will launch the dialog box.

In that function create a object for the CTest class previously created by us.

The code Snippet is shown below.

CTest test;

test.DoModal();

Now run the program. Once you go to the particular menu item and click it the dialog box will be launced.

Note:- Wherever you create the class object be sure to include the Header file.

No comments:

Post a Comment