Click here to Skip to main content
13,772,614 members
Click here to Skip to main content

Stats

291.3K views
78.3K downloads
226 bookmarked
Posted 30 Dec 2005
Licenced CPOL

Form Designer

, 1 Aug 2009
Component for adding scriptable forms capabilities to an application.
MFCDemo.exe
CSDemo
App.ico
Bmp
ABottom.bmp
About.bmp
ALeft.bmp
ARight.bmp
ATop.bmp
AX.bmp
BringFront.bmp
Button.bmp
Center.bmp
Check.bmp
Combo.bmp
Copy.bmp
Cut.bmp
Delete.bmp
Down.bmp
Edit.bmp
Frame.bmp
Grid.bmp
GridSettings.bmp
HCenter.bmp
HScroll.bmp
HSL.bmp
HSpace.bmp
HSS.bmp
Left.bmp
List.bmp
New.bmp
Open.bmp
Paste.bmp
Picture.bmp
Preview.bmp
Progress.bmp
Props.bmp
Radio.bmp
Rectangle.bmp
Redo.bmp
Right.bmp
Save.bmp
SelAll.bmp
SelNone.bmp
SendBack.bmp
SL.bmp
Slider.bmp
Spin.bmp
SS.bmp
Tab.bmp
Text.bmp
Undo.bmp
Up.bmp
Validate.bmp
VCenter.bmp
VScroll.bmp
VSL.bmp
VSpace.bmp
VSS.bmp
Wand.bmp
CSDemo.suo
DaeDoe.bmp
MFCDemo
MFCDemo.dsp
MFCDemo.odl
MFCDemo.reg
res
DaeDoe.bmp
MFCDemo.ico
MFCDemoDoc.ico
Toolbar1.bmp
Toolbar2.bmp
Toolbar3.bmp
Wand.bmp
VBDemo
Bmp
ABottom.bmp
About.bmp
ALeft.bmp
ARight.bmp
ATop.bmp
AX.bmp
BringFront.bmp
Button.bmp
Center.bmp
Check.bmp
Combo.bmp
Copy.bmp
Cut.bmp
Delete.bmp
Down.bmp
Edit.bmp
Frame.bmp
Grid.bmp
GridSettings.bmp
HCenter.bmp
HScroll.bmp
HSL.bmp
HSpace.bmp
HSS.bmp
Left.bmp
List.bmp
New.bmp
Open.bmp
Paste.bmp
Picture.bmp
Preview.bmp
Progress.bmp
Props.bmp
Radio.bmp
Rectangle.bmp
Redo.bmp
Right.bmp
Save.bmp
SelAll.bmp
SelNone.bmp
SendBack.bmp
SL.bmp
Slider.bmp
Spin.bmp
SS.bmp
Tab.bmp
Text.bmp
Undo.bmp
Up.bmp
Validate.bmp
VCenter.bmp
VScroll.bmp
VSL.bmp
VSpace.bmp
VSS.bmp
Wand.bmp
DaeDoe.bmp
VBDemo.vbp
DDForms.chm
DDForms
Archive
FormEditorItems.rgs
vssver.scc
Constants.scr
DaeDoe.bmp
DDForms.def
DDForms.vcproj
DDForms.vcproj.vspscc
EventSinkPassThrough.rgs
FormEditor.bmp
FormEditor.rgs
FormEditorItemCollection.rgs
FormEditorItemDetails.rgs
FormViewer.bmp
FormViewer.rgs
FormViewerItemCollection.rgs
FormViewerItemDetails.rgs
mssccprj.scc
PropPageExtended.rgs
PropPageFormEditor.rgs
PropPageFormViewer.rgs
PropPageSimpleScriptEditor.rgs
SimpleScriptEditor.bmp
SimpleScriptEditor.rgs
vssver.scc
DDFormsTools
CodeMaxDriver
CodeMaxDriver.rgs
CodeMaxDriver.vcproj
CodeMaxDriver.vcproj.vspscc
CodeMaxDriverps.def
CodeMaxDriverPS.vcproj
CodeMaxDriverPS.vcproj.vspscc
mssccprj.scc
vssver.scc
CodeSenseDriver
CodeSenseDriver.rgs
CodeSenseDriver.vcproj
CodeSenseDriver.vcproj.vspscc
CodeSenseDriverps.def
CodeSenseDriverPS.vcproj
CodeSenseDriverPS.vcproj.vspscc
mssccprj.scc
vssver.scc
DDPropPageAll
DDPropPageAll.def
DDPropPageAll.vcproj
DDPropPageAll.vcproj.vspscc
mssccprj.scc
PropPageAll.rgs
vssver.scc
DDUnlock
DDUnlock.vcproj
DDUnlock.vcproj.vspscc
mssccprj.scc
vssver.scc
DDControlPack
DDButton.bmp
DDCheckBox.bmp
DDComboBox.bmp
DDControlPack.rgs
DDControlPack.vcproj
DDControlPack.vcproj.vspscc
DDHorzScrollBar.bmp
DDLabel.bmp
DDListBox.bmp
DDPicture.bmp
DDRadioButton.bmp
DDTextBox.bmp
DDVertScrollBar.bmp
mssccprj.scc
vssver.scc
Redistributables
Ansi
CodeMaxDriver.dll
CodeSenseDriver.dll
DDControlPack.dll
DDForms.dll
DDPropPageAll.dll
Unicode
CodeMaxDriver.dll
CodeSenseDriver.dll
DDControlPack.dll
DDForms.dll
DDPropPageAll.dll
// AutoResources.h
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_AUTORESOURCES_H__E60244A3_2E09_11D6_B6A6_C8D760853445__INCLUDED_)
#define AFX_AUTORESOURCES_H__E60244A3_2E09_11D6_B6A6_C8D760853445__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CAutoClipboard
class CAutoClipboard
{
private:
	// this will be set TRUE if we opened the clipboard
	BOOL m_Open;
public:
	CAutoClipboard(HWND hWndOwner=NULL)
	{
		// open the clipboard
		m_Open=OpenClipboard(hWndOwner);
		if(m_Open==FALSE)
		{
			throw std::exception();
		}
	}
	~CAutoClipboard()
	{
		// close the clipboard
		if(m_Open)
		{
			(void)CloseClipboard();
		}
	}
// todo : make this work correctly accross multiple instances
NOCOPY(CAutoClipboard);
};

