📄 tftpcliview.cpp
字号:
// TftpCliView.cpp : implementation file
//
#include "stdafx.h"
#include "WinDemo.h"
#include "TftpCliView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTftpCliView
IMPLEMENT_DYNCREATE(CTftpCliView, CFormView)
CTftpCliView::CTftpCliView()
: CFormView(CTftpCliView::IDD)
{
//{{AFX_DATA_INIT(CTftpCliView)
m_Status = _T("");
m_File = _T("");
m_TftpsIP = _T("");
//}}AFX_DATA_INIT
}
CTftpCliView::~CTftpCliView()
{
}
void CTftpCliView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTftpCliView)
DDX_Control(pDX, IDC_Transfer, m_Transfer);
DDX_Text(pDX, IDC_Stat, m_Status);
DDV_MaxChars(pDX, m_Status, 9);
DDX_Text(pDX, IDC_FILE_TRANS, m_File);
DDV_MaxChars(pDX, m_File, 20);
DDX_Text(pDX, IDC_TFTPS_IP, m_TftpsIP);
DDV_MaxChars(pDX, m_TftpsIP, 15);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTftpCliView, CFormView)
//{{AFX_MSG_MAP(CTftpCliView)
ON_BN_CLICKED(IDC_Transfer, OnTransfer)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_SHOW_STATUS, OnShowStatus)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTftpCliView diagnostics
#ifdef _DEBUG
void CTftpCliView::AssertValid() const
{
CFormView::AssertValid();
}
void CTftpCliView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTftpCliView message handlers
void CTftpCliView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
theApp.m_pWndStatus = this;
}
void CTftpCliView::OnTransfer()
{
char Temp[20], x1[3], x2[5];
int i=0,j=0,z=0, num;
m_Transfer.EnableWindow(FALSE);
/* Start the TFTP Client by sending 5 to Embedded Side */
unsigned long x = htonl(5);
theApp.SendBytes((char *)&x, sizeof(unsigned long));
UpdateData(TRUE); /* Get Data from the User */
/* Sending Server IP address to the Embedded Side */
strcpy(Temp, (const char *)m_TftpsIP);
*x2 = 0;
while (Temp[i] != 0 && (i < 15))
{
while((Temp[i] != 0) && (Temp[i] != '.') && i < 15)
{
x1[j++] = Temp[i++];
}
num = atoi(x1);
strcat(x2, (char *)&num);
j = 0;
i++;
}
theApp.SendBytes(x2, 4);
/* Sending File Name to the Embedded Side */
for (i = 0; i<20; i++)
Temp[i] = 0;
strcpy(Temp, (const char *)m_File);
theApp.SendBytes(Temp, strlen(Temp));
}
LRESULT CTftpCliView::OnShowStatus(WPARAM wParam, LPARAM lParam)
{
m_Status = (LPCSTR)wParam;
UpdateData(FALSE); /* calls DDX */
if ((m_Status == "Completed") || (m_Status == "Error"))
m_Transfer.EnableWindow(TRUE);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -