📄 tftpdemodlg.cpp
字号:
// TftpDemoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "WinDemo.h"
#include "TftpDemoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTftpDemoDlg dialog
CTftpDemoDlg::CTftpDemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTftpDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTftpDemoDlg)
m_File = _T("test.txt");
m_Status = _T("");
m_TftpsIP = _T("208.239.168.121");
//}}AFX_DATA_INIT
}
void CTftpDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTftpDemoDlg)
DDX_Control(pDX, IDC_Transfer, m_Transfer);
DDX_Text(pDX, IDC_FILE_TRANS, m_File);
DDV_MaxChars(pDX, m_File, 20);
DDX_Text(pDX, IDC_Stat, m_Status);
DDV_MaxChars(pDX, m_Status, 9);
DDX_Text(pDX, IDC_TFTPS_IP, m_TftpsIP);
DDV_MaxChars(pDX, m_TftpsIP, 15);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTftpDemoDlg, CDialog)
//{{AFX_MSG_MAP(CTftpDemoDlg)
ON_BN_CLICKED(IDC_Transfer, OnTransfer)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_TFTP_Exit, OnTFTPExit)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_SHOW_STATUS, OnShowStatus)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTftpDemoDlg message handlers
int CTftpDemoDlg::DoModal()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DoModal();
}
void CTftpDemoDlg::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));
}
int CTftpDemoDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
theApp.m_pWndStatus = this;
return 0;
}
LRESULT CTftpDemoDlg::OnShowStatus(WPARAM wParam, LPARAM lParam)
{
m_Status = (LPCSTR)wParam;
UpdateData(FALSE); /* calls DDX */
if (m_Status == "Completed")
m_Transfer.EnableWindow(TRUE);
return 0;
}
void CTftpDemoDlg::OnTFTPExit()
{
CTftpDemoDlg::OnCancel();
CTftpDemoDlg::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -