Dialog Based Application
Dialog Based Application
#include "stdafx.h"
#include "dialogbased.h"
#include "dialogbasedDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CDialogbasedDlg dialog
m_operation=-1;
m_a=0;
m_b=0;
m_c=0;
}
BEGIN_MESSAGE_MAP(CDialogbasedDlg, CDialog)
//{{AFX_MSG_MAP(CDialogbasedDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CDialogbasedDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
return TRUE; // return TRUE unless you set the focus to a control
}
void CDialogbasedDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM)
dc.GetSafeHdc(), 0);
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CDialogbasedDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CDialogbasedDlg::OnButton1()
{
UpdateData(true);
if(m_operation==0)
m_c=m_a + m_b;
else if(m_operation==1)
m_c=m_a - m_b;
else if(m_operation==2)
m_c=m_a * m_b;
else if(m_operation==3)
{
if(m_b==0)
m_c=0;
else
m_c=m_a / m_b;
}
UpdateData(false);
void CDialogbasedDlg::OnButton2()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_a=0;
m_b=0;
m_c=0;
m_operation=-1;
UpdateData(false);
}
OUTPUT