FreeCode2008.rar
// CmdShellDlg.cpp : implementation file // #include "stdafx.h" #include "darkshell.h" #include "CmdShellDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCmdShellDlg dialog CCmdShellDlg::CCmdShellDlg(CWnd* pParent /*=NULL*/) : CDialog(CCmdShellDlg::IDD, pParent) { //{{AFX_DATA_INIT(CCmdShellDlg) m_Cmd = _T("net user"); //}}AFX_DATA_INIT } void CCmdShellDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCmdShellDlg) DDX_Control(pDX, IDC_EDIT_SHELL, m_EdtShell); DDX_Text(pDX, IDC_EDIT_CMD, m_Cmd); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CCmdShellDlg, CDialog) //{{AFX_MSG_MAP(CCmdShellDlg) ON_BN_CLICKED(IDC_BTN_RUN, OnBtnRun) ON_BN_CLICKED(IDC_BTN_CLEAN, OnBtnClean) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CCmdShellDlg message handlers BOOL CCmdShellDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the small icon for this dialog SetIcon(AfxGetApp()->LoadIcon(IDI_ICOBTN_SHELL), FALSE); CenterWindow(); // TODO: Add extra initialization here TCHAR szIp[100]; DWORD dwPort = m_hServer.GetPeerName(szIp); CString strTitle; strTitle.Format(_T("超级终端@%s:%d"), szIp, dwPort); SetWindowText(strTitle); //设置回调 m_hServer.SetCallBack(this); //开始CmdShell m_hServer.Begin(); return TRUE; } void CCmdShellDlg::OnCancel() { // TODO: Add extra cleanup here m_hServer.SendCmd(_T("exit\r\n")); m_hServer.Close(); //非模式对话框,需要这样销毁对话框 DestroyWindow(); //CDialog::OnCancel(); } void CCmdShellDlg::PostNcDestroy() { // TODO: Add your specialized code here and/or call the base class //delete掉主对话框中new出来的指针 delete this; CDialog::PostNcDestroy(); } BOOL CCmdShellDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if (pMsg->message == WM_KEYDOWN) { int nVirtKey = (int)pMsg->wParam; if (nVirtKey == VK_RETURN) { //如果是回车在这里做你要做的事情,或者什么也不作 return TRUE; } if (nVirtKey == VK_ESCAPE) { //如果是ESC在这里做你要做的事情,或者什么也不作 return TRUE; } } return CDialog::PreTranslateMessage(pMsg); } //回调函数 void CCmdShellDlg::OnRecvMsg(LPCTSTR szMsg) { m_EdtShell.AddText(szMsg); } void CCmdShellDlg::OnBtnRun() { // TODO: Add your control notification handler code here UpdateData(); m_Cmd +=_T("\r\n"); m_hServer.SendCmd(m_Cmd); } void CCmdShellDlg::OnBtnClean() { // TODO: Add your control notification handler code here m_EdtShell.ClearEdit(); }
- 1
- 2
- 粉丝: 0
- 资源: 1
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- mongodb数据库基本操作.pdf
- C#,布尔可满足性问题(Boolean Satisfiability Problem)算法与源代码
- C#,回文分割问题(Palindrome Partitioning Problem)算法与源代码
- C#,煎饼排序问题(Pancake Sorting Problem)算法与源代码
- C#,排列组合的堆生成法(Heap’s Algorithm for generating permutations)算法与源代码
- C#,老鼠迷宫问题的回溯法求解(Rat in a Maze)算法与源代码
- 6693eeb8d683458a07938615fba9e68f.apk
- C#,数值计算,解微分方程的龙格-库塔二阶方法与源代码
- C#,数值计算,用割线法(Secant Method)求方程根的算法与源代码
- C#,子集和问题(Subset Sum Problem)的算法与源代码