/////////////////////////////////////////////////////////////////////////////
// CAutoDCState
class CAutoDCState
{
public:
	// this will be set TRUE if the device context state was saved
	BOOL m_Saved;
	// the device context handle
	HDC m_hdc;
public:
	CAutoDCState(HDC hdc) : m_hdc(hdc)
	{
		// save the device context state
		m_Saved=SaveDC(m_hdc);
		if(m_Saved==FALSE)
		{
			throw std::exception();
		}
	}
	~CAutoDCState()
	{
		// restore the device context state
		if(m_Saved)
		{
			(void)RestoreDC(m_hdc,-1);
		}
	}
// todo : make this work correctly accross multiple instances
NOCOPY(CAutoDCState);
};

/////////////////////////////////////////////////////////////////////////////
// CAutoTypeAttrPtr
class CAutoTypeAttrPtr
{
private:
	// type attributes pointer
	TYPEATTR *m_pTypeAttr;
	// owner
	CComPtr<ITypeInfo> m_spOwner;
public:
	CAutoTypeAttrPtr() :
		m_pTypeAttr(NULL)
	{}
	CAutoTypeAttrPtr(const CComPtr<ITypeInfo> &spTypeInfo) :
		m_pTypeAttr(NULL)
	{
		// get the type attributes
		Get(spTypeInfo);
	}
	~CAutoTypeAttrPtr()
	{
		// release the type attributes
		if(m_pTypeAttr!=NULL and m_spOwner!=NULL)
		{
			(void)m_spOwner->ReleaseTypeAttr(m_pTypeAttr);
		}
	}
	void Get(const CComPtr<ITypeInfo> &spTypeInfo)
	{
		// check parameters
		if(spTypeInfo==NULL)
		{
			throw std::exception();
		}
		// release the type attributes
		if(m_pTypeAttr!=NULL and m_spOwner!=NULL)
		{
			(void)m_spOwner->ReleaseTypeAttr(m_pTypeAttr);
			m_pTypeAttr=NULL;
		}
		// get the type attributes
		if(!SUCCEEDED(spTypeInfo->GetTypeAttr(&m_pTypeAttr)))
		{
			throw std::exception();
		}
		// save the owner
		m_spOwner=spTypeInfo;
	}
	TYPEATTR *operator->() const
	{
		// return the type attributes pointer
		return m_pTypeAttr;
	}
	operator TYPEATTR *() const
	{
		// return the type attributes pointer
		return m_pTypeAttr;
	}
// todo : make this work correctly accross multiple instances
NOCOPY(CAutoTypeAttrPtr);
};

/////////////////////////////////////////////////////////////////////////////
// CAutoFuncDescPtr
class CAutoFuncDescPtr
{
private:
	// function description pointer
	FUNCDESC *m_pFuncDesc;
	// owner
	CComPtr<ITypeInfo> m_spOwner;
public:
	CAutoFuncDescPtr() :
		m_pFuncDesc(NULL)
	{}
	CAutoFuncDescPtr(long Ix,const CComPtr<ITypeInfo> &spTypeInfo) :
		m_pFuncDesc(NULL)
	{
		// get the function description
		Get(Ix,spTypeInfo);
	}
	~CAutoFuncDescPtr()
	{
		// release the function description
		if(m_pFuncDesc!=NULL and m_spOwner!=NULL)
		{
			(void)m_spOwner->ReleaseFuncDesc(m_pFuncDesc);
		}
	}
	void Get(long Ix,const CComPtr<ITypeInfo> &spTypeInfo)
	{
		// check parameters
		if(spTypeInfo==NULL)
		{
			throw std::exception();
		}
		// release the function description
		if(m_pFuncDesc!=NULL and m_spOwner!=NULL)
		{
			(void)m_spOwner->ReleaseFuncDesc(m_pFuncDesc);
			m_pFuncDesc=NULL;
		}
		// get the function description
		if(!SUCCEEDED(spTypeInfo->GetFuncDesc(Ix,&m_pFuncDesc)))
		{
			throw std::exception();
		}
		// save the owner
		m_spOwner=spTypeInfo;
	}
	FUNCDESC *operator->() const
	{
		// return the function description pointer
		return m_pFuncDesc;
	}
	operator FUNCDESC *() const
	{
		// return the function description pointer
		return m_pFuncDesc;
	}
// todo : make this work correctly accross multiple instances
NOCOPY(CAutoFuncDescPtr);
};

/////////////////////////////////////////////////////////////////////////////
// CAutoVarDescPtr
class CAutoVarDescPtr
{
private:
	// variable description pointer
	VARDESC *m_pVarDesc;
	// owner
	CComPtr<ITypeInfo> m_spOwner;
public:
	CAutoVarDescPtr() :
		m_pVarDesc(NULL)
	{}
	CAutoVarDescPtr(long Ix,const CComPtr<ITypeInfo> &spTypeInfo) :
		m_pVarDesc(NULL)
	{
		// get the variable description
		Get(Ix,spTypeInfo);
	}
	~CAutoVarDescPtr()
	{
		// release the variable description
		if(m_pVarDesc!=NULL and m_spOwner!=NULL)
		{
			(void)m_spOwner->ReleaseVarDesc(m_pVarDesc);
		}
	}
	void Get(long Ix,const CComPtr<ITypeInfo> &spTypeInfo)
	{
		// check parameters
		if(spTypeInfo==NULL)
		{
			throw std::exception();
		}
		// release the variable description
		if(m_pVarDesc!=NULL and m_spOwner!=NULL)
		{
			(void)m_spOwner->ReleaseVarDesc(m_pVarDesc);
			m_pVarDesc=NULL;
		}
		// get the variable description
		if(!SUCCEEDED(spTypeInfo->GetVarDesc(Ix,&m_pVarDesc)))
		{
			throw std::exception();
		}
		// save the owner
		m_spOwner=spTypeInfo;
	}
	VARDESC *operator->() const
	{
		// return the variable description pointer
		return m_pVarDesc;
	}
	operator VARDESC *() const
	{
		// return the variable description pointer
		return m_pVarDesc;
	}
// todo : make this work correctly accross multiple instances
NOCOPY(CAutoVarDescPtr);
};

