From: <bl...@us...> - 2003-05-12 07:21:48
|
Update of /cvsroot/cpptool/rfta/src/rftavc7addin In directory sc8-pr-cvs1:/tmp/cvs-serv27609 Modified Files: AddIn.cpp Connect.cpp stdafx.h Log Message: * finally managed to enable the MFC within the add-in Index: AddIn.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/AddIn.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AddIn.cpp 11 May 2003 17:53:09 -0000 1.1 --- AddIn.cpp 12 May 2003 07:21:44 -0000 1.2 *************** *** 7,11 **** CAddInModule _AtlModule; ! // DLL Entry Point extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) --- 7,11 ---- CAddInModule _AtlModule; ! /* // DLL Entry Point extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) *************** *** 14,17 **** --- 14,89 ---- return _AtlModule.DllMain(dwReason, lpReserved); } + */ + + + + + + + ///////////////////////////////////////////////////////////////////////////// + // RFTAAddinVC7App + + class RFTAAddinVC7App : public CWinApp + { + public: + RFTAAddinVC7App(); + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(RFTAAddinVC7App) + public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + //}}AFX_VIRTUAL + + //{{AFX_MSG(RFTAAddinVC7App) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + }; + + + ///////////////////////////////////////////////////////////////////////////// + // RFTAAddinVC7App + + BEGIN_MESSAGE_MAP(RFTAAddinVC7App, CWinApp) + //{{AFX_MSG_MAP(RFTAAddinVC7App) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP + END_MESSAGE_MAP() + + ///////////////////////////////////////////////////////////////////////////// + // The one and only RFTAAddinVC7App object + + RFTAAddinVC7App theApp; + + ///////////////////////////////////////////////////////////////////////////// + // RFTAAddinVC7App construction + + RFTAAddinVC7App::RFTAAddinVC7App() + { + // TODO: add construction code here, + // Place all significant initialization in InitInstance + } + + ///////////////////////////////////////////////////////////////////////////// + // RFTAAddinVC7App initialization + + BOOL RFTAAddinVC7App::InitInstance() + { + _AtlModule.SetResourceInstance(m_hInstance); + + return CWinApp::InitInstance(); + } + + int RFTAAddinVC7App::ExitInstance() + { + // _AtlModule.Term(); + return CWinApp::ExitInstance(); + } + + *************** *** 19,22 **** --- 91,95 ---- STDAPI DllCanUnloadNow(void) { + AFX_MANAGE_STATE(AfxGetStaticModuleState()); return _AtlModule.DllCanUnloadNow(); } *************** *** 26,29 **** --- 99,103 ---- STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { + AFX_MANAGE_STATE(AfxGetStaticModuleState()); return _AtlModule.DllGetClassObject(rclsid, riid, ppv); } *************** *** 33,36 **** --- 107,111 ---- STDAPI DllRegisterServer(void) { + AFX_MANAGE_STATE(AfxGetStaticModuleState()); // registers object, typelib and all interfaces in typelib HRESULT hr = _AtlModule.DllRegisterServer(); *************** *** 42,45 **** --- 117,121 ---- STDAPI DllUnregisterServer(void) { + AFX_MANAGE_STATE(AfxGetStaticModuleState()); HRESULT hr = _AtlModule.DllUnregisterServer(); return hr; Index: Connect.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/Connect.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Connect.cpp 11 May 2003 17:53:09 -0000 1.1 --- Connect.cpp 12 May 2003 07:21:44 -0000 1.2 *************** *** 57,60 **** --- 57,88 ---- }; + + /* + + + void GetLastErrorDescription(CComBSTR& bstr) + { + CComPtr<IErrorInfo> pErrorInfo; + if (GetErrorInfo(0, &pErrorInfo) == S_OK) + pErrorInfo->GetDescription(&bstr); + } + + #define VERIFY_OK(f) \ + { \ + HRESULT hr = (f); \ + if (hr != S_OK) \ + { \ + if (FAILED(hr)) \ + { \ + CComBSTR bstr; \ + GetLastErrorDescription(bstr); \ + _RPTF2(_CRT_ASSERT, "Object call returned %lx\n\n%S", hr, (BSTR) bstr); \ + } \ + else \ + _RPTF1(_CRT_ASSERT, "Object call returned %lx", hr); \ + } \ + } + */ + inline void checkIDTCall( HRESULT hresult ) { *************** *** 78,82 **** STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication, AddInDesignerObjects::ext_ConnectMode ConnectMode, IDispatch *pAddInInst, SAFEARRAY ** /*custom*/ ) { ! // AFX_MANAGE_STATE(AfxGetStaticModuleState()); // _asm int 3; // comment this out to force an assertion when loading the add-in. --- 106,110 ---- STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication, AddInDesignerObjects::ext_ConnectMode ConnectMode, IDispatch *pAddInInst, SAFEARRAY ** /*custom*/ ) { ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); // _asm int 3; // comment this out to force an assertion when loading the add-in. *************** *** 320,329 **** STDMETHODIMP CConnect::Exec(BSTR bstrCmdName, EnvDTE::vsCommandExecOption ExecuteOption, VARIANT * /*pvarVariantIn*/, VARIANT * /*pvarVariantOut*/, VARIANT_BOOL *pvbHandled) { *pvbHandled = VARIANT_FALSE; if(ExecuteOption == EnvDTE::vsCommandExecOptionDoDefault) { CComBSTR commandName = bstrCmdName; ! ::MessageBoxW( 0, commandName, commandName, MB_OK ); *pvbHandled = VARIANT_TRUE; --- 348,360 ---- STDMETHODIMP CConnect::Exec(BSTR bstrCmdName, EnvDTE::vsCommandExecOption ExecuteOption, VARIANT * /*pvarVariantIn*/, VARIANT * /*pvarVariantOut*/, VARIANT_BOOL *pvbHandled) { + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + *pvbHandled = VARIANT_FALSE; if(ExecuteOption == EnvDTE::vsCommandExecOptionDoDefault) { CComBSTR commandName = bstrCmdName; + AfxMessageBox( "Hello from MFC: " + CString(commandName) ); ! // ::MessageBoxW( 0, commandName, commandName, MB_OK ); *pvbHandled = VARIANT_TRUE; Index: stdafx.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/stdafx.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** stdafx.h 11 May 2003 17:53:10 -0000 1.1 --- stdafx.h 12 May 2003 07:21:44 -0000 1.2 *************** *** 36,39 **** --- 36,48 ---- #include "resource.h" + + + #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + + #include <afxwin.h> // MFC core and standard components + #include <afxdisp.h> + #include <afxcmn.h> + #include <afxtempl.h> + #include <atlbase.h> #include <atlcom.h> |