www.pudn.com > HanMsg.rar > PLAY.cpp


// PLAY.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Msg.h" 
#include "PLAY.h" 
#include "DelogDialog.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CPLAY dialog 
 
 
CPLAY::CPLAY(CWnd* pParent /*=NULL*/) 
	: CDialog(CPLAY::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CPLAY) 
	m_Msgcontent = _T(""); 
	m_Msgcontent_date = _T(""); 
	m_Msgcontent_time = _T(""); 
	m_Msgcontent_phone = _T(""); 
	m_Msgcontent_index=_T(""); 
	//}}AFX_DATA_INIT 
	del.LoadBitmaps(_T("del"), _T("del")); 
	btn3.LoadBitmaps(_T("btn3"), _T("btn3")); 
	btn4.LoadBitmaps(_T("btn4"), _T("btn4")); 
 
	btn5.LoadBitmaps(_T("btn5"), _T("btn5")); 
	btn6.LoadBitmaps(_T("btn6"), _T("btn6")); 
	btn7.LoadBitmaps(_T("btn7"), _T("btn7")); 
	btn8.LoadBitmaps(_T("btn8"), _T("btn8")); 
} 
 
 
void CPLAY::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CPLAY) 
	DDX_Text(pDX, IDC_EDIT1, m_Msgcontent_phone); 
	DDX_Text(pDX,IDC_EDIT37,m_edit37); 
	DDX_Control(pDX,IDC_EDIT37,m_edit37Control); 
	DDX_Text(pDX,IDC_EDIT38,m_edit38); 
	DDX_Control(pDX,IDC_EDIT38,m_edit38Control); 
	DDX_Text(pDX,IDC_EDIT39,m_edit39); 
	DDX_Control(pDX,IDC_EDIT39,m_edit39Control); 
	DDX_Text(pDX,IDC_EDIT40,m_edit40); 
	DDX_Control(pDX,IDC_EDIT40,m_edit40Control); 
	DDX_Text(pDX,IDC_EDIT1,m_edit1); 
	DDX_Control(pDX,IDC_EDIT1,m_edit1Control); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CPLAY, CDialog) 
	//{{AFX_MSG_MAP(CPLAY) 
	ON_WM_CTLCOLOR() 
	ON_BN_CLICKED(IDC_RETURN, OnReturn) 
	ON_BN_CLICKED(IDC_DELETE, OnDelete) 
	ON_BN_CLICKED(IDC_NEXTMES, OnNextmes) 
	ON_BN_CLICKED(IDC_TEST, OnTest) 
	ON_BN_CLICKED(IDC_PREMES, OnPremes) 
	ON_BN_CLICKED(IDC_END, OnEnd) 
	ON_BN_CLICKED(IDC_START, OnStart) 
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CPLAY message handlers 
 
BOOL CPLAY::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	VERIFY(del.SubclassDlgItem(IDC_DELETE,this)); 
	del.SizeToContent(); 
	VERIFY(btn3.SubclassDlgItem(IDC_RETURN,this)); 
	btn3.SizeToContent(); 
	VERIFY(btn4.SubclassDlgItem(IDOK,this)); 
	btn4.SizeToContent(); 
 
	VERIFY(btn5.SubclassDlgItem(IDC_START,this)); 
	btn5.SizeToContent();						     
	VERIFY(btn6.SubclassDlgItem(IDC_PREMES,this)); 
	btn6.SizeToContent(); 
	VERIFY(btn7.SubclassDlgItem(IDC_NEXTMES,this)); 
	btn7.SizeToContent(); 
	VERIFY(btn8.SubclassDlgItem(IDC_END,this)); 
	btn8.SizeToContent(); 
 
	timee=new CFont; 
	timee->CreateFont(24,0,0,0,600,FALSE,FALSE,0, 
					ANSI_CHARSET,OUT_DEFAULT_PRECIS, 
					CLIP_DEFAULT_PRECIS, 
					DEFAULT_QUALITY, 
					DEFAULT_PITCH|FF_SWISS, 
					_T("宋体")); 
	//MsgDialog::SetFont(timee,TRUE); 
	//m_edit38="china"; 
	m_edit37=_T("第")+m_Msgcontent_index+_T("条"); 
	m_edit37Control.SetFont(timee); 
	m_edit37Control.SetWindowText(m_edit37); 
 
	m_edit38=m_Msgcontent_phone; 
	m_edit38Control.SetFont(timee); 
	m_edit38Control.SetWindowText(m_edit38); 
	 
	m_edit39=m_Msgcontent_date; 
	m_edit39Control.SetFont(timee); 
	m_edit39Control.SetWindowText(m_edit39); 
	 
	m_edit40=m_Msgcontent_time; 
	m_edit40Control.SetFont(timee); 
	m_edit40Control.SetWindowText(m_edit40); 
 
	m_edit1=m_Msgcontent; 
	m_edit1Control.SetFont(timee); 
	m_edit1Control.SetWindowText(m_edit1); 
 
	playposfinp=playposfin-238; 
	playposfinn=playposfin; 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
 
 
