shipinfo.cpp

来自「Viaual C++实战演练一书的源代码,对于C++程序员有实际的借鉴意义.」· C++ 代码 · 共 84 行

CPP
84
字号
// ShipInfo.cpp : implementation file
//

#include "stdafx.h"
#include "demo3.h"
#include "ShipInfo.h"
#include "Dynamic.h"

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

/////////////////////////////////////////////////////////////////////////////
// CShipInfo dialog


CShipInfo::CShipInfo(CWnd* pParent /*=NULL*/)
	: CDialog(CShipInfo::IDD, pParent)
{
	//{{AFX_DATA_INIT(CShipInfo)
	m_fHs = 0.0f;
	m_strBp = _T("");
	m_fHx = 0.0f;
	m_fJing = 0.0f;
	m_strTime = _T("");
	m_fWei = 0.0f;
	//}}AFX_DATA_INIT
}


void CShipInfo::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CShipInfo)
	DDX_Text(pDX, IDC_EDIT_HS, m_fHs);
	DDV_MinMaxFloat(pDX, m_fHs, 0.f, 100.f);
	DDX_Text(pDX, IDC_EDIT_BP, m_strBp);
	DDX_Text(pDX, IDC_EDIT_HX, m_fHx);
	DDV_MinMaxFloat(pDX, m_fHx, 0.f, 360.f);
	DDX_Text(pDX, IDC_EDIT_J, m_fJing);
	DDV_MinMaxFloat(pDX, m_fJing, -180.f, 180.f);
	DDX_Text(pDX, IDC_EDIT_T, m_strTime);
	DDX_Text(pDX, IDC_EDIT_W, m_fWei);
	DDV_MinMaxFloat(pDX, m_fWei, -90.f, 90.f);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CShipInfo, CDialog)
	//{{AFX_MSG_MAP(CShipInfo)
	ON_BN_CLICKED(ID_CLOSE, OnClose)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CShipInfo& 	CShipInfo::operator=(CShip* ship)
{
	m_fHs = ship->m_fV;
	m_fHx = ship->m_fCourse;
	m_fJing = ship->m_fX0;
	m_fWei = ship->m_fY0;
	m_strBp = ship->m_strScutcheon;

	struct tm *today;
	if(today= localtime( &(ship->m_tTime) ))
	{
		m_strTime.Format("%02d点%02d分%02d秒", today->tm_hour-today->tm_isdst, today->tm_min, today->tm_sec);
	}

	return *this;
}

/////////////////////////////////////////////////////////////////////////////
// CShipInfo message handlers

void CShipInfo::OnClose() 
{
	// TODO: Add your control notification handler code here
	if(this)
		delete this;
}

⌨️ 快捷键说明

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