}
//str.Format(_T(\str.Format(_T(\
dc.TextOut(m_left+i*m_IntervalPan,m_bottom+3,str);
//绘制Y轴
str.Format(_T(\最低点
dc.TextOut(m_left-20,m_bottom+m_IntervalPan1,str); //0点坐标
str.Format(_T(\
dc.TextOut(m_left-20,m_bottom,str);
//最高点
str.Format(_T(\
dc.TextOut(m_left-20,m_bottom-m_IntervalPan1,str); /*str.Format(_T(\
dc.TextOut(m_left-20,m_bottom-m_IntervalPan1,str); */ //绘制x轴刻度
for (i = m_left; i < m_right; i+=5) { if ((i & 1) == 0) { // 10的倍数
dc.MoveTo(i + 10, m_bottom); dc.LineTo(i + 10, m_bottom+4); } else { // 10的倍数 dc.MoveTo(i + 10, m_bottom); dc.LineTo(i + 10, m_bottom+2); } }
//绘制Y轴刻度
for (i = m_top+30; i < m_bottom+80; i+=5) { if ((i & 1) == 0) { // 10的倍数
}
}
dc.MoveTo(m_left,i + 10 ); dc.LineTo( m_left+4,i + 10); } else { // 10的倍数 dc.MoveTo( m_left,i + 10); dc.LineTo( m_left+2,i + 10); }
// 绘制X轴箭头
dc.MoveTo(m_right+15,m_bottom-5); dc.LineTo(m_right+20,m_bottom); dc.LineTo(m_right+15,m_bottom+5);
//dc.TextOut(m_right+5,m_bottom-20,_T(\// 绘制Y轴箭头
dc.MoveTo(m_left-5,m_top+25); dc.LineTo(m_left,m_top+20); dc.LineTo(m_left+5,m_top+25);
◆图形界面模块
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialog {
public:
CAboutDlg();
// 对话框数据
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现 protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { }
void CAboutDlg::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX); }
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP()
// CCommSys0713Dlg 对话框
CCommSys0713Dlg::CCommSys0713Dlg(CWnd* pParent /*=NULL*/) : CDialog(CCommSys0713Dlg::IDD, pParent) , m_value1(0)
, m_value11(_T(\ , m_value12(_T(\ , m_value13(_T(\ , m_value14(_T(\{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); }
void CCommSys0713Dlg::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT11, m_value11); DDX_Text(pDX, IDC_EDIT12, m_value12); DDX_Text(pDX, IDC_EDIT13, m_value13); DDX_Text(pDX, IDC_EDIT14, m_value14); }
BEGIN_MESSAGE_MAP(CCommSys0713Dlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT()
ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP
ON_BN_CLICKED(IDCANCEL, &CCommSys0713Dlg::OnBnClickedCancel)
ON_BN_CLICKED(IDC_BUTTON1, &CCommSys0713Dlg::OnBnClickedButton1) ON_BN_CLICKED(IDOK, &CCommSys0713Dlg::OnBnClickedStart)
ON_BN_CLICKED(IDC_BUTTON4, &CCommSys0713Dlg::OnBnClickedButton4) ON_BN_CLICKED(IDC_BUTTON2, &CCommSys0713Dlg::OnBnClickedButton2) ON_BN_CLICKED(IDC_BUTTON3, &CCommSys0713Dlg::OnBnClickedButton3) ON_BN_CLICKED(IDC_BUTTON6, &CCommSys0713Dlg::OnBnClickedButton6) ON_BN_CLICKED(IDC_BUTTON5, &CCommSys0713Dlg::OnBnClickedButton5) ON_BN_CLICKED(IDC_BUTTON7, &CCommSys0713Dlg::OnBnClickedButton7) ON_BN_CLICKED(IDC_BUTTON8, &CCommSys0713Dlg::OnBnClickedButton8) END_MESSAGE_MAP()
// CCommSys0713Dlg 消息处理程序
BOOL CCommSys0713Dlg::OnInitDialog() {
CDialog::OnInitDialog();
// 将“关于...”菜单项添加到系统菜单中。
// IDM_ABOUTBOX 必须在系统命令范围内。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) {
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } }
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }
void CCommSys0713Dlg::OnSysCommand(UINT nID, LPARAM lParam) {
if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
CAboutDlg dlgAbout; dlgAbout.DoModal(); } else {
CDialog::OnSysCommand(nID, lParam); } }
// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, // 这将由框架自动完成。
void CCommSys0713Dlg::OnPaint() {
if (IsIconic()) {
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast
// 使图标在工作区矩形中居中
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;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon); } else {
CDialog::OnPaint(); } }
//当用户拖动最小化窗口时系统调用此函数取得光标 //显示。
HCURSOR CCommSys0713Dlg::OnQueryDragIcon()