HBRUSH CPLAY::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)  
{ 
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); 
	 
	// TODO: Change any attributes of the DC here 
	if(pWnd->GetDlgCtrlID()==IDC_EDIT37) 
	{ 
		pDC->SetBkColor(RGB(150,150,150));//RGB(200,200,200) 
		pDC->SetTextColor(RGB(255,0,0));//RGB(140,189,222) 
	} 
	if(pWnd->GetDlgCtrlID()==IDC_EDIT38) 
	{ 
		pDC->SetBkColor(RGB(150,150,150));//RGB(200,200,200) 
		pDC->SetTextColor(RGB(255,0,0));//RGB(140,189,222) 
	} 
	if(pWnd->GetDlgCtrlID()==IDC_EDIT39) 
	{ 
		pDC->SetBkColor(RGB(150,150,150));//RGB(200,200,200) 
		pDC->SetTextColor(RGB(255,0,0));//RGB(140,189,222) 
	} 
	if(pWnd->GetDlgCtrlID()==IDC_EDIT40) 
	{ 
		pDC->SetBkColor(RGB(150,150,150));//RGB(200,200,200) 
		pDC->SetTextColor(RGB(255,0,0));//RGB(140,189,222) 
	} 
	if(pWnd->GetDlgCtrlID()==IDC_EDIT1) 
	{ 
		pDC->SetBkColor(RGB(200,200,100));//RGB(200,200,200) 
		pDC->SetTextColor(RGB(0,0,255));//RGB(140,189,222) 
	} 
	// TODO: Return a different brush if the default is not desired 
	return hbr; 
} 
 
void CPLAY::OnOK()  
{ 
	// TODO: Add extra validation here 
	 
	CDialog::OnOK(); 
	DestroyWindow(); 
} 
 
void CPLAY::OnReturn()  
{ 
	// TODO: Add your control notification handler code here 
	CDialog::OnOK(); 
	DestroyWindow(); 
	//MessageBox(m_MsgIndex,TEXT("CONTENT"),MB_OK); 
} 
 
void CPLAY::OnDelete()  
{ 
	// TODO: Add your control notification handler code here 
//MessageBox(m_MsgIndex,TEXT("CONTENT"),MB_OK); 
	DelogDialog diadel; 
	if(diadel.DoModal()==IDOK) 
	{ 
		//MessageBox(TEXT("CPLAY 进入删除"),TEXT("提示"),MB_OK); 
		dlggg->DelFileLine(m_MsgIndex); 
		//DelFileLine(Index); 
		CDialog::OnOK(); 
		DestroyWindow(); 
	} 
} 
 
