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

Form Designer

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

#if !defined(AFX_PROPERTYINFO_H__C199F141_7624_11D6_BCED_444553540000__INCLUDED_)
#define AFX_PROPERTYINFO_H__C199F141_7624_11D6_BCED_444553540000__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CPredefinedValue
class CPredefinedValue
{
public:
	// name
	std::wstring m_Name;
	// value
	CComVariant m_Value;

	CPredefinedValue();
	virtual ~CPredefinedValue();
};
// CPredefinedValue vector
typedef std::vector<CPredefinedValue> CPredefinedValueVector;

/////////////////////////////////////////////////////////////////////////////
// CPropertyInfo
class CPropertyInfo
{
private:
	// determines the dispatch interface type
	void GetDispatchType(const CComPtr<ITypeInfo> &spTypeInfo);

	// determines the user defined property type
	void GetUserDefinedType(
		const CComPtr<ITypeInfo> &spTypeInfo,const TYPEDESC &TypeDesc);
	// determines the property type
	void GetType(
		const CComPtr<ITypeInfo> &spTypeInfo,const TYPEDESC &TypeDesc);

	// retreives predefined property values
	void GetPredefinedValues(const CComPtr<IDispatch> &spDispatch);

	// sets boolean predefined property values
	void SetPredefinedValuesOnBool();
	// sets enumerator predefined property values
	void SetPredefinedValuesOnEnum(const CComPtr<ITypeInfo> &spTypeInfo);

public:
	// name
	std::wstring m_Name;
	// dispatch id
	DISPID m_DispatchId;
	// variant type
	VARTYPE m_VariantType;
	// type
	enum Type {
		TypeUnknown,	// unknown
		TypeInvalid,	// invalid
		TypeString,		// string
		TypeBool,		// boolean
		TypeEnum,		// enumerator
		TypeColor,		// color
		TypeFont,		// font
		TypePicture,	// picture
	} m_Type;
	// predefined values
	CPredefinedValueVector m_PredefinedValues;
	// value
	CComVariant m_Value;

	CPropertyInfo();
	virtual ~CPropertyInfo();

	// creates property info
	void Create(const CComPtr<IDispatch> &spDispatch,DISPID DispatchId,
		const TYPEDESC &TypeDesc);

	// retreives the property value
	void GetValue(const CComPtr<IDispatch> &spDispatch);

	// returns the property value name
	std::wstring GetValueName() const;
};

#endif // !defined(AFX_PROPERTYINFO_H__C199F141_7624_11D6_BCED_444553540000__INCLUDED_)

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