📄 connectdial.cpp
字号:
// connectDial.cpp : implementation file
//
#include "stdafx.h"
#include "ftpclient.h"
#include "connectDial.h"
#include "FtpGet.h"
#include "Dealsocket.h"
#include "myfile.h"
#include "viewDial.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CString dir;
/////////////////////////////////////////////////////////////////////////////
// connectDial dialog
connectDial::connectDial(CWnd* pParent /*=NULL*/)
: CDialog(connectDial::IDD, pParent)
{
//{{AFX_DATA_INIT(connectDial)
host="218.94.61.52";
port=21;
user="anonymous";
password="anonymous";
//}}AFX_DATA_INIT
}
void connectDial::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(connectDial)
DDX_Control(pDX, IDC_EDIT4, m_myedit4);
DDX_Control(pDX, IDC_EDIT3, m_myedit3);
DDX_Control(pDX, IDC_EDIT2, m_myedit2);
DDX_Control(pDX, IDC_CHECK1, m_mycheck1);
DDX_Control(pDX, IDC_RADIO1, m_ctrlRadio1);
DDX_Text(pDX, IDC_EDIT1, host);
DDX_Text(pDX, IDC_EDIT2, user);
DDX_Text(pDX, IDC_EDIT3, password);
DDX_Text(pDX, IDC_EDIT4, port);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(connectDial, CDialog)
//{{AFX_MSG_MAP(connectDial)
ON_WM_CTLCOLOR()
ON_WM_PAINT()
ON_BN_CLICKED(IDC_CHECK1, OnCheck)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// connectDial message handlers
void connectDial::OnOK()
{
UpdateData();
pasv=!m_ctrlRadio1.GetCheck();
// TODO: Add extra validation here
hCtrlSock=
CFtpGet::ConnectFtp( host, port, user, password);
if( hCtrlSock==INVALID_SOCKET) flag=-1;
CDialog::OnOK();
}
void connectDial::OnCancel()
{
// TODO: Add extra cleanup here
flag=-1;
CDialog::OnCancel();
}
HBRUSH connectDial::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return m_Brush;
}
void connectDial::OnPaint()
{
CPaintDC dc(this);
CRect rect;
m_ctrlRadio1.SetCheck(TRUE);
GetClientRect(&rect);//得到窗体的大小
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap(IDB_BITMAP1);//加载背景图片
BITMAP bitMap;
bmpBackground.GetBitmap(&bitMap);
CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground);
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth, bitMap.bmHeight,SRCCOPY);//该函数给对话框贴上位图
}
void connectDial::OnCheck()
{ CString a;
BOOL check=m_mycheck1.GetCheck();
if(check) { port=21;
user="anonymous";
password="anonymous";
a.Format("%d",port);
SetDlgItemText(IDC_EDIT2,user);
SetDlgItemText(IDC_EDIT3,password);
SetDlgItemText(IDC_EDIT4,a);
m_myedit2.EnableWindow(false);
m_myedit3.EnableWindow(false);
m_myedit4.EnableWindow(false);
}
else
{
m_myedit2.EnableWindow(true);
m_myedit3.EnableWindow(true);
m_myedit4.EnableWindow(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -