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

📄 stkappsink.cpp

📁 本代码为使用vc平台开发stk软件x插件的一个范例。
💻 CPP
字号:
/******************************************************************************/
/*****       Copyright 2004-2004, Analytical Graphics, Incorporated.      *****/
/******************************************************************************/
// STKAppSink.cpp : implementation file
//

#include "stdafx.h"
#include "cppmdi.h"
#include "STKAppSink.h"
#include "MainFrm.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

extern CCPPMDIApp theApp;


/////////////////////////////////////////////////////////////////////////////
// CSTKAppSink

IMPLEMENT_DYNCREATE(CSTKAppSink, CCmdTarget)

CSTKAppSink::CSTKAppSink()
{
	EnableAutomation();
}

CSTKAppSink::~CSTKAppSink()
{
}

void CSTKAppSink::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.

	CCmdTarget::OnFinalRelease();
}

// OnScenarioNew
//   called in response to a "New / Scenario" connect command to
//   create the 2D and VO windows
void CSTKAppSink::OnScenarioNew(BSTR path)
{
	theApp.GetMainFrame()->NewWindows();
	theApp.GetMainFrame()->m_IsScenarioLoaded = true;
}

// OnScenarioLoad
//   called in response to a "Load / Scenario" connect command to
//   create the 2D and VO windows
void CSTKAppSink::OnScenarioLoad(BSTR path)
{
	theApp.GetMainFrame()->NewWindows();
	theApp.GetMainFrame()->m_IsScenarioLoaded = true;
}

// OnScenarioClose
//   called in response to a "Unload / Scenario/*" connect command to
//   create the 2D and VO windows
void CSTKAppSink::OnScenarioClose()
{
	theApp.GetMainFrame()->m_IsScenarioLoaded = false;

	if (theApp.GetMainFrame()->MDIGetActive())
	{
		theApp.CloseAllDocuments(FALSE);
	}
}

// OnScenarioSave
//   called in response to a "Save /" connect command
void CSTKAppSink::OnScenarioSave(BSTR path)
{
}

// OnLogMessage
//   updates the Message Viewer with a new message that we received from
//   STK/X.  These messages are identical to the ones you would see in the
//   STK message viewer.
void CSTKAppSink::OnLogMessage(	BSTR				bstrMsg, 
								AgELogMsgType		eType, 
								long				lErrorCode, 
								BSTR				bstrFileName, 
								long				lLineNo, 
								AgELogMsgDispID		eDispID)
{
	static const CString MsgTypeNames[] = {	"Debug", "Info", "ForceInfo", "Warning", "Alarm" };
	static const CString MsgDispIDNames[] =	{ "All", "Default", "MsgWin", "StatusBar" };

	CString	msg;
	CString msgType("Unknown");
	CString msgID("Unknown");

	// get strings corresponding to message type and id enums
	if (eType >= eLogMsgDebug && eType <= eLogMsgAlarm)
		msgType = MsgTypeNames[eType];

	if (eDispID >= eLogMsgDispAll && eDispID <= eLogMsgDispStatusBar)
		msgID = MsgDispIDNames[eDispID + 1];

	msg.Format("<Message> %s  <Type> %s  <Error Code> %i  <Filename> %s  <Line #> %i  <ID> %s",
					bstrMsg,
					msgType,
					lErrorCode,
					bstrFileName,
					lLineNo,
					msgID);

	theApp.m_MsgViewDlg.AddMessage(msg);
}




BEGIN_MESSAGE_MAP(CSTKAppSink, CCmdTarget)
	//{{AFX_MSG_MAP(CSTKAppSink)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CSTKAppSink, CCmdTarget)
	//{{AFX_DISPATCH_MAP(CSTKAppSink)
		// NOTE - the ClassWizard will add and remove mapping macros here.
     DISP_FUNCTION_ID(CSTKAppSink,"OnScenarioNew",1,OnScenarioNew,VTS_NONE,VTS_BSTR)
     DISP_FUNCTION_ID(CSTKAppSink,"OnScenarioLoad",2,OnScenarioLoad,VTS_NONE,VTS_BSTR)
     DISP_FUNCTION_ID(CSTKAppSink,"OnScenarioClose",3,OnScenarioClose,VTS_NONE,VTS_NONE)
     DISP_FUNCTION_ID(CSTKAppSink,"OnScenarioSave",4,OnScenarioSave,VTS_NONE,VTS_BSTR)
     DISP_FUNCTION_ID(CSTKAppSink,"OnLogMessage",5,OnLogMessage,VTS_NONE,VTS_BSTR VTS_I4 VTS_I4 VTS_BSTR VTS_I4 VTS_I4)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()


// Note: we add support for IID_ISTKAppSink to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {C859C0B4-581E-4671-B655-27E49F5E35BE}
static const IID IID_ISTKAppSink =
{ 0xc859c0b4, 0x581e, 0x4671, { 0xb6, 0x55, 0x27, 0xe4, 0x9f, 0x5e, 0x35, 0xbe } };

BEGIN_INTERFACE_MAP(CSTKAppSink, CCmdTarget)
	INTERFACE_PART(CSTKAppSink, DIID_IAgSTKXApplicationEvents, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSTKAppSink message handlers
/******************************************************************************/
/*****       Copyright 2004-2004, Analytical Graphics, Incorporated.      *****/
/******************************************************************************/

⌨️ 快捷键说明

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