Click here to Skip to main content
15,886,110 members
Articles / Desktop Programming / WTL

Form Designer

26 Jul 2021CPOL24 min read 351.2K   82.5K   230  
Component for adding scriptable forms capabilities to an application.
// Class2.cpp : implementation file
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MFCDemo.h"
#include "Class2.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CClass2

IMPLEMENT_DYNCREATE(CClass2, CCmdTarget)

CClass2::CClass2()
{
	EnableAutomation();

	EnableConnections();

	EnableTypeLib();
	
	// To keep the application running as long as an OLE automation 
	//	object is active, the constructor calls AfxOleLockApp.
	
	AfxOleLockApp();
}

CClass2::~CClass2()
{
	// To terminate the application when all objects created with
	// 	with OLE automation, the destructor calls AfxOleUnlockApp.
	
	AfxOleUnlockApp();
}

void CClass2::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.

	CCmdTarget::OnFinalRelease();
}

BEGIN_MESSAGE_MAP(CClass2, CCmdTarget)
	//{{AFX_MSG_MAP(CClass2)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CClass2, CCmdTarget)
	//{{AFX_DISPATCH_MAP(CClass2)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_IClass2 to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {0F002770-2DF3-4738-91DE-62240AC7F803}
static const IID IID_IClass2 =
{ 0xf002770, 0x2df3, 0x4738, { 0x91, 0xde, 0x62, 0x24, 0xa, 0xc7, 0xf8, 0x3 } };

BEGIN_INTERFACE_MAP(CClass2, CCmdTarget)
	INTERFACE_PART(CClass2, IID_IClass2, Dispatch)
	INTERFACE_PART(CClass2, IID_IConnectionPointContainer, ConnPtContainer)
END_INTERFACE_MAP()

BEGIN_CONNECTION_MAP(CClass2, CCmdTarget)
	CONNECTION_PART(CClass2, DIID_IClass2Events, Class2CP)
END_CONNECTION_MAP()

// {A0E35494-5C2F-48CD-9F40-61C8F13EEFC3}
IMPLEMENT_OLECREATE(CClass2, "MFCDemo.Class2", 0xa0e35494, 0x5c2f, 0x48cd, 0x9f, 0x40, 0x61, 0xc8, 0xf1, 0x3e, 0xef, 0xc3)

IMPLEMENT_OLETYPELIB(CClass2, LIBID_MFCDemo, 1, 0)

/////////////////////////////////////////////////////////////////////////////
// CClass2 message handlers

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
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions