Google Search

Saturday, January 29, 2011

Modeless Dialog box Creation 600459– Visual Programming Anna University lab manual download fourth semester

Modeless Dialog box Creation 600459– Visual Programming Anna University lab manual download fourth semester


Aim:

          To write a VC++ program to display the text on modeless  dialog box

Logical Description:

            The program starts with object creation. After initializing the instance, the user created window is assigned as main window. Using Show window option project user created window.  Using resources option create a Modeless dialog box  & attach it to the user created window.

Algorithm:

1.      Start the process
2.      Create a dialog box using IDD_DIALOG1 and add the items in it
3.      The creation of the dialog box can be done with the help of CDialog  creating an instance to it.
4.      Allocate memory to the created instance
5.      Call the create method (creation of instance) on the event RButtonDown
6.      Stop the process


Source Code:

#include<afxwin.h>
#include<afxdlgs.h>
#include "resource.h"

class mydlg:public CDialog
{

public:
            mydlg():CDialog()
            {

            }
public:
            BOOL OnInitDialog()
            {
                        return TRUE;
            }

            void OnOK()
            {
                        EndDialog(TRUE);
            }
            void OnCancel()
            {
                        EndDialog(FALSE);
            }

            DECLARE_MESSAGE_MAP()
};


BEGIN_MESSAGE_MAP(mydlg,CDialog)
ON_COMMAND(IDC_CIRCLE, OnCircle)
ON_COMMAND(IDC_SQUARE, OnSquare)                       
END_MESSAGE_MAP()

class mywin:public CFrameWnd
{
public:
            mywin()
            {
                        Create(0,"MFC WINDOW");
            }
            void OnRButtonDown( )
            {
                        CDialog *dlg;
                        dlg = new mydlg();
                        dlg->Create(IDD_DIALOG1);
                        dlg->ShowWindow(1);
                       
            }
            DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(mywin,CFrameWnd)
            ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()

class myapp:public CWinApp
{
public:
            BOOL InitInstance()
            {
                        mywin *p;
                        p=new mywin();
                        m_pMainWnd=p;
                        p->ShowWindow(SW_SHOWNORMAL);
                        return true;
            }
}; myapp A;

0 comments:

Post a Comment