📄 infodlg.cpp
字号:
// InfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Airtime_CE.h"
#include "InfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const MaxInfoCount=3;
TCHAR arrInfoName[MaxInfoCount][12]=
{
_T("车站名"),
_T("到站时间"),
_T("开车时间")
};
/////////////////////////////////////////////////////////////////////////////
// CInfoDlg dialog
CInfoDlg::CInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CInfoDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_sTitle=_T("");
m_sNote=_T("");
m_strTo=_T("");
m_bDisplayNote=0;
}
void CInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInfoDlg)
DDX_Control(pDX, IDC_LIST_INFO, m_InfoCtrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInfoDlg, CDialog)
//{{AFX_MSG_MAP(CInfoDlg)
ON_WM_LBUTTONDBLCLK()
ON_WM_DESTROY()
ON_WM_CLOSE()
ON_NOTIFY(NM_DBLCLK, IDC_LIST_INFO, OnDblclkListInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInfoDlg message handlers
BOOL CInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//m_InfoCtrl.SetColumnWidth(-1,-3);
m_InfoCtrl.AddColumn(arrInfoName[0],0);
m_InfoCtrl.SetColumnWidth(0,100);
m_InfoCtrl.AddColumn(arrInfoName[1],1);
m_InfoCtrl.SetColumnWidth(1,100);
m_InfoCtrl.AddColumn(arrInfoName[2],2);
m_InfoCtrl.SetColumnWidth(2,100);
//m_InfoCtrl.AddColumn(_T("备注"),3);
//m_InfoCtrl.SetColumnWidth(3,250);
SetWindowText(m_sTitle+_T(" 次列车的详细信息:"));
//GetDlgItem(IDC_STATIC_NOTE)->SetWindowText(_T("备注:"));
//GetDlgItem(IDC_EDIT_NOTE)->SetWindowText(m_sNote);
m_StationsArray.RemoveAll();
PrepareInfo(m_strTo);
//m_NoteArray.RemoveAll();
//PrepareInfo2(m_sNote);
int num=m_StationsArray.GetSize();
//int num2=m_NoteArray.GetSize();
for(int i=0;i<num;i++)
{
m_InfoCtrl.AddItem(i,0,GetStationName(m_StationsArray[i]));
m_InfoCtrl.AddItem(i,1,GetArriveTime(m_StationsArray[i]));
m_InfoCtrl.AddItem(i,2,GetStartTime(m_StationsArray[i]));
// if(i<num2)m_InfoCtrl.AddItem(i,3,m_NoteArray[i]);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CInfoDlg::PrepareInfo(CString strTo)
{
int len=strTo.GetLength();
int pos=strTo.Find(_T(";"));
if(pos>0)
{
strTo=strTo.Right(len-pos-1);
len=strTo.GetLength();
pos=strTo.Find(_T(";"));
}
else
return 0;
CString s;
while(pos>0)
{
s=strTo.Left(pos);
m_StationsArray.Add(s);
len=strTo.GetLength();
strTo=strTo.Right(len-pos-1);
pos=strTo.Find(_T(";"));
}
return 1;
}
void CInfoDlg::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnLButtonDblClk(nFlags, point);
}
BOOL CInfoDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DestroyWindow();
}
void CInfoDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
CString CInfoDlg::GetStationName(CString& str)
{
CString sRtn="";
int len=str.GetLength();
if(len>3)
str=str.Mid(2,str.GetLength()-3);
else
return str;
int pos=str.Find(_T(","));
if(pos>0)
{
sRtn=str.Left(pos);
str=str.Right(str.GetLength()-pos-1);
return sRtn;
}
else
return sRtn;
}
CString CInfoDlg::GetArriveTime(CString& str)
{
CString sRtn="";
int pos=str.Find(_T(","));
if(pos>0)
{
sRtn=str.Left(pos);
str=str.Right(str.GetLength()-pos-1);
return sRtn;
}
else
return sRtn;
}
CString CInfoDlg::GetStartTime(CString& str)
{
CString sRtn="";
int pos=str.Find(_T(","));
if(pos>0)
{
sRtn=str.Left(pos);
str=str.Right(str.GetLength()-pos-1);
return sRtn;
}
else
return sRtn;
}
/*
BOOL CInfoDlg::PrepareInfo2(CString sNote)
{
int len=sNote.GetLength();
if(len<1)return 0;
TCHAR* str;
wsprintf(str,_T("%S"),sNote);//char* to TCHAR*
AfxMessageBox(str);
TCHAR* tkn=_T(",。:;");
TCHAR* ptr;
wsprintf(ptr,_T("%S"),sNote);//char* to TCHAR*
ptr=_tcstok(str,tkn);
while(ptr)
{
m_NoteArray.Add(ptr);
AfxMessageBox(ptr);
ptr=_tcstok(NULL,tkn);
}
return 1;
}
BOOL CInfoDlg::PrepareInfo2(CString sNote)
{
int len=sNote.GetLength();
if(len<1)return 0;
int pos1=sNote.Find(_T"");
TCHAR* str;
wsprintf(str,_T("%S"),sNote);//char* to TCHAR*
AfxMessageBox(str);
TCHAR* tkn=_T(",。:;");
TCHAR* ptr;
wsprintf(ptr,_T("%S"),sNote);//char* to TCHAR*
ptr=_tcstok(str,tkn);
while(ptr)
{
m_NoteArray.Add(ptr);
AfxMessageBox(ptr);
ptr=_tcstok(NULL,tkn);
}
return 1;
}
*/
void CInfoDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if(m_bDisplayNote!=1)DisplayNote();
CDialog::OnClose();
}
void CInfoDlg::OnDblclkListInfo(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
DisplayNote();
*pResult = 0;
}
void CInfoDlg::DisplayNote()
{
//if(m_bDisplayNote==1)return;
m_bDisplayNote=1;
if(m_sNote!=_T(""))
MessageBox(m_sNote,m_sTitle+_T(" 次列车的备注信息:"));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -