Click here to Skip to main content
15,881,600 members
Articles / Desktop Programming / WTL

WTL Helper

Rate me:
Please Sign up or sign in to vote.
4.92/5 (116 votes)
27 Aug 200713 min read 695.4K   8.8K   190  
Add-in for Microsoft VC++.NET 2003 that helps to insert message handlers for WTL.
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Sergey Solozhentsev
// Author: 	Sergey Solozhentsev e-mail: salos@mail.ru
// Product:	WTL Helper
// File:      	InsertPoint.h
// Created:	17.01.2005 9:58
// 
//   Using this software in commercial applications requires an author
// permission. The permission will be granted to everyone excluding the cases
// when someone simply tries to resell the code.
//   This file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this notice
// and the authors name is included.
//   This file is provided "as is" with no expressed or implied warranty. The
// author accepts no liability if it causes any damage to you or your computer
// whatsoever.
//
////////////////////////////////////////////////////////////////////////////////

#pragma	  once

#include "VSElements.h"
#include "HandlerManager.h"

//����������� ������ �������, ���������� � ������ �������, ����������� ���������� EnvDTE
#define INSERT_STEP_ENVDTE		1
//����������� ���������� �������, ������� ������� �������, �������� map � ��������� 
//�������
#define INSERT_STEP_GLOBAL		2
//����������� map entry
#define INSERT_STEP_MAP_ENTRY	3

#define INSERT_POINT_UNKNOWN				0
#define INSERT_POINT_FUNC					1
#define INSERT_POINT_VAR					2
#define INSERT_POINT_MAP					3
#define INSERT_POINT_ALT_MAP				4
#define INSERT_POINT_MAP_ENTRY				5
#define INSERT_POINT_HANDLER				6
#define INSERT_POINT_DDX					7
#define INSERT_POINT_SPEC_FUNC				9
#define INSERT_POINT_INCLUDE				10
#define INSERT_POINT_DDXSUPPORT				11
#define INSERT_POINT_REPLACE_END_MSG_MAP	12

struct InsertionPoint
{
	VSElement* pElement;
	int Type;
	virtual HRESULT Insert(VSClass* pClass, int Step) = NULL;
	InsertionPoint(int iType = INSERT_POINT_UNKNOWN) : Type(iType)
	{
	}
	virtual ~InsertionPoint(){};
};

struct InsertPointFunc : public InsertionPoint
{
	CString Body;
	HRESULT Insert(VSClass* pClass, int Step);
	InsertPointFunc(int iType = INSERT_POINT_FUNC);
};

struct InsertPointVariable : public InsertionPoint
{
	HRESULT Insert(VSClass* pClass, int Step);
	InsertPointVariable(int iType = INSERT_POINT_VAR);
};

struct InsertPointMap : public InsertionPoint
{
	HRESULT Insert(VSClass* pClass, int Step);
	InsertPointMap(int iType = INSERT_POINT_MAP);
};

struct InsertPointAltMap : public InsertionPoint
{
	VSMessageMap* pParentMap;
	CString DefineName;
	HRESULT Insert(VSClass* pClass, int Step);
	InsertPointAltMap(int iType = INSERT_POINT_ALT_MAP);
};

struct InsertPointMapEntry : public InsertionPoint
{
	VSMap* pParentMap;
	HRESULT Insert(VSClass* pClass, int Step);
	InsertPointMapEntry(int iType = INSERT_POINT_MAP_ENTRY);
};

struct InsertPointHandler : public InsertPointMapEntry
{
	VSFunction* pFunction;
	CString Body;
	HRESULT Insert(VSClass* pClass, int Step);
	InsertPointHandler(int iType = INSERT_POINT_HANDLER);
};

struct InsertPointDDX : public InsertPointMapEntry
{
	VSVariable* pVariable;
	CString Initializer;
	HRESULT Insert(VSClass* pClass, int Step);
	InsertPointDDX(int iType = INSERT_POINT_DDX);
private:
	HRESULT AddInitializer(VSFunction* pFunc);
};

struct InsertSpecFunction : public InsertPointFunc
{
	VSBase* pBase;
	CString OnCreateBody;
	CString OnDestroyBody;
	MessageStruct* pMesCreate;
	MessageStruct* pMesDestroy;
	bool bInitDialog;
	HRESULT Insert(VSClass* pClass, int Step);
	InsertSpecFunction(int iType = INSERT_POINT_SPEC_FUNC);
};

struct InsertInclude : public InsertionPoint
{
	HRESULT Insert(VSClass* pClass, int Step);
	EnvDTE::ProjectItemPtr pProjectFile;
	_variant_t Pos;
	CString AdditionalMacro;
	InsertInclude(int iType = INSERT_POINT_INCLUDE);
	~InsertInclude();
private:
	EnvDTE::CodeElementPtr pInclude;
};

struct InsertPointDDXSupport : public InsertionPoint
{
	bool bUseFloat;
	VSBase* pBase;
	HRESULT Insert(VSClass* pClass, int Step);
	InsertPointDDXSupport(int Type = INSERT_POINT_DDXSUPPORT);
	~InsertPointDDXSupport();
private:
	EnvDTE::EditPointPtr pFloatPoint;
};

struct InsertPointReplaceEndMap : public InsertionPoint
{
	InsertPointReplaceEndMap();
	HRESULT Insert(VSClass* pClass, int Step);
};

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Belarus Belarus
I am a software developer for 3 years.

Comments and Discussions