Click here to Skip to main content
15,891,431 members
Articles / Desktop Programming / WTL

Form Designer

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

#pragma once

/////////////////////////////////////////////////////////////////////////////
// _CopyInterfaceFromAdaptInterface
template <class T>
class _CopyInterfaceFromAdaptInterface
{
public:
	static HRESULT copy(T **p1,CAdapt<CComPtr<T> > *p2)
	{
		// check parameters
		if(p1==NULL)
		{
			return E_POINTER;
		}
		if(p2==NULL)
		{
			return E_POINTER;
		}
		// copy the interface
		*p1=CComPtr<T>(*p2).Detach();
		return S_OK;
	}
	static void init(T **p)
	{
		// initialise
		ATLASSERT(p!=NULL);
		*p=NULL;
	}
	static void destroy(T **p)
	{
		// destroy
		ATLASSERT(p!=NULL);
		CComPtr<T>().Attach(*p);
	}
};

/////////////////////////////////////////////////////////////////////////////
// _CopyVariantFromAdaptIUnknown
class _CopyVariantFromAdaptIUnknown
{
public:
	static HRESULT copy(VARIANT *p1,CAdapt<CComPtr<IUnknown> > *p2);
	static void init(VARIANT *p);
	static void destroy(VARIANT *p);
};

/////////////////////////////////////////////////////////////////////////////
// _CopyVariantFromAdaptIDispatch
class _CopyVariantFromAdaptIDispatch
{
public:
	static HRESULT copy(VARIANT *p1,CAdapt<CComPtr<IDispatch> > *p2);
	static void init(VARIANT *p);
	static void destroy(VARIANT *p);
};

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