void CPLAY::OnNextmes()  
{ 
	// TODO: Add your control notification handler code here 
 
	//CString filetext=dlggg->openfile(); 
//MessageBox(m_wholefile,TEXT("start OnNextmes()  m_wholefile"),MB_OK);//正确显示 
	CString wangstart=dlggg->openfile(); 
//MessageBox(wangstart,TEXT("finish OnNextmes()  wangstart"),MB_OK);//将第二条短信发送号码的前四位的重复一次 
	//long b=filetext.Find(TEXT("\r\n"),playposfin);//找到下一个结尾标志 
	long nextmessign=m_wholefile.Find(TEXT("\r\n"),playposfinn); 
	if(nextmessign!=-1) 
	{ 
		CString nextfile=m_wholefile.Mid(playposfinn,119); 
	//MessageBox(nextfile,TEXT("OnNextmes() nextfile"),MB_OK); 
		CString nextphone=nextfile.Left(13); 
		CString nextdate=nextfile.Mid(29,8); 
		CString nexttime=nextfile.Mid(38,5); 
		CString nextIndex=nextfile.Mid(44,2); 
		m_MsgIndex=nextIndex; 
		CString nextcontent=nextfile.Mid(47,72); 
 
		m_edit37Control.SetWindowText(_T("")); 
		m_edit37Control.SetWindowText(_T("第")+nextIndex+_T("条")); 
		m_edit38Control.SetWindowText(_T("")); 
		m_edit38Control.SetWindowText(nextphone); 
		m_edit39Control.SetWindowText(_T("")); 
		m_edit39Control.SetWindowText(nextdate); 
		m_edit40Control.SetWindowText(_T("")); 
		m_edit40Control.SetWindowText(nexttime); 
		m_edit1Control.SetWindowText(_T("")); 
		m_edit1Control.SetWindowText(nextcontent); 
		playposfinp=playposfinn-119; 
		playposfinn+=119; 
	} 
	else  
	{ 
 
	} 
//MessageBox(m_wholefile,TEXT("finish OnNextmes()  m_wholefile"),MB_OK); 
	CString wang=dlggg->openfile(); 
//MessageBox(wang,TEXT("finish OnNextmes()  wang"),MB_OK); 
} 
void CPLAY::OnPremes()  
{ 
	// TODO: Add your control notification handler code here 
	if(playposfinp>=0) 
	{ 
		CString prefile=m_wholefile.Mid(playposfinp,119); 
	//MessageBox(prefile,TEXT("OnPremes() prefile"),MB_OK); 
		CString prephone=prefile.Left(13); 
		CString predate=prefile.Mid(29,8); 
		CString pretime=prefile.Mid(38,5); 
		CString preIndex=prefile.Mid(44,2); 
		m_MsgIndex=preIndex; 
		CString precontent=prefile.Mid(47,72); 
 
		m_edit37Control.SetWindowText(_T("")); 
		m_edit37Control.SetWindowText(_T("第")+preIndex+_T("条")); 
		m_edit38Control.SetWindowText(_T("")); 
		m_edit38Control.SetWindowText(prephone); 
		m_edit39Control.SetWindowText(_T("")); 
		m_edit39Control.SetWindowText(predate); 
		m_edit40Control.SetWindowText(_T("")); 
		m_edit40Control.SetWindowText(pretime); 
		m_edit1Control.SetWindowText(_T("")); 
		m_edit1Control.SetWindowText(precontent); 
		playposfinn=playposfinp+119; 
		playposfinp-=119; 
	} 
	else 
	{ 
	} 
} 
 