/////////////////////////////////////////////////////////////////////////////
// CAutoGlobalMemory
class CAutoGlobalMemory
{
private:
	// this will be set TRUE if we own the global memory
	BOOL m_Owns;
	// the global memory handle
	HGLOBAL m_hGlobal;
public:
	explicit CAutoGlobalMemory(HGLOBAL hGlobal=NULL) :
		m_Owns((hGlobal==NULL) ? FALSE : TRUE),
		m_hGlobal(hGlobal)
	{}
	CAutoGlobalMemory(CAutoGlobalMemory &Obj) :
		m_Owns(Obj.m_Owns),
		m_hGlobal(Obj.Release())
	{}
	~CAutoGlobalMemory()
	{
		// free the global memory
		if(m_Owns)
		{
			(void)GlobalFree(m_hGlobal);
		}
	}
	const CAutoGlobalMemory &operator=(CAutoGlobalMemory &Obj)
	{
		// check for self assignment
		if(this==&Obj)
		{
			return *this;
		}
		// assign from a different global memory handle
		if(m_hGlobal!=Obj.Get())
		{
			if(m_Owns)
			{
				(void)GlobalFree(m_hGlobal);
			}
			m_Owns=Obj.m_Owns;
		}
		// assign from the same global memory handle
		else if(Obj.m_Owns)
		{
			m_Owns=TRUE;
		}
		return m_hGlobal=Obj.Release(), *this;
	}
	HGLOBAL Release()
	{
		// release ownership
		m_Owns=FALSE;
		// return the global memory handle
		return m_hGlobal;
	}
	HGLOBAL Get() const
	{
		// return the global memory handle
		return m_hGlobal;
	}
	operator HGLOBAL() const
	{
		// return the global memory handle
		return m_hGlobal;
	}
};

/////////////////////////////////////////////////////////////////////////////
// CAutoCoTaskMem
template <class T>
class CAutoCoTaskMem
{
private:
	// this will be set TRUE if we own the memory
	BOOL m_Owns;
	// the memory pointer
	T *m_pMem;
public:
	explicit CAutoCoTaskMem(T *pMem=NULL) :
		m_Owns((pMem==NULL) ? FALSE : TRUE),
		m_pMem(pMem)
	{}
	CAutoCoTaskMem(CAutoCoTaskMem<T> &Obj) :
		m_Owns(Obj.m_Owns),
		m_pMem(Obj.Release())
	{}
	~CAutoCoTaskMem()
	{
		// free the memory
		if(m_Owns and
			// check the pointer too since ownership may have
			// been set via operator&
			m_pMem!=NULL)
		{
			CoTaskMemFree(m_pMem);
		}
	}
	const CAutoCoTaskMem &operator=(CAutoCoTaskMem<T> &Obj)
	{
		// check for self assignment
		if(this==Obj.GetThis())
		{
			return *this;
		}
		// assign from a different memory pointer
		if(m_pMem!=Obj.Get())
		{
			if(m_Owns and
				// check the pointer too since ownership may have
				// been set via operator&
				m_pMem!=NULL)
			{
				CoTaskMemFree(m_pMem);
			}
			m_Owns=Obj.m_Owns;
		}
		// assign from the same memory pointer
		else if(Obj.m_Owns)
		{
			m_Owns=TRUE;
		}
		return m_pMem=Obj.Release(), *this;
	}
	const CAutoCoTaskMem *GetThis()
	{
		// return the this pointer
		// this is required since operator& is overloaded
		return this;
	}
	T *Release()
	{
		// release ownership
		m_Owns=FALSE;
		// return the memory pointer
		return m_pMem;
	}
	T *Get() const
	{
		// return the memory pointer
		return m_pMem;
	}
	operator T *() const
	{
		// return the memory pointer
		return m_pMem;
	}
	T **operator&()
	{
		// assume com assignment
		ATLASSERT(m_Owns==FALSE);
		m_Owns=TRUE;
		// return a pointer to the memory pointer
		return &m_pMem;
	}
};

/////////////////////////////////////////////////////////////////////////////
// CAutoSafeArrayPtr
class CAutoSafeArrayPtr
{
private:
	// this will be set TRUE if we own the safe array pointer
	BOOL m_Owns;
	// the safe array pointer
	SAFEARRAY *m_pSafeArray;
public:
	explicit CAutoSafeArrayPtr(SAFEARRAY *pSafeArray=NULL) :
		m_Owns((pSafeArray==NULL) ? FALSE : TRUE),
		m_pSafeArray(pSafeArray)
	{}
	CAutoSafeArrayPtr(CAutoSafeArrayPtr &Obj) :
		m_Owns(Obj.m_Owns),
		m_pSafeArray(Obj.Release())
	{}
	~CAutoSafeArrayPtr()
	{
		// destroy the safe array
		if(m_Owns)
		{
			(void)SafeArrayDestroy(m_pSafeArray);
		}
	}
	const CAutoSafeArrayPtr &operator=(CAutoSafeArrayPtr &Obj)
	{
		// check for self assignment
		if(this==&Obj)
		{
			return *this;
		}
		// assign from a different safe array pointer
		if(m_pSafeArray!=Obj.Get())
		{
			if(m_Owns)
			{
				(void)SafeArrayDestroy(m_pSafeArray);
			}
			m_Owns=Obj.m_Owns;
		}
		// assign from the same safe array pointer
		else if(Obj.m_Owns)
		{
			m_Owns=TRUE;
		}
		return m_pSafeArray=Obj.Release(), *this;
	}
	SAFEARRAY *Release()
	{
		// release ownership
		m_Owns=FALSE;
		// return the safe array pointer
		return m_pSafeArray;
	}
	SAFEARRAY *Get() const
	{
		// return the safe array pointer
		return m_pSafeArray;
	}
	operator SAFEARRAY *() const
	{
		// return the safe array pointer
		return m_pSafeArray;
	}
};

/////////////////////////////////////////////////////////////////////////////
// CAutoWindowHandle
class CAutoWindowHandle
{
private:
	// this will be set TRUE if we own the window handle
	BOOL m_Owns;
	// the window handle
	HWND m_hWnd;
public:
	explicit CAutoWindowHandle(HWND hWnd=NULL) :
		m_Owns((hWnd==NULL) ? FALSE : TRUE),
		m_hWnd(hWnd)
	{}
	CAutoWindowHandle(CAutoWindowHandle &Obj) :
		m_Owns(Obj.m_Owns),
		m_hWnd(Obj.Release())
	{}
	~CAutoWindowHandle()
	{
		// destroy the window
		if(m_Owns and IsWindow(m_hWnd))
		{
			(void)DestroyWindow(m_hWnd);
		}
	}
	const CAutoWindowHandle &operator=(CAutoWindowHandle &Obj)
	{
		// check for self assignment
		if(this==&Obj)
		{
			return *this;
		}
		// assign from a different window handle
		if(m_hWnd!=Obj.Get())
		{
			if(m_Owns and IsWindow(m_hWnd))
			{
				(void)DestroyWindow(m_hWnd);
			}
			m_Owns=Obj.m_Owns;
		}
		// assign from the same window handle
		else if(Obj.m_Owns)
		{
			m_Owns=TRUE;
		}
		return m_hWnd=Obj.Release(), *this;
	}
	HWND Release()
	{
		// release ownership
		m_Owns=FALSE;
		// return the window handle
		return m_hWnd;
	}
	HWND Get() const
	{
		// return the window handle
		return m_hWnd;
	}
	operator HWND() const
	{
		// return the window handle
		return m_hWnd;
	}
};

#endif // !defined(AFX_AUTORESOURCES_H__E60244A3_2E09_11D6_B6A6_C8D760853445__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)

Share

About the Author

DaveShep
Web Developer
United Kingdom United Kingdom
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.181119.1 | Last Updated 1 Aug 2009
Article Copyright 2005 by DaveShep
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid