包含目录添加
D:\OpenRS\external\include\BCGCBPro22.1
D:\OpenRS\desktop\include
库目录添加D:\OpenRS\external\lib
输出文件\openRS\desktop\debug\vc60\Plugins\ext_Matching.dll
在解决方案视图中,在”资源文件”右键-添加-资源-Menu-新建
编辑菜单
注意:添加资源后自动生成“resource.h”
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__B191D6A9_6437_4DC2_85D3_D4A09AC05E69__INCLUDED_)
#define AFX_STDAFX_H__B191D6A9_6437_4DC2_85D3_D4A09AC05E69__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN// Exclude rarely-used stuff from Windows headers
#include
#include
#ifndef _AFX_NO_OLE_SUPPORT
#include
#include
#include
#endif // _AFX_NO_OLE_SUPPORT
#ifndef _AFX_NO_DB_SUPPORT
#include
#endif // _AFX_NO_DB_SUPPORT
#ifndef _AFX_NO_DAO_SUPPORT
#include
#endif // _AFX_NO_DAO_SUPPORT
#include
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include
#endif // _AFX_NO_AFXCMN_SUPPORT
#include
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__B191D6A9_6437_4DC2_85D3_D4A09AC05E69__INCLUDED_)
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h"// main symbols
class CExt_MatchingApp : public CWinApp
{
public:
CExt_MatchingApp(){};
DECLARE_MESSAGE_MAP()
};
extern CExt_MatchingApp g_theApp;
#ifndef _ORS_VIEWER_EXTENSION_MATCHING_H_
#define _ORS_VIEWER_EXTENSION_MATCHING_H_
#include "orsGuiBase/orsIGuiElement.h"
#include "orsGuiBase/orsIViewerExtension.h"
interface extXMatch : public orsIViewerExtension, public orsObjectBase
{
public:
extXMatch();
~extXMatch();
// SetLayerCollection、SetImageViewer是实现orsIViewerExtension接口必须要实现的成员函数
virtual void SetLayerCollection(orsILayerCollection *pLayerCollection);
virtual void SetImageViewer(orsIImageView *pImageViewer);
// create、pluginMenu、windowProc、OnCmdMsg是实现orsIGuiExtension接口必须要实现的成员函数
virtual bool create(orsIFrameWnd *frameWnd);
virtual bool pluginMenu(orsIFrameWnd *frameWnd);
virtual LRESULT windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
public:
orsILayerCollection *GetLayerCollection(){ return m_pLayerCollection; };
public:
orsIFrameWnd *m_pParentFrameWnd;
orsILayerCollection *m_pLayerCollection;
orsIImageView *m_pImageViewer;
public:
ORS_OBJECT_IMP2(extXMatch, orsIViewerExtension, orsIGuiExtension, "matching", "orsViewer Extension - Matching")
};
#endif // _ORS_VIEWER_EXTENSION_MATCHING_H_
#include "stdafx.h"
#include "extXMatch.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CExt_MatchingApp, CWinApp)
END_MESSAGE_MAP()
CExt_MatchingApp g_theApp;
extXMatch::extXMatch()
{
m_pParentFrameWnd = NULL;
m_pLayerCollection = NULL;
m_pImageViewer = NULL;
}
extXMatch::~extXMatch()
{
}
bool extXMatch::create(orsIFrameWnd *frameWnd)
{
HINSTANCE oldRcHandle = AfxGetResourceHandle();
AfxSetResourceHandle(GetModuleHandle("ext_Matching.dll"));
//////////////////////////////////////////////////////////////////////////
m_pParentFrameWnd = frameWnd;
frameWnd->AddMenu(&g_theApp, IDR_MENU1, _T("My Test Menu"), _T("帮助"));
//////////////////////////////////////////////////////////////////////////
AfxSetResourceHandle(oldRcHandle);
return true;
}
void extXMatch::SetLayerCollection(orsILayerCollection *pLayerCollection)
{
m_pLayerCollection = pLayerCollection;
}
void extXMatch::SetImageViewer(orsIImageView *pImageViewer)
{
m_pImageViewer = pImageViewer;
}
LRESULT extXMatch::windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return AfxGetAfxWndProc()(hWnd, message, wParam, lParam);
return FALSE;
}
BOOL extXMatch::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
if (g_theApp.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
return FALSE;
}
//////////////////////////////////////////////////////////////////////////
bool extXMatch::pluginMenu(orsIFrameWnd *frameWnd)
{
HINSTANCE oldRcHandle = AfxGetResourceHandle();
AfxSetResourceHandle(GetModuleHandle("ext_Matching.dll"));
frameWnd->AddMenu(&g_theApp, IDR_MENU1, _T("My Test Menu"), _T("帮助"));
//////////////////////////////////////////////////////////////////////////
AfxSetResourceHandle(oldRcHandle);
return true;
}
#include "stdafx.h"
#include "orsBase/orsIPlatform.h"
#include "extXMatch.h"
//////////////////////////////////////////////////////////////////////////
extXMatch *g_orsExtXMatch = NULL;
orsIObject* createExtXMatch(bool bForRegister)
{
if (bForRegister)
return new extXMatch;
else {
g_orsExtXMatch = new extXMatch;
return g_orsExtXMatch;
}
}
//////////////////////////////////////////////////////////////////////////
class orsXPlugin : public orsIPlugin
{
public:
virtual const orsChar *getID()
{
return "org.openRS.ext_Matching";
};
virtual const orsChar *getName()
{
return "ext_Matching";
};
virtual const orsChar *getProvider()
{
return "edu.whu.rs";
};
virtual const orsChar *getVersion()
{
return "0.1";
}
virtual bool initialize(orsIPlatform* platform)
{
orsIRegisterService *pRegister = platform->getRegisterService();
pRegister->registerObject(createExtXMatch);
return true;
}
virtual void finalize()
{
}
};
ORS_REGISTER_PLUGIN(orsXPlugin)
注:参考来源http://blog.csdn.net/zshuaihua/article/details/44941467,原文章基于VC++6.0进行,现在在VS2013下实践了