// calcdlg.cpp : implementation file
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "mfccalc.h"
#include "calcdlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg message handlers
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CCalcDlg dialog
IMPLEMENT_DYNCREATE(CCalcDlg, CDialog)
BEGIN_DISPATCH_MAP(CCalcDlg, CDialog)
//{{AFX_DISPATCH_MAP(CCalcDlg)
DISP_PROPERTY_EX(CCalcDlg, "Accum", GetAccum, SetAccum, VT_I4)
DISP_PROPERTY_EX(CCalcDlg, "Operand", GetOperand, SetOperand, VT_I4)
DISP_PROPERTY_EX(CCalcDlg, "Operation", GetOperation, SetOperation, VT_I2)
DISP_PROPERTY_EX(CCalcDlg, "Visible", GetVisible, SetVisible, VT_BOOL)
DISP_FUNCTION(CCalcDlg, "Evaluate", Evaluate, VT_BOOL, VTS_NONE)
DISP_FUNCTION(CCalcDlg, "Clear", Clear, VT_EMPTY, VTS_NONE)
DISP_FUNCTION(CCalcDlg, "Display", Display, VT_EMPTY, VTS_NONE)
DISP_FUNCTION(CCalcDlg, "Close", Close, VT_EMPTY, VTS_NONE)
DISP_FUNCTION(CCalcDlg, "Button", Button, VT_BOOL, VTS_BSTR)
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
#ifndef IMPLEMENT_OLECREATE_SINGLE
// MFC will provide this macro in the future. For now, we define it.
#define IMPLEMENT_OLECREATE_SINGLE(class_name, external_name, \
l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
AFX_DATADEF COleObjectFactory class_name::factory(class_name::guid, \
RUNTIME_CLASS(class_name), TRUE, _T(external_name)); \
const AFX_DATADEF GUID class_name::guid = \
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } };
#endif
// {62C4DD10-F45E-11cd-8C3D-00AA004BB3B7}
IMPLEMENT_OLECREATE_SINGLE(CCalcDlg, "mfccalc.calculator",
0x62c4dd10, 0xf45e, 0x11cd, 0x8c, 0x3d, 0x0, 0xaa, 0x0, 0x4b, 0xb3, 0xb7);
CCalcDlg::CCalcDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCalcDlg::IDD, pParent)
{
m_bAutoDelete = TRUE; // default to auto-delete
m_dwRegister = 0; // not registered as active by default
//{{AFX_DATA_INIT(CCalcDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// Note that LoadAccelerator does not require DestroyAcceleratorTable
m_hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD));
// clear the contents of the calculator and reset state
OnClickedClear();
// enable this object for OLE automation
EnableAutomation();
}
CCalcDlg::~CCalcDlg()
{
if (m_dwRegister != 0)
RevokeActiveObject(m_dwRegister, NULL);
}
void CCalcDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCalcDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CCalcDlg implementation
void CCalcDlg::PerformOperation()
{
if (m_errorState != ErrNone)
return;
if (m_bOperandAvail)
{
if (m_operator == OpNone)
m_accum = m_operand;
else if (m_operator == OpMultiply)
m_accum *= m_operand;
else if (m_operator == OpDivide)
{
if (m_operand == 0)
m_errorState = ErrDivideByZero;
else
m_accum /= m_operand;
}
else if (m_operator == OpAdd)
m_accum += m_operand;
else if (m_operator == OpSubtract)
m_accum -= m_operand;
}
m_bOperandAvail = FALSE;
UpdateDisplay();
}
void CCalcDlg::ClickedNumber(long l)
{
if (m_errorState != ErrNone)
return;
if (!m_bOperandAvail)
m_operand = 0L;
SetOperand(m_operand*10+l);
UpdateDisplay();
}
void CCalcDlg::UpdateDisplay()
{
if (GetSafeHwnd() == NULL)
return;
CString str;
if (m_errorState != ErrNone)
str.LoadString(IDS_ERROR);
else
{
long lVal = (m_bOperandAvail) ? m_operand : m_accum;
str.Format(_T("%ld"), lVal);
}
GetDlgItem(IDE_ACCUM)->SetWindowText(str);
GetDlgItem(IDC_INVISIBLE_FOCUS)->SetFocus();
}
BEGIN_MESSAGE_MAP(CCalcDlg, CDialog)
//{{AFX_MSG_MAP(CCalcDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND_RANGE(IDB_0, IDB_9, OnClickedNumber)
ON_BN_CLICKED(IDB_CLEAR, OnClickedClear)
ON_BN_CLICKED(IDB_DIVIDE, OnClickedDivide)
ON_BN_CLICKED(IDB_EQUAL, OnClickedEqual)
ON_BN_CLICKED(IDB_MINUS, OnClickedMinus)
ON_BN_CLICKED(IDB_PLUS, OnClickedPlus)
ON_BN_CLICKED(IDB_TIMES, OnClickedTimes)
ON_EN_SETFOCUS(IDE_ACCUM, OnSetFocusAccum)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCalcDlg message handlers
BOOL CCalcDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
pSysMenu->RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND);
pSysMenu->RemoveMenu(SC_SIZE, MF_BYCOMMAND);
// want focus to stay on the dialog itself (until a button is clicked)
SetFocus();
return FALSE;
}
void CCalcDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::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 CCalcDlg::OnPaint()
{
if (!IsIconic())
{
CDialog::OnPaint();
return;
}
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (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);
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCalcDlg::OnQueryDragIcon()
{
return (HCURSOR)m_hIcon;
}
void CCalcDlg::OnClickedNumber(UINT nID)
{
ASSERT(nID >=
没有合适的资源?快使用搜索试试~ 我知道了~
一个比较好的Com程序谢谢观看
共79个文件
obj:12个
h:9个
pdb:6个
需积分: 0 4 下载量 179 浏览量
2008-10-09
21:22:13
上传
评论
收藏 8.61MB RAR 举报
温馨提示
一个比较好的com程序 欢迎大家下载啊 潘爱民先生的com原理于应用
资源详情
资源评论
资源推荐
收起资源包目录
ch11.rar (79个子文件)
ch11
mfccalc
mfccalc.rc 7KB
resource.h 2KB
mfccalc.h 1KB
mfccalc.plg 248B
stdafx.h 689B
calcdlg.cpp 11KB
mfccalc.ncb 57KB
mfccalc.dsp 7KB
mfccalc.dsw 537B
Debug
vc60.pdb 348KB
mfccalc.pch 5.1MB
calcdlg.obj 52KB
stdafx.obj 103KB
vc60.idb 185KB
mfccalc.ilk 213KB
mfccalc.exe 112KB
mfccalc.res 3KB
mfccalc.pdb 721KB
mfccalc.obj 13KB
stdafx.cpp 519B
mfccalc.opt 48KB
mfccalc.cpp 3KB
Release
mfccalc.exe 24KB
res
mfccalc.rc2 399B
mfccalc.ico 766B
calcdlg.h 3KB
mfccalc.reg 650B
mfccalc.odl 1KB
UniDebug
vc60.pdb 348KB
mfccalc.pch 5.12MB
calcdlg.obj 52KB
stdafx.obj 104KB
vc60.idb 185KB
mfccalc.res 3KB
mfccalc.obj 13KB
calcdriv
calctype.cpp 2KB
resource.h 938B
stdafx.h 806B
calcdriv.ncb 57KB
calcdriv.opt 48KB
Calcdriv.clw 1KB
calcdriv.cpp 7KB
calcdriv.rc 3KB
Debug
Calctype.sbr 0B
vc60.pdb 348KB
calcdriv.pch 6.41MB
vc60.idb 193KB
calcdriv.bsc 2.91MB
Stdafx.sbr 1.27MB
Stdafx.obj 104KB
Calcdriv.res 3KB
calcdriv.pdb 817KB
calcdriv.obj 35KB
calcdriv.exe 108KB
calcdriv.sbr 0B
calcdriv.ilk 198KB
Calctype.obj 10KB
stdafx.cpp 519B
calcdriv.mak 9KB
calcdriv.dsw 539B
calcdriv.h 2KB
Release
calcdriv.exe 20KB
calctype.h 1012B
res
calcdriv.ico 766B
calcdriv.rc2 2KB
calcdriv.dsp 7KB
calcdriv.plg 250B
CalcDriv.aps 20KB
UniDebug
vc60.pdb 340KB
calcdriv.pch 5.12MB
vc60.idb 185KB
Stdafx.obj 104KB
Calcdriv.res 3KB
calcdriv.obj 35KB
Calctype.obj 10KB
CalcDrv.xls 34KB
Point
point.tlb 2KB
point.odl 1KB
point.h 10KB
共 79 条
- 1
miaodaijiang
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0