⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 简单的远程控制工具,分为服务器与客户斋,让你了解socket编程的知识.
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "Ctrl_Clnt9.h"

#include "MainFrm.h"
#include "Ctrl_Clnt9Doc.H"
#include "GetImage.H"
#include "SendMsg.H"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

////////         VERSION         ////////////////////
//#define _MIN_VERSION
////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CCJMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CCJMDIFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_TIMER()
	//}}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 (CCJMDIFrameWnd::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_pComboBox = (CComboBox*)m_wndToolBar.InsertControl(
		RUNTIME_CLASS(CComboBox), _T(""), CRect(-100,-200,0,0), ID_COMBOBOX,
		WS_CHILD | CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | CBS_HASSTRINGS );

	m_pEditText = (CEdit*)m_wndToolBar.InsertControl(
		RUNTIME_CLASS(CEdit), _T(""), CRect(-500,-200,0,0), ID_EDIT_TEXT,
		WS_CHILD | ES_AUTOVSCROLL | ES_READONLY | WS_EX_STATICEDGE | WS_BORDER);

	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	SetInitialSize (0,0,238,400);
	///////////////////////////////////////////////////
	// Initialize dialog bar m_wndOutput1
	///////////////////////////////////////////////////

	if (!m_wndResult.Create(this, IDM_VIEW_RESULT,
		_T("Result View"), CSize(600,400), CBRS_BOTTOM))
	{
		TRACE0("Failed to create dialog bar IDM_VIEW_RESULT\n");
		return -1;		// fail to create
	}

//////////////////////////define in Stdafx.H
#if !defined(_MIN_VERSION)
	if (!m_wndWorkspace.Create(this, IDM_VIEW_COMMAND,
		_T("Command View"), CSize(220,450), CBRS_LEFT))
	{
		TRACE0("Failed to create dialog bar m_wndWorkspace\n");
		return -1;		// fail to create
	}

	// Add the views to the tab control.
	m_wndWorkspace.AddView(_T("Command"),    RUNTIME_CLASS(CCmdView));

	m_wndWorkspace.SetMenuID(IDR_RESULT);
	m_wndWorkspace.EnableDockingOnSizeBar(CBRS_ALIGN_ANY);
#endif
	m_wndResult.SetMenuID(IDR_RESULT);
	m_wndResult.EnableDockingOnSizeBar(CBRS_ALIGN_ANY);

	EnableDockingSizeBar(CBRS_ALIGN_ANY);
//////////////////////////define in Stdafx.H
#if !defined(_MIN_VERSION)
	DockSizeBar(&m_wndWorkspace);
#endif
	DockSizeBar(&m_wndResult);
    SetTimer(2, 10000, NULL);
	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~FWS_ADDTOTITLE ; 
	if( !CCJMDIFrameWnd::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
{
	CCJMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CCJMDIFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers



BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_KEYDOWN)
	{
//		if (pMsg->wParam == VK_ESCAPE)
//			return FALSE;
		if (pMsg->wParam == VK_F12)
		{
			DestroyWindow ();
			return TRUE;
		}
	}

	// TODO: Add your specialized code here and/or call the base class
	
	return CCJMDIFrameWnd::PreTranslateMessage(pMsg);
}





void CMainFrame::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
  CCtrl_Clnt9Doc *lpDoc;
  lpDoc =  (CCtrl_Clnt9Doc *)g_pDoc;
  if (lpDoc == NULL || lpDoc->m_bUsing == TRUE) return;
  
  SendMsg(CMD_NULL);
  CCJMDIFrameWnd::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -