socket编程

源代码在线查看: tosdlgdlg.cpp

软件大小: 102 K
上传用户: faye3000
关键词: socket 编程
下载地址: 免注册下载 普通下载 VIP

相关代码

				// TosDLgDlg.cpp : implementation file
				//
				
				#include "stdafx.h"
				#include "TosDLg.h"
				#include "TosDLgDlg.h"
				#include "Resource.h"
				
				#include 
				#include "Tosteel.h"
				
				#include  "SC6NETMESOT.h"
				
				#ifdef _DEBUG
				#define new DEBUG_NEW
				#undef THIS_FILE
				static char THIS_FILE[] = __FILE__;
				#endif
				
				//CTOSTEEL	_tosteel;
				WakeHandles _wcb  ;
				
				struct ReqData{
					int		info;
					int		timing;
				//	char	Data[1024 * 2];
				} ;
				
				/////////////////////////////////////////////////////////////////////////////
				// CTosDLgDlg dialog
				
				CTosDLgDlg::CTosDLgDlg(CWnd* pParent /*=NULL*/)
					: CDialog(CTosDLgDlg::IDD, pParent)
				{
					//{{AFX_DATA_INIT(CTosDLgDlg)
					m_MsgNo = 0;
					m_MsgFmt = _T("");
					m_MsgData1 = _T("");
					m_MsgData2 = 0;
					m_MsgData3 = 0.0f;
					m_MsgData4 = 0.0;
					m_FactNo = 0;
					//}}AFX_DATA_INIT
					// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
					m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
				}
				
				void CTosDLgDlg::DoDataExchange(CDataExchange* pDX)
				{
					CDialog::DoDataExchange(pDX);
					//{{AFX_DATA_MAP(CTosDLgDlg)
					DDX_Text(pDX, IDC_MSGNO, m_MsgNo);
					DDX_Text(pDX, IDC_MSGFMT, m_MsgFmt);
					DDX_Text(pDX, IDC_MSGDATA1, m_MsgData1);
					DDX_Text(pDX, IDC_MSGDATA2, m_MsgData2);
					DDX_Text(pDX, IDC_MSGDATA3, m_MsgData3);
					DDX_Text(pDX, IDC_MSGDATA4, m_MsgData4);
					DDX_Text(pDX, IDC_FACTNO, m_FactNo);
					//}}AFX_DATA_MAP
				}
				
				BEGIN_MESSAGE_MAP(CTosDLgDlg, CDialog)
					//{{AFX_MSG_MAP(CTosDLgDlg)
					ON_WM_PAINT()
					ON_WM_QUERYDRAGICON()
					ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
					//}}AFX_MSG_MAP
				END_MESSAGE_MAP()
				
				/////////////////////////////////////////////////////////////////////////////
				// CTosDLgDlg message handlers
				
				BOOL CTosDLgDlg::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
					
					// TODO: Add extra initialization here
				
					char TaskName[] = "ALARM_SVR" ;
				
					int sts = S1TASKOPEN(&_wcb, TaskName, "", 0, 1);
				
					if ( sts != 0 ) 
					{
						MessageBox("Can not start the task(Task_name : ALARM_CLT) successfully!","Warning");
						exit(0);
					}
				
					CWnd * pCtrl ;
				
					pCtrl = GetDlgItem(IDC_MSGNO) ;
					pCtrl->SetWindowText("1");
				
					pCtrl = GetDlgItem(IDC_FACTNO) ;
					pCtrl->SetWindowText("1");
				
					pCtrl = GetDlgItem(IDC_MSGFMT) ;
					pCtrl->SetWindowText("%s%d%f%lf");
				
					pCtrl = GetDlgItem(IDC_MSGDATA1) ;
					pCtrl->SetWindowText("just a test !!!!");
				
					pCtrl = GetDlgItem(IDC_MSGDATA2) ;
					pCtrl->SetWindowText("11");
				
					pCtrl = GetDlgItem(IDC_MSGDATA3) ;
					pCtrl->SetWindowText("22");
				
					pCtrl = GetDlgItem(IDC_MSGDATA4) ;
					pCtrl->SetWindowText("33");
				
					return TRUE;  // return TRUE  unless you set the focus to a control
				}
				
				CTosDLgDlg::~CTosDLgDlg()
				{
					int sts = S1TASKCLOSE(&_wcb);
				}
				
				// 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 CTosDLgDlg::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 CTosDLgDlg::OnQueryDragIcon()
				{
					return (HCURSOR) m_hIcon;
				}
				
				void CTosDLgDlg::OnButton1() 
				{
					this->UpdateData(true) ;
				
					int     fact_no		;
					int     msg_no		;
					char	*msg_fmt	;
					char	*msg_data1	;
					int		msg_data2	;
					float	msg_data3	;
					double	msg_data4	;
					long	p_mesdat[32];
				
					char *p_host = "sen_host" ;
				
					fact_no		= m_FactNo ;
					msg_no		= m_MsgNo ;
					msg_fmt		= (char*)LPCTSTR(m_MsgFmt) ;
					msg_data1	= (char*)LPCTSTR(m_MsgData1) ;
					msg_data2	= m_MsgData2 ;
					msg_data3	= m_MsgData3 ;
					msg_data4	= m_MsgData4 ;
				
					p_mesdat[0] = 4 ;
					p_mesdat[1] = (long)msg_data1 ;
					p_mesdat[2] = (long)msg_data2 ;
					p_mesdat[3] = (long)&msg_data3 ;
					p_mesdat[4] = (long)&msg_data4 ;
				
					int w_ans = SC6NETMESOT(p_host , fact_no , msg_no , msg_fmt , p_mesdat ) ;
				
					if ( w_ans != 0 ) 
					{
						MessageBox("Can not send the message to the client(Task_name : ALARM_CLT)","Warning");
					}
					else
					{
						MessageBox("Send the message to the client(Task_name : ALARM_CLT) successfully!","Ok");
					}
				}
							

相关资源