📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "stepftp.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "FtpView.h"
#include "FtpInforView.h"
#include "localfile.h"
#include "serverfile.h"
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_BNANY, OnBnany)
ON_BN_CLICKED(IDC_BNDEFAULT, OnBndefault)
ON_COMMAND(IDC_SWSVRDLG, OnSwsvrdlg)
ON_UPDATE_COMMAND_UI(IDC_SWSVRDLG, OnUpdateSwsvrdlg)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
// add CDialogBar
m_uidlgbarID=2234;
if (!m_dlgbar.Create(this, IDD_DLGTARGET,CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE,
m_uidlgbarID))
{
TRACE0("创建m_dlgbar失败\n");
return -1; // fail to create
}
m_dlgbar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_dlgbar);
m_dlgbar.SetDlgItemText(IDC_EDPORT,"21");
m_dlgbar.SetDlgItemText(IDC_EDADDRESS,"ftp.cdut.edu.cn");
m_dlgbar.SetDlgItemText(IDC_EDUSER,"qiuboyuan");
m_dlgbar.SetDlgItemText(IDC_EDPASSWORD,"love");
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnBnany()
{
// TODO: Add your control notification handler code here
m_dlgbar.SetDlgItemText(IDC_EDUSER,"anonymous");
m_dlgbar.SetDlgItemText(IDC_EDPASSWORD,"well00000000@hotmail.com");
}
void CMainFrame::OnBndefault()
{
// TODO: Add your control notification handler code here
m_dlgbar.SetDlgItemText(IDC_EDPORT,"21");
}
void CMainFrame::OnSwsvrdlg()
{
// TODO: Add your command handler code here
if(m_dlgbar.IsWindowVisible())
{
m_dlgbar.ShowWindow(SW_HIDE);
return;
}
m_dlgbar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_dlgbar);
m_dlgbar.ShowWindow(SW_SHOW);
}
void CMainFrame::OnUpdateSwsvrdlg(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(m_dlgbar.IsWindowVisible())
{
pCmdUI->SetCheck(1);
}
else
pCmdUI->SetCheck(0);
}
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
BOOL bResult;
bResult=m_splitterwndV.CreateStatic(this,3,1);
if(bResult==FALSE)
return FALSE;
bResult=m_splitterwndV.CreateView(0,0,RUNTIME_CLASS(CFtpView),CSize(375,100),pContext);
if(bResult==FALSE)
return FALSE;
bResult=m_splitterwndV.CreateView(2,0,RUNTIME_CLASS(CFtpInforView),CSize(375,100),pContext);
if(bResult==FALSE)
return FALSE;
m_splitterwndV.SetRowInfo(1,180,0);
bResult=m_splitterwndH.CreateStatic(&m_splitterwndV,1,2,WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL,m_splitterwndV.IdFromRowCol(1,0));
if(bResult==FALSE)
return FALSE;
bResult=m_splitterwndH.CreateView(0,0,RUNTIME_CLASS(CLocalFile),CSize(375,180),pContext);
if(bResult==FALSE)
return FALSE;
bResult=m_splitterwndH.CreateView(0,1,RUNTIME_CLASS(CServerFile),CSize(375,180),pContext);
if(bResult==FALSE)
return FALSE;
return TRUE;
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
/* if(m_ctLocDir.m_hWnd)
m_ctLocDir.SetWindowPos(this,0,0,cx-3,0,SWP_NOZORDER|SWP_NOMOVE);
if(m_ctLocFile.m_hWnd)
{
m_ctLocFile.ShowWindow(SW_HIDE);
m_ctLocFile.SetWindowPos(this,0,0,cx-1,cy-22,SWP_NOZORDER|SWP_NOMOVE);
m_ctLocFile.ShowWindow(SW_SHOW);
} */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -