📄 angtrandlg.cpp
字号:
// AngTranDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AngTran.h"
#include "AngTranDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char 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
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CAngTranDlg dialog
CAngTranDlg::CAngTranDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAngTranDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAngTranDlg)
m_nDeg = 0;
m_szContact = _T("交流联系 3S工作室 汪自军: http://www.sciencenet.cn/blog/zjwang.htm");
m_szDec = _T("");
m_szInput = _T("");
m_szRad = _T("");
m_szSex = _T("");
m_szInputDeg = _T("°′″");
m_nPre = 6;
m_chkDec = FALSE;
m_chkRad = FALSE;
m_chkSex = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CAngTranDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAngTranDlg)
DDX_CBIndex(pDX, IDC_CMB_INANGDEG, m_nDeg);
DDX_Text(pDX, IDC_EDIT_CONTACT, m_szContact);
DDX_Text(pDX, IDC_EDIT_DEC, m_szDec);
DDX_Text(pDX, IDC_EDIT_INPUT, m_szInput);
DDX_Text(pDX, IDC_EDIT_RAD, m_szRad);
DDX_Text(pDX, IDC_EDIT_SEX, m_szSex);
DDX_Text(pDX, IDC_STA_INPUTDEG, m_szInputDeg);
DDX_CBIndex(pDX, IDC_CMB_PRE, m_nPre);
DDX_Check(pDX, IDC_CHK_DEC, m_chkDec);
DDX_Check(pDX, IDC_CHK_RAD, m_chkRad);
DDX_Check(pDX, IDC_CHK_SEX, m_chkSex);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAngTranDlg, CDialog)
//{{AFX_MSG_MAP(CAngTranDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BTN_INPUT, OnBtnInput)
ON_CBN_SELCHANGE(IDC_CMB_INANGDEG, OnSelchangeCmbInangdeg)
ON_BN_CLICKED(IDC_BTN_OUTPUT, OnBtnOutput)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAngTranDlg message handlers
BOOL CAngTranDlg::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);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
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
return TRUE; // return TRUE unless you set the focus to a control
}
void CAngTranDlg::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 CAngTranDlg::OnPaint()
{
if (IsIconic())
{
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);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CAngTranDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
#include "WzjCooAng.h"
#include "WzjCommon.h"
#include "WzjArray.h"
void CAngTranDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CWzjArray arr(m_szInput);
long lCount = arr.m_nRow;
double** pdDec;
double** pdSex;
double** pdRad;
New2Array(pdDec, lCount,1);
New2Array(pdSex, lCount,1);
New2Array(pdRad, lCount,1);
for (long l = 0; l < lCount; l++)
{
CWzjCooAng ang(atof(arr.m_szUnitData[l][0]));
switch ( m_nDeg)
{
case 0:
pdDec[l][0] = ang.SexTranToDecAngle();
pdSex[l][0] = ang.GetAngle();
pdRad[l][0] = ang.SexTranToRadAngle();
break;
case 1:
pdDec[l][0] = ang.GetAngle();
pdSex[l][0] = ang.DecTranToSexAngle();
pdRad[l][0] = ang.DecTranToRadAngle();
break;
case 2:
pdDec[l][0] = ang.RadTranToDecAngle();
pdSex[l][0] = ang.RadTranToSexAngle();
pdRad[l][0] = ang.GetAngle();
break;
}
}
CWzjArray arrDec(pdDec, lCount, 1);
CWzjArray arrSex(pdSex, lCount, 1);
// MessageBox(GetStr(arrSex.m_dUnitData[0][0]));
CWzjArray arrRad(pdRad, lCount, 1);
arrDec.FormatToTotalArray(m_nPre);
arrSex.FormatToTotalArray(m_nPre);
arrRad.FormatToTotalArray(m_nPre);
m_szDec = arrDec.GetTotalArrayStr();
m_szSex = arrSex.GetTotalArrayStr();
m_szRad = arrRad.GetTotalArrayStr();
// m_dAngRslt = ang.DecTranToSexAngle();
UpdateData(FALSE);
// CDialog::OnOK();
}
void CAngTranDlg::OnBtnInput()
{
// TODO: Add your control notification handler code here
m_szInput = "";
OpenTextFile(m_szInput, "txt", "文本文件(*.txt)|*.txt");
m_szInput.TrimRight();
UpdateData(FALSE);
}
void CAngTranDlg::OnSelchangeCmbInangdeg()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString szDeg[3] = {"°′″","°","rad"};
this->m_szInputDeg = szDeg[m_nDeg];
UpdateData(FALSE);
}
void CAngTranDlg::OnBtnOutput()
{
UpdateData(TRUE);
// TODO: Add your control notification handler code here
if (m_chkDec) SaveTextFile(m_szDec,"txt","文本文件(*.txt)|*.txt");
if (m_chkSex) SaveTextFile(m_szSex,"txt","文本文件(*.txt)|*.txt");
if (m_chkRad) SaveTextFile(m_szRad,"txt","文本文件(*.txt)|*.txt");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -