我的包是用C++,VS2015開發的。 例如,我在項目菜單和工具欄中定義了一些命令,當我啓動VS時,工具欄菜單很好,但是項目菜單中的命令沒有出現,那麼我必須點擊工具欄菜單中的任何按鈕,然後項目菜單中的命令返回。 當啓動visual studio或打開一個項目時,我想要我的包初始化項目菜單命令。使用C++開發VSPackage,如何在啓動時初始化我的包visual studio
我喜歡這個
class ATL_NO_VTABLE CYHMExtensionsPackage :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CYHMExtensionsPackage, &CLSID_YHMExtensions>,
// Provides the implementation for IVsPackage to make this COM object into a VS Package.
public IVsPackageImpl<CYHMExtensionsPackage, &CLSID_YHMExtensions>,
public IOleCommandTargetImpl<CYHMExtensionsPackage>,
// Provides consumers of this object with the ability to determine which interfaces support extended error information.
public ATL::ISupportErrorInfoImpl<&__uuidof(IVsPackage)>
{
public:
// Provides a portion of the implementation of IUnknown, in particular the list of interfaces
// the CYHMExtensionsPackage object will support via QueryInterface
BEGIN_COM_MAP(CYHMExtensionsPackage)
COM_INTERFACE_ENTRY(IVsPackage)
COM_INTERFACE_ENTRY(IOleCommandTarget)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
VSL_DECLARE_NOT_COPYABLE(CYHMExtensionsPackage)
public:
CYHMExtensionsPackage():m_dwEditorCookie(0), m_MyToolWindow(GetVsSiteCache())
{
GetYHMVSSolution();
}
~CYHMExtensionsPackage()
{
}
...
};