void CPLAY::OnEnd()  
{ 
	// TODO: Add your control notification handler code here 
	CString endfile=m_wholefile.Right(119); 
	CString endphone=endfile.Left(13); 
	CString enddate=endfile.Mid(29,8); 
	CString endtime=endfile.Mid(38,5); 
	CString endIndex=endfile.Mid(44,2); 
	m_MsgIndex=endIndex; 
	CString endcontent=endfile.Mid(47,72); 
 
	m_edit37Control.SetWindowText(_T("")); 
	m_edit37Control.SetWindowText(_T("第")+endIndex+_T("条")); 
	m_edit38Control.SetWindowText(_T("")); 
	m_edit38Control.SetWindowText(endphone); 
	m_edit39Control.SetWindowText(_T("")); 
	m_edit39Control.SetWindowText(enddate); 
	m_edit40Control.SetWindowText(_T("")); 
	m_edit40Control.SetWindowText(endtime); 
	m_edit1Control.SetWindowText(_T("")); 
	m_edit1Control.SetWindowText(endcontent); 
	long wholelong=m_wholefile.GetLength(); 
	playposfinp=wholelong-238; 
 
} 
void CPLAY::OnStart()  
{ 
	// TODO: Add your control notification handler code here 
	CString startfile=m_wholefile.Left(119); 
	CString startphone=startfile.Left(13); 
	CString startdate=startfile.Mid(29,8); 
	CString starttime=startfile.Mid(38,5); 
	CString startIndex=startfile.Mid(44,2); 
	m_MsgIndex=startIndex; 
	CString startcontent=startfile.Mid(47,72); 
 
	m_edit37Control.SetWindowText(_T("")); 
	m_edit37Control.SetWindowText(_T("第")+startIndex+_T("条")); 
	m_edit38Control.SetWindowText(_T("")); 
	m_edit38Control.SetWindowText(startphone); 
	m_edit39Control.SetWindowText(_T("")); 
	m_edit39Control.SetWindowText(startdate); 
	m_edit40Control.SetWindowText(_T("")); 
	m_edit40Control.SetWindowText(starttime); 
	m_edit1Control.SetWindowText(_T("")); 
	m_edit1Control.SetWindowText(startcontent); 
	playposfinn=119; 
} 
 
 
void CPLAY::OnTest()  
{ 
	// TODO: Add your control notification handler code here 
	//CString filetext=dlggg->openfile(); 
MessageBox(m_wholefile,TEXT("OnTest()  m_wholefile"),MB_OK); 
	//long b=filetext.Find(TEXT("\r\n"),playposfin);//找到下一个结尾标志 
	CString nextfile=m_wholefile.Mid(119,119); 
MessageBox(nextfile,TEXT("OnTest() nextfile"),MB_OK); 
	 
} 
 
void CPLAY::OnButton1()  
{ 
	// TODO: Add your control notification handler code here 
	MessageBox(m_wholefile,TEXT("start OnNextmes()  m_wholefile"),MB_OK);//正确显示 
	CString wangstart=dlggg->openfile(); 
MessageBox(wangstart,TEXT("finish OnNextmes()  wangstart"),MB_OK);//将第二条短信发送号码的前四位的重复一次 
	//long b=filetext.Find(TEXT("\r\n"),playposfin);//找到下一个结尾标志 
	long nextmessign=m_wholefile.Find(TEXT("\r\n"),playposfinn); 
	if(nextmessign!=-1) 
	{ 
		CString nextfile=m_wholefile.Mid(playposfinn,119); 
	MessageBox(nextfile,TEXT("OnNextmes() nextfile"),MB_OK); 
		CString nextphone=nextfile.Left(13); 
		CString nextdate=nextfile.Mid(29,8); 
		CString nexttime=nextfile.Mid(38,5); 
		CString nextIndex=nextfile.Mid(44,2); 
		m_MsgIndex=nextIndex; 
		CString nextcontent=nextfile.Mid(47,72); 
 
		m_edit37Control.SetWindowText(_T("")); 
		m_edit37Control.SetWindowText(_T("第")+nextIndex+_T("条")); 
		m_edit38Control.SetWindowText(_T("")); 
		m_edit38Control.SetWindowText(nextphone); 
		m_edit39Control.SetWindowText(_T("")); 
		m_edit39Control.SetWindowText(nextdate); 
		m_edit40Control.SetWindowText(_T("")); 
		m_edit40Control.SetWindowText(nexttime); 
		m_edit1Control.SetWindowText(_T("")); 
		m_edit1Control.SetWindowText(nextcontent); 
		playposfinp=playposfinn-119; 
		playposfinn+=119; 
	} 
	else  
	{ 
 
	} 
MessageBox(m_wholefile,TEXT("finish OnNextmes()  m_wholefile"),MB_OK); 
	CString wang=dlggg->openfile(); 
MessageBox(wang,TEXT("finish OnNextmes()  wang"),MB_OK); 
}