⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setparam.cpp

📁 通过GSM模块接收和发送短信的代码。在eVC4.0下编译通过
💻 CPP
字号:
// SetParam.cpp : implementation file
//

#include "stdafx.h"
#include "portpe.h"
#include "SetParam.h"
extern CPortPeApp theApp;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSetParam dialog


CSetParam::CSetParam(CWnd* pParent /*=NULL*/)
	: CDialog(CSetParam::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetParam)
	//}}AFX_DATA_INIT
}


void CSetParam::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetParam)
	DDX_Control(pDX, IDC_PICTURE, m_pic);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetParam, CDialog)
	//{{AFX_MSG_MAP(CSetParam)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetParam message handlers

BOOL CSetParam::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	HBITMAP	hBk	=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(MAIN331),IMAGE_BITMAP, 0, 0, 0);	
	
	if(hBk!=NULL)
	{
		m_pic.SetBitmap(hBk);
	}
	// TODO: Add extra initialization here
	CEdit* pBoxOne;
	TCHAR out[1024];
	DWORD dwReadNum=512;
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT1);
	MultiByteToWideChar (CP_ACP,0,theApp.AppSetup.SMSC,-1,out, dwReadNum);
	pBoxOne->SetWindowText (out);
	pBoxOne->SetWindowPos(NULL,0,0,150,20,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER);
	
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT2);
	MultiByteToWideChar (CP_ACP,0,theApp.AppSetup.SAFE1,-1,out, dwReadNum);
	pBoxOne->SetWindowText (out);
	pBoxOne->SetWindowPos(NULL,0,0,150,20,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER);
	
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT3);
	MultiByteToWideChar (CP_ACP,0,theApp.AppSetup.SAFE2,-1,out, dwReadNum);
	pBoxOne->SetWindowText (out);
	pBoxOne->SetWindowPos(NULL,0,0,150,20,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER);
	
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT4);
	MultiByteToWideChar (CP_ACP,0,theApp.AppSetup.SOS1,-1,out, dwReadNum);
	pBoxOne->SetWindowText (out);
	pBoxOne->SetWindowPos(NULL,0,0,150,20,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER);
	
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT5);
	MultiByteToWideChar (CP_ACP,0,theApp.AppSetup.SOS2,-1,out, dwReadNum);
	pBoxOne->SetWindowText (out);
	pBoxOne->SetWindowPos(NULL,0,0,150,20,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER);
	
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT6);
	MultiByteToWideChar (CP_ACP,0,theApp.AppSetup.SPECIAL,-1,out, dwReadNum);
	pBoxOne->SetWindowText (out);
	pBoxOne->SetWindowPos(NULL,0,0,150,20,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER);
	
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT7);
	MultiByteToWideChar (CP_ACP,0,theApp.AppSetup.FIRST,-1,out, dwReadNum);
	pBoxOne->SetWindowText (out);
	pBoxOne->SetWindowPos(NULL,0,0,150,20,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER);
	
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT8);
	MultiByteToWideChar (CP_ACP,0,theApp.AppSetup.SECOND,-1,out, dwReadNum);
	pBoxOne->SetWindowText (out);
	pBoxOne->SetWindowPos(NULL,0,0,150,20,SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER);
	
	iLocal=0;

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CSetParam::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();
				return TRUE;
			case 9://Tab键
			case 40://向下箭头
				if (iLocal == 7)
				{
					iLocal=-1;
				}
				iLocal++;
				ShowPic();
				return TRUE;
			case 38://向上箭头
				if (iLocal == 0)
				{
					iLocal=8;
				}
				iLocal--;
				ShowPic();
				return TRUE;
			case 27://ESC键:退出
				CDialog::OnOK ();
				return TRUE;
			case 37://向上箭头
			case 39://向上箭头
			case 12://清除键
			case 8://清除键
			case 48:
			case 49:
			case 50:
			case 51:
			case 52:
			case 53:
			case 54:
			case 55:
			case 56:
			case 57:
				break;
			default:
				return TRUE;
		}
	}
	if ( WM_KEYUP == pMsg->message)
	{
		return TRUE;
	}	
	return CDialog::PreTranslateMessage(pMsg);
}

void CSetParam::ShowPic()
{
	CEdit* pBoxOne;
	switch(iLocal)
	{
		case 0://文本框
			pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT1);
			pBoxOne->SetFocus ();
			break;
		case 1://拨打电话
			pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT2);
			pBoxOne->SetFocus ();
			break;
		case 2://阅读短信
			pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT3);
			pBoxOne->SetFocus ();
			break;
		case 3://文本框
			pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT4);
			pBoxOne->SetFocus ();
			break;
		case 4://文本框
			pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT5);
			pBoxOne->SetFocus ();
			break;
		case 5://文本框
			pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT6);
			pBoxOne->SetFocus ();
			break;
		case 6://文本框
			pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT7);
			pBoxOne->SetFocus ();
			break;
		case 7://文本框
			pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT8);
			pBoxOne->SetFocus ();
			break;
		default:
			return;
	}
}

void CSetParam::OpenFun()
{
	int ret;
	ret=MessageBox(TEXT("您要立即保存设置吗?"),TEXT("系统提问信息"),MB_YESNO|MB_ICONQUESTION);
	if (IDYES != ret)
	{
		return;
	}
	CEdit* pBoxOne;
	TCHAR out[1024];
	DWORD dwReadNum=512;
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT1);
	pBoxOne->GetWindowText (out,512);
	WideCharToMultiByte (CP_ACP,0,out,-1,theApp.AppSetup.SMSC,256,NULL,NULL);

	
	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT2);
	pBoxOne->GetWindowText (out,512);
	WideCharToMultiByte (CP_ACP,0,out,-1,theApp.AppSetup.SAFE1,256,NULL,NULL);

	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT3);
	pBoxOne->GetWindowText (out,512);
	WideCharToMultiByte (CP_ACP,0,out,-1,theApp.AppSetup.SAFE2,256,NULL,NULL);

	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT4);
	pBoxOne->GetWindowText (out,512);
	WideCharToMultiByte (CP_ACP,0,out,-1,theApp.AppSetup.SOS1,256,NULL,NULL);

	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT5);
	pBoxOne->GetWindowText (out,512);
	WideCharToMultiByte (CP_ACP,0,out,-1,theApp.AppSetup.SOS2,256,NULL,NULL);

	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT6);
	pBoxOne->GetWindowText (out,512);
	WideCharToMultiByte (CP_ACP,0,out,-1,theApp.AppSetup.SPECIAL,256,NULL,NULL);

	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT7);
	pBoxOne->GetWindowText (out,512);
	WideCharToMultiByte (CP_ACP,0,out,-1,theApp.AppSetup.FIRST,256,NULL,NULL);

	pBoxOne = (CEdit*) GetDlgItem (IDC_EDIT8);
	pBoxOne->GetWindowText (out,512);
	WideCharToMultiByte (CP_ACP,0,out,-1,theApp.AppSetup.SECOND,256,NULL,NULL);

	theApp.SaveAppSetup ();
}

⌨️ 快捷键说明

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