sportdlg.cpp

来自「一个控制字符移动的MFC程序」· C++ 代码 · 共 91 行

CPP
91
字号
// SportDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Timer.h"
#include "SportDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSportDlg dialog


CSportDlg::CSportDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSportDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSportDlg)
	m_h = 0;
	m_w = 0;
	m_distance = 0;
	m_speed = 0;
	m_s = 0;
	//}}AFX_DATA_INIT
}


void CSportDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSportDlg)
	DDX_Control(pDX, IDC_SLIDER1, m_slider);
	DDX_Text(pDX, IDC_EDIT1, m_h);
	DDX_Text(pDX, IDC_EDIT2, m_w);
	DDX_Text(pDX, IDC_EDIT3, m_distance);
	DDV_MinMaxInt(pDX, m_distance, 1, 200);
	DDX_Slider(pDX, IDC_SLIDER1, m_speed);
	DDX_Text(pDX, IDC_EDIT4, m_s);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSportDlg, CDialog)
	//{{AFX_MSG_MAP(CSportDlg)
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER1, OnCustomdrawSlider1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSportDlg message handlers

void CSportDlg::OnOK() 
{
	// TODO: Add extra validation here
	
	CDialog::OnOK();
}

void CSportDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

BOOL CSportDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_slider.SetRange(10,200);
	m_slider.SetTicFreq(100);
	m_slider.SetPos(100);
	UpdateData(false);
	return true;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CSportDlg::OnCustomdrawSlider1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	m_s=m_slider.GetPos();
	UpdateData(false);
	*pResult = 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?