Escolar Documentos
Profissional Documentos
Cultura Documentos
// DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
JERRY CHACKO
UR11CS042
// CSpinnDlg dialog
JERRY CHACKO
UR11CS042
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX,
strAboutMenu);
}
}
// 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
// TODO: Add extra initialization here
m_cSpin.SetRange(1, 1000);
UDACCEL uda[3];
uda[0].nSec=0;
uda[0].nInc=1; //Start incrementing by One
uda[1].nSec=3;
uda[2].nInc=5; //After 3 seconds increment by 5
uda[3].nSec=5;
uda[3].nInc=20; //5 seconds later (or t+8) increment by 20
m_cSpin.SetAccel(3,uda); //the first argument is the number
//of elements in the array
m_strEdit="DEFAULT";
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CSpinnDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
JERRY CHACKO
UR11CS042
void CSpinnDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND,
reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSpinnDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CSpinnDlg::OnDeltaposSpin(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
NM_UPDOWN* spin = (NM_UPDOWN*)pNMHDR;
switch((*spin).iPos+(*spin).iDelta){
case 1: m_strEdit="This"; break;
case 2: m_strEdit="is"; break;
case 3: m_strEdit="fun!"; break;
}
UpdateData(FALSE);
*pResult = 0;
}
JERRY CHACKO
UR11CS042
PROGRAM :
// diag_sampleDlg.cpp : implementation file
//
#include "stdafx.h"
#include "diag_sample.h"
#include "diag_sampleDlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
JERRY CHACKO
UR11CS042
// Cdiag_sampleDlg dialog
JERRY CHACKO
UR11CS042
JERRY CHACKO
UR11CS042
CDialogEx::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void Cdiag_sampleDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND,
reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR Cdiag_sampleDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void Cdiag_sampleDlg::On_1()
{
// TODO: Add your control notification handler code here
JERRY CHACKO
UR11CS042
UpdateData(true);
m_var=m_var*10+1;
m_s=m_s+'1';
UpdateData(false);
}
void Cdiag_sampleDlg::On_2()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+2;
m_s=m_s+'2';
UpdateData(false);
}
void Cdiag_sampleDlg::On_3()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+3;
m_s=m_s+'3';
UpdateData(false);
}
void Cdiag_sampleDlg::On_4()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+4;
m_s=m_s+'4';
UpdateData(false);
}
void Cdiag_sampleDlg::On_5()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+5;
m_s=m_s+'5';
UpdateData(false);
}
JERRY CHACKO
UR11CS042
void Cdiag_sampleDlg::On_6()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+6;
m_s=m_s+'6';
UpdateData(false);
}
void Cdiag_sampleDlg::On_7()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+7;
m_s=m_s+'7';
UpdateData(false);
}
void Cdiag_sampleDlg::On_8()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+8;
m_s=m_s+'8';
UpdateData(false);
}
void Cdiag_sampleDlg::On_9()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+9;
m_s=m_s+'9';
UpdateData(false);
}
void Cdiag_sampleDlg::On_0()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_var=m_var*10+0;
JERRY CHACKO
UR11CS042
m_s=m_s+'0';
UpdateData(false);
}
void Cdiag_sampleDlg::On_plus()
{
// TODO: Add your control notification handler code here
UpdateData(true);
temp=m_var;
m_var=0;
m_s=m_s+'+';
ch=1;
UpdateData(false);
}
void Cdiag_sampleDlg::On_minus()
{
// TODO: Add your control notification handler code here
UpdateData(true);
temp=m_var;
m_var=0;
m_s=m_s+'-';
ch=2;
UpdateData(false);
}
void Cdiag_sampleDlg::On_multiply()
{
// TODO: Add your control notification handler code here
UpdateData(true);
temp=m_var;
m_var=0;
m_s=m_s+'*';
ch=3;
UpdateData(false);
}
void Cdiag_sampleDlg::On_divide()
{
// TODO: Add your control notification handler code here
UpdateData(true);
temp=m_var;
m_var=0;
m_s=m_s+'/';
ch=4;
JERRY CHACKO
UR11CS042
UpdateData(false);
}
void Cdiag_sampleDlg::On_equals()
{
// TODO: Add your control notification handler code here
UpdateData(true);
switch(ch)
{
case 1:
m_var=temp+m_var;
m_s="";
break;
case 2:
m_var=temp-m_var;
m_s="";
break;
case 3:
m_var=temp*m_var;
m_s="";
break;
case 4:
m_var=temp/m_var;
m_s="";
break;
}
//m_var=0;
UpdateData(false);
}
//void Cdiag_sampleDlg::On_plus()
//{
//
// TODO: Add your control notification handler code here
//
UpdateData(true);
//
temp=m_var;
//
m_var=0;
//
ch=1;
//
UpdateData(false);
//}
JERRY CHACKO
UR11CS042