📄 portpedlg.cpp
字号:
// PortPeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "PortPe.h"
#include "PortPeDlg.h"
#include "DlgTel.h"
#include "resource.h"
#include "ReadSMS.h"
extern CPortPeApp theApp;
#include "DlgPwd.h"
#include "SetMain.h"
#include "ComPort.h"
extern CComPort port;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPortPeDlg dialog
CPortPeDlg::CPortPeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPortPeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPortPeDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPortPeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPortPeDlg)
DDX_Control(pDX, IDC_PICTURE, m_pic);
DDX_Control(pDX, IDC_LIST2, m_lst);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPortPeDlg, CDialog)
//{{AFX_MSG_MAP(CPortPeDlg)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPortPeDlg message handlers
//12,15,23,26,28,30,34
//01,12,15,23,26,28,34
BOOL CPortPeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
//
//m_lst.Set
m_lst.InsertColumn (0,TEXT("串口内容"));
m_lst.SetColumnWidth (0,1000);
/*wcscpy(theApp.AppSetup.PWD ,TEXT("123456"));
theApp.AppSetup.HANDUP =0;
theApp.AppSetup.LASTSMS =11;*/
//theApp.AppSetup.MAXSMS =1;
//theApp.SaveAppSetup();
theApp.ReadAppSetup();
HBITMAP hBk =(HBITMAP)::LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(MAIN10),IMAGE_BITMAP, 0, 0, 0);
if(hBk!=NULL)
{
m_pic.SetBitmap(hBk);
}
iLocal=1;
if(!port.InitComPort(TEXT("COM2:")))
MessageBox(TEXT("初始化失败"),TEXT("系统提示信息"),MB_OK);
//port.Execute_Action ("13671168764","sdfsd","2004-12-12");
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CPortPeDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_KEYDOWN == pMsg->message)
{
switch((int) pMsg->wParam)
{
case 13://回车
OpenFun (iLocal);
return TRUE;
case 9://Tab键
if (iLocal == 4)
iLocal=0;
ShowPic(++iLocal);
break;
case 38://向上箭头
if(iLocal == 1)
iLocal=5;
ShowPic(--iLocal);
break;
case 40://向下箭头
if (iLocal == 4)
iLocal=0;
ShowPic(++iLocal);
break;
case 124://拨打电话
port.LocalVoice (1);
port.SetList (1,"ATA\r");
/*iLocal=1;
ShowPic(iLocal);
OpenFun(iLocal);*/
return TRUE;
case 125://挂断电话
port.LocalVoice (0);
port.SetList (1,"ATH\r");
break;
default:
return TRUE;
}
}
if (WM_CHAR == pMsg->message || WM_KEYUP == pMsg->message)
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
void CPortPeDlg::ShowPic(int iLocal)
{
HBITMAP hBk;
switch(iLocal)
{
case 1://拨打电话
hBk =(HBITMAP)::LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(MAIN10),IMAGE_BITMAP, 0, 0, 0);
break;
case 2://阅读短信
hBk =(HBITMAP)::LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(MAIN20),IMAGE_BITMAP, 0, 0, 0);
break;
case 3://系统设置
hBk =(HBITMAP)::LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(MAIN30),IMAGE_BITMAP, 0, 0, 0);
break;
case 4://退出系统
hBk =(HBITMAP)::LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(MAIN40),IMAGE_BITMAP, 0, 0, 0);
break;
default:
return;
}
if(hBk!=NULL)
{
m_pic.SetBitmap(hBk);
}
}
void CPortPeDlg::OpenFun(int iLocal)
{
CReadSMS read;
CDlgPwd pwd;
CDlgTel tel;
switch(iLocal)
{
case 1://拨打电话
tel.DoModal ();
break;
case 2://阅读短信
read.DoModal ();
break;
case 3://系统设置
if (IDOK == pwd.DoModal ())
{
CSetMain setmain;
setmain.DoModal ();
}
break;
case 4://退出系统
CDialog::OnOK ();
return ;
default:
return;
}
}
void CPortPeDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -