Click here to Skip to main content
15,896,269 members
Articles / Mobile Apps

The StateWizard VC++ Add-in and Engine with Source Code

Rate me:
Please Sign up or sign in to vote.
4.73/5 (24 votes)
26 Mar 2009CPOL12 min read 190.9K   2.8K   132  
A cross-platform state-oriented application framework and a ClassWizard-like round-trip UML dynamic modeling/development tool that runs in popular IDEs. Aims at providing concurrent, distributed, and real-time application development tools for Win32/Linux
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently

#pragma once

#ifndef STRICT
#define STRICT
#endif

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER				// Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT		// Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400	// Change this to the appropriate value to target Windows 2000 or later.
#endif						

#ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE			// Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400	// Change this to the appropriate value to target IE 5.0 or later.
#endif

#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS	// some CString constructors will be explicit

// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS




//#define _UNICODE 

#include <afxwin.h>   // MFC core and standard components
#include <afxext.h>   // MFC extensions
#include <afxdisp.h>  // MFC Automation extensions

#include "resource.h"
#include <atlbase.h>
#include <atlcom.h>
#include <atlstr.h>
#include <comutil.h>

#include "..\Common\common.h"
#include "..\Common\HtmlHelp.h"
#include "..\Common\WndUtils.h"
//#include <stdio.h>
#ifdef VS2005
	#pragma comment(lib, "comsuppw.lib")
#else
	#pragma comment(lib, "comsupp.lib")
#endif


#pragma warning( disable : 4278 )
#pragma warning( disable : 4146 )
	//The following #import imports the IDTExtensibility2 interface based on it's LIBID
	#import "libid:AC0714F2-3D04-11D1-AE7D-00A0C90F26F4" version("1.0") lcid("0")  raw_interfaces_only named_guids

	//The following #import imports MSO based on it's LIBID
	//#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" version("2.2") lcid("0") raw_interfaces_only named_guids

	//The following #import imports VCProjectEngine.dll for VS.NET 2003 based on it's LIBID
#ifdef VS2005
	//fbbf3c60-2428-11d7-8bf6-00b0d03daa06
	//#import "C:\Program Files\Microsoft Visual Studio 8\VC\vcpackages\VCProjectEngine.dll" raw_interfaces_only raw_native_types
	#import "libid:fbbf3c60-2428-11d7-8bf6-00b0d03daa06" version("8.0") lcid("0") named_guids
#else
	#import "libid:6194e01d-71a1-419f-85e3-47ba6283dd1d" version("7.0") lcid("0") named_guids
#endif

	using namespace VCProjectEngineLibrary;

#pragma warning( default : 4146 )
#pragma warning( default : 4278 )

#define IfFailGo(x) { hr=(x); if (FAILED(hr)) goto Error; }
#define IfFailGoCheck(x, p) { hr=(x); if (FAILED(hr)) goto Error; if(!p) {hr = E_FAIL; goto Error; } }

#pragma warning( disable : 4278 )
//The following #import imports DTE based on it's LIBID
#ifdef VS2005
	#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0") lcid("0") raw_interfaces_only named_guids
#else
	#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids
#endif


#ifdef _DEBUG
	#import "..\Debug\StateTree\StateTree.tlb" no_namespace raw_interfaces_only
#else
	#import "..\Release\StateTree\StateTree.tlb" no_namespace raw_interfaces_only
#endif
#pragma warning( default : 4278 )

#ifdef VS2005
	class DECLSPEC_UUID("B613C9B3-BC34-4987-9D7A-F30AC2714B7B") StateMachineWizLib;
#else
	class DECLSPEC_UUID("302B47BB-C9BB-42B5-980A-2953AEEBDB8A") StateMachineWizLib;
#endif

using namespace ATL;


#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
#endif

#include <atlbase.h>

#include <iostream>
#include <afxdhtml.h>
#include "DSUtils.h"
using namespace std;

class CAddInModule : public CAtlDllModuleT< CAddInModule >
{
public:
	CAddInModule()
	{
		m_hInstance = NULL;
	}

	DECLARE_LIBID(__uuidof(StateMachineWizLib))

	inline HINSTANCE GetResourceInstance()
	{
		return m_hInstance;
	}

	inline void SetResourceInstance(HINSTANCE hInstance)
	{
		m_hInstance = hInstance;
	}

private:
	HINSTANCE m_hInstance;
};

class CAddInApp : public CWinApp
{
public:
    virtual BOOL InitInstance();
    virtual int ExitInstance();
	DECLARE_MESSAGE_MAP()
protected:
	BOOL m_bRun;
};

extern CAddInApp theApp;
extern CAddInModule _AtlModule;
#ifdef VS2005
	//The following #import imports EnvDTE80 based on its LIBID.
    #import "libid:1A31287A-4D7D-413e-8E32-3B374931BD89" version("8.0") lcid("0") raw_interfaces_only named_guids
	using namespace EnvDTE80;
	extern CComPtr<DTE2> g_pDTE;
#else
	extern CComPtr<EnvDTE::_DTE> g_pDTE;
#endif
extern CComPtr<IDispatch> g_pObjCtrl;
extern DSUtils g_dsUtils;

#define MAX_INT 0xABCDEF


/*
The compiler encountered a function that was marked with deprecated. The function may no longer be supported in a future release. You can turn this warning off with the warning pragma (example below).
C4996 is generated for the line on which the function is declared and for the line on which the function is used.
*/
#ifdef VS2005
#pragma warning(disable : 4996)
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Alex "Question is more important than the answer."

Comments and Discussions