📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "Kill.h"
#include "ClientTreeView.h"
#include "MainFrm.h"
#include "ConfigOther.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "ConfigServerDlg.h"
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" named_guids rename("EOF","adoEOF"), rename("BOF","adoBOF")
using namespace ADODB;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(IDR_MAINMENU_SERVERCONFIG, OnMainmenuServerconfig)
ON_COMMAND(IDR_MENU_TEST, OnMenuTest)
ON_COMMAND(IDR_MAINMENU_CONFIG_WEB, OnMainmenuConfigWeb)
ON_COMMAND(IDR_MAINMENU_CONFIG_OTHER, OnMainmenuConfigOther)
//}}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_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
/*
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
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
*/
EnableDocking(CBRS_ALIGN_ANY);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style&=~FWS_ADDTOTITLE ;//防止系统将子窗口的名字添加到标题栏
cs.style &= ~FWS_PREFIXTITLE;//防止系统将标题栏设置成应用程序名
cs.lpszName="Kill管理程序";//设置系统标题栏
// cs.
cs.cy = ::GetSystemMetrics(SM_CYSCREEN);
cs.cx = ::GetSystemMetrics(SM_CXSCREEN);
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
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
char appPath[256];
if(!m_Splitter.CreateStatic(this,1,2))
return FALSE;
//CPacketDataView CClientTreeView
if(!m_Splitter.CreateView(0,0,RUNTIME_CLASS(CClientTreeDlgView),CSize(175,100),pContext))
return FALSE;
if(!m_Splitter.CreateView(0,1,RUNTIME_CLASS(CClientInfoview),CSize(375,100),pContext))
return FALSE;
m_ClientTreeview=(CClientTreeDlgView *)m_Splitter.GetPane(0,0);
m_ClientInfoview=(CClientInfoview *)m_Splitter.GetPane(0,1);
m_ClientPort=-1;
m_ServerPort=-1;
// TODO: Add extra initialization here
GetCurrentDirectory(256,appPath); //取得应用程序当前路径
m_IniFile.Format("%s",appPath);
m_IniFile+="\\killconfig.ini";
strSection = "URL_ADDRESS";
strSectionKey = "URL1";
char inBuf[80];
GetPrivateProfileString (strSection,strSectionKey, NULL, inBuf, 80, m_IniFile);
m_InstallUrl=inBuf;
strSection = "URL_ADDRESS";
strSectionKey = "URL2";
GetPrivateProfileString (strSection,strSectionKey, NULL, inBuf, 80, m_IniFile);
m_UnInstallUrl=inBuf;
strSection = "SERVER_PORT";
strSectionKey = "CLIENT_PORT";
GetPrivateProfileString (strSection,strSectionKey, NULL, inBuf, 80, m_IniFile);
m_ClientPort=atoi(inBuf);
strSectionKey = "SERVER_PORT";
GetPrivateProfileString (strSection,strSectionKey, NULL, inBuf, 80, m_IniFile);
m_ServerPort=atoi(inBuf);
if(m_ServerPort!=0 && m_ClientPort!=0)
{
m_SocketServer.StartServer(m_ServerPort,m_ClientPort);
}
else
AfxMessageBox("程序启动后,请设置Socket端口");
// return CFrameWnd::OnCreateClient(lpcs, pContext);
}
void CMainFrame::OnMainmenuServerconfig()
{
// TODO: Add your command handler code here
CConfigServerDlg dlg;
int sport,cport;
if(dlg.DoModal()==IDOK)
{
sport=dlg.m_ServerPort;
cport=dlg.m_ClientPort;
m_SocketServer.StartServer(dlg.m_ServerPort,dlg.m_ClientPort);
m_ClientPort=dlg.m_ClientPort;
// m_InstallUrl=dlg.m_Url;
}
}
void CMainFrame::OnMenuTest()
{
// TODO: Add your command handler code here
}
void CMainFrame::OnMainmenuConfigWeb()
{
// TODO: Add your command handler code here
m_WebServerDlg.m_InstallPackAddress= m_InstallUrl;
m_WebServerDlg.m_UnInstallPackAddress= m_UnInstallUrl;
if(m_WebServerDlg.DoModal()==IDOK)
{
m_InstallUrl=m_WebServerDlg.m_InstallPackAddress;
m_UnInstallUrl=m_WebServerDlg.m_UnInstallPackAddress;
}
}
void CMainFrame::OnMainmenuConfigOther()
{
// TODO: Add your command handler code here
CConfigOther dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -