[commit] r1506 - in trunk/SDK/BON: Common Wizard/Templates/1033

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Sep 7 09:55:06 CDT 2011


Author: ksmyth
Date: Wed Sep  7 09:55:06 2011
New Revision: 1506

Log:
Use #import-style COM in RawComponent.cpp

Modified:
   trunk/SDK/BON/Common/ComHelp.cpp
   trunk/SDK/BON/Common/ComponentObj.h
   trunk/SDK/BON/Common/GMECOM.H
   trunk/SDK/BON/Wizard/Templates/1033/RawComponent.cpp

Modified: trunk/SDK/BON/Common/ComHelp.cpp
==============================================================================
--- trunk/SDK/BON/Common/ComHelp.cpp	Wed Sep  7 09:13:24 2011	(r1505)
+++ trunk/SDK/BON/Common/ComHelp.cpp	Wed Sep  7 09:55:06 2011	(r1506)
@@ -1 +1,20 @@
 #include "StdAfx.h"
+
+#include "Comdef.h"
+#include "ComponentConfig.h"
+
+void SetErrorInfo(HRESULT hr, const wchar_t* err)
+{
+	ICreateErrorInfoPtr errCreate;
+	if (SUCCEEDED(CreateErrorInfo(&errCreate))
+		&& SUCCEEDED(errCreate->SetDescription(const_cast<wchar_t*>(err)))
+#define __OLESTR(x) L ## x
+#define _OLESTR(x) __OLESTR(x)
+		&& SUCCEEDED(errCreate->SetSource(_OLESTR(COCLASS_PROGID)))
+		)
+	{
+
+		IErrorInfoPtr errorInfo = errCreate;
+		SetErrorInfo(0, errorInfo);
+	}
+}

Modified: trunk/SDK/BON/Common/ComponentObj.h
==============================================================================
--- trunk/SDK/BON/Common/ComponentObj.h	Wed Sep  7 09:13:24 2011	(r1505)
+++ trunk/SDK/BON/Common/ComponentObj.h	Wed Sep  7 09:55:06 2011	(r1506)
@@ -1,5 +1,4 @@
-#if !defined(AFX_INTERPRETEROBJ_H__1DBDD345_023D_11D2_BBB3_0040051F7117__INCLUDED_)
-#define AFX_INTERPRETEROBJ_H__1DBDD345_023D_11D2_BBB3_0040051F7117__INCLUDED_
+#pragma once
 
 
 #include "ComHelp.h"
@@ -7,6 +6,8 @@
 #include <ComponentConfig.h>
 #include "Exceptions.h"
 #include "MgaUtil.h"
+#include "Core.h"
+#include "Mga.h"
 
 #if defined(BUILDER_OBJECT_NETWORK)
 #else
@@ -335,5 +336,3 @@
 
 //{{AFX_INSERT_LOCATION}}
 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_INTERPRETEROBJ_H__1DBDD345_023D_11D2_BBB3_0040051F7117__INCLUDED_)

Modified: trunk/SDK/BON/Common/GMECOM.H
==============================================================================
--- trunk/SDK/BON/Common/GMECOM.H	Wed Sep  7 09:13:24 2011	(r1505)
+++ trunk/SDK/BON/Common/GMECOM.H	Wed Sep  7 09:55:06 2011	(r1506)
@@ -1,7 +1,8 @@
 #ifndef GMECOM_H
 #define GMECOM_H
 
-#include "ComponentLib.h"
+
+#include "Comdef.h"
 
 #define COM_EQUAL(a, b) (static_cast<IUnknown *>(a) == b ? true : a.IsEqualObject(b))
 
@@ -47,6 +48,16 @@
 		{ CLEANUP; } \
 		return hr; \
 	} \
+	catch(_com_error &e) \
+	{ \
+		{ CLEANUP; } \
+		if (e.Description() != _bstr_t()) \
+			SetErrorInfo(e.Error(), e.Description()); \
+		return e.Error(); \
+	} \
 	return S_OK;
 
+	// Defined in ComHelp.cpp
+	void SetErrorInfo(HRESULT hr, const wchar_t* err);
+
 #endif // GMECOM_H

Modified: trunk/SDK/BON/Wizard/Templates/1033/RawComponent.cpp
==============================================================================
--- trunk/SDK/BON/Wizard/Templates/1033/RawComponent.cpp	Wed Sep  7 09:13:24 2011	(r1505)
+++ trunk/SDK/BON/Wizard/Templates/1033/RawComponent.cpp	Wed Sep  7 09:55:06 2011	(r1506)
@@ -10,6 +10,13 @@
 #include <GMECOM.h>
 #include <Console.h>
 #include "ComponentConfig.h"
+#import "progid:Mga.MgaMetaFolder" no_implementation auto_search no_namespace no_search_namespace
+#import "progid:Mga.MgaFolders" no_implementation auto_search no_namespace no_search_namespace
+#import "progid:Mga.MgaMetaFolder" implementation_only auto_search no_namespace no_search_namespace
+#import "progid:Mga.MgaFolders" implementation_only auto_search no_namespace no_search_namespace
+// Sometimes IntelliSense has a hard time picking up the above lines. Try this:
+//#include "Debug/Mga.tlh"
+
 #include "RawComponent.h"
 
 // this method is called after all the generic initialization is done
@@ -35,28 +42,24 @@
 
 
 // This is the main component method for interpereters and plugins. 
-// May als be used in case of invokeable addons
+// May also be used in case of invokeable addons
 STDMETHODIMP RawComponent::InvokeEx( IMgaProject *project,  IMgaFCO *currentobj,  
 									IMgaFCOs *selectedobjs,  long param) {
 	COMTRY {
-	  if(interactive) {
-		CComBSTR projname;
-		CComBSTR focusname = "<nothing>";
-		CComPtr<IMgaTerritory> terr;
-		COMTHROW(project->CreateTerritory(NULL, &terr));
-		COMTHROW(project->BeginTransaction(terr));
+		_bstr_t focusname = "<nothing>";
+		IMgaTerritoryPtr terr;
+		project->CreateTerritory(NULL, &terr, NULL);
+		project->BeginTransaction(terr, TRANSACTION_GENERAL);
 		try {
-			COMTHROW(project->get_Name(&projname));
-			if(currentobj) COMTHROW(currentobj->get_Name(&focusname));
+			if (currentobj)
+				focusname = currentobj->Name;
 			using namespace GMEConsole;
 			Console::Out::WriteLine("Interpreter started...");
-			AfxMessageBox(_T("RAW Com Component --- Plugin!!!! Sample (project: ") + CString(projname) +
-						_T(", focus: ") + CString(focusname));
-			COMTHROW(project->CommitTransaction());
+			AfxMessageBox(_T("RAW Com Component --- Plugin!!!! Sample (project: ") + project->Name +
+						_T(", focus: ") + focusname);
+			project->CommitTransaction();
 			Console::Out::WriteLine(_T("Interpreter completed..."));
 		}	catch(...) { project->AbortTransaction(); throw; }
-		
-	  } 
 	} COMCATCH(;);
 }
 
@@ -85,16 +88,14 @@
 // these two functions are the main 
 STDMETHODIMP RawComponent::GlobalEvent(globalevent_enum event) { 
 	if(event == GLOBALEVENT_UNDO) {
-		AfxMessageBox(_T("UNDO!!"));
+		AfxMessageBox(_T("Undo));
 	}
 	return S_OK; 
 }
 
 STDMETHODIMP RawComponent::ObjectEvent(IMgaObject * obj, unsigned long eventmask, VARIANT v) {
 	if(eventmask & OBJEVENT_CREATED) {
-		CComBSTR objID;
-		COMTHROW(obj->get_ID(&objID));
-		AfxMessageBox(_T("Object created! ObjID: ") + CString(objID)); 
+		AfxMessageBox(_T("Object created: ObjID=") + obj->ID); 
 	}		
 	return S_OK;
 }


More information about the gme-commit mailing list