Click here to Skip to main content
14,035,006 members
Click here to Skip to main content

Stats

298.2K views
79K 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
// Stream.h
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_STREAM_H__5A2B7AC1_27AE_11D6_B6A6_F2A9931D1E45__INCLUDED_)
#define AFX_STREAM_H__5A2B7AC1_27AE_11D6_B6A6_F2A9931D1E45__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CStreamHeader
class CStreamHeader
{
public:
	// signature
	DWORD m_DaeDoe;
	// signature
	GUID m_Signature;
	// version
	DWORD m_Version;
	// reserved 0
	DWORD m_Reserved0;
	// reserved 1
	DWORD m_Reserved1;

	CStreamHeader();

	// reads the header from the passed stream
	void ReadFromStream(const CComPtr<IStream> &spStream);
	// writes the header to the passed stream
	void WriteToStream(const CComPtr<IStream> &spStream);
	// returns TRUE if the header is valid
	BOOL IsValid();
};

/////////////////////////////////////////////////////////////////////////////
// CStreamFooter
class CStreamFooter
{
public:
	// signature
	GUID m_Signature;
	// reserved 0
	DWORD m_Reserved0;
	// reserved 1
	DWORD m_Reserved1;

	CStreamFooter();

	// reads the footer from the passed stream
	void ReadFromStream(const CComPtr<IStream> &spStream);
	// writes the footer to the passed stream
	void WriteToStream(const CComPtr<IStream> &spStream);
	// returns TRUE if the footer is valid
	BOOL IsValid();
};

/////////////////////////////////////////////////////////////////////////////
// CStreamFormBlock
class CStreamFormBlock
{
public:
	// name
	std::wstring m_Name;
	// size
	CSize m_Size;
	// background color
	OLE_COLOR m_BackColor;
	// foreground color
	OLE_COLOR m_ForeColor;

	CStreamFormBlock();

	// reads the form block from the passed stream
	void ReadFromStream(
		const CComPtr<IStream> &spStream,DWORD StreamVersion);
	// writes the form block to the passed stream
	void WriteToStream(const CComPtr<IStream> &spStream);
};

/////////////////////////////////////////////////////////////////////////////
// CStreamItemListHeader
class CStreamItemListHeader
{
public:
	// count
	DWORD m_Count;
	// bounding rectangle
	CRect m_BoundingRect;

	CStreamItemListHeader();

	// reads the item list header from the passed stream
	void ReadFromStream(
		const CComPtr<IStream> &spStream,DWORD StreamVersion);
	// writes the item list header to the passed stream
	void WriteToStream(const CComPtr<IStream> &spStream);
};

/////////////////////////////////////////////////////////////////////////////
// CStreamItemBlock
class CStreamItemBlock
{
public:
	// name
	std::wstring m_Name;
	// tag
	std::wstring m_Tag;
	// position and size
	CRect m_Rect;
	// class id
	CLSID m_ClassId;
	// this will be set TRUE if the item has persistant data
	BOOL m_HasPersistantData;

	CStreamItemBlock();

	// reads the item block from the passed stream
	void ReadFromStream(
		const CComPtr<IStream> &spStream,DWORD StreamVersion);
	// writes the item block to the passed stream
	void WriteToStream(const CComPtr<IStream> &spStream);
};

/////////////////////////////////////////////////////////////////////////////
// CStreamItemPersistantDataHeader
class CStreamItemPersistantDataHeader
{
public:
	// length
	ULARGE_INTEGER m_Length;

	CStreamItemPersistantDataHeader();

	// reads the item persistant data header from the passed stream
	void ReadFromStream(
		const CComPtr<IStream> &spStream,DWORD StreamVersion);
	// writes the item persistant data header to the passed stream
	void WriteToStream(const CComPtr<IStream> &spStream);
};

/////////////////////////////////////////////////////////////////////////////
// CStreamScriptHeader
class CStreamScriptHeader
{
public:
	// line count
	DWORD m_LineCount;

	CStreamScriptHeader();

	// reads the script header from the passed stream
	void ReadFromStream(
		const CComPtr<IStream> &spStream,DWORD StreamVersion);
	// writes the script header to the passed stream
	void WriteToStream(const CComPtr<IStream> &spStream);
};

/////////////////////////////////////////////////////////////////////////////
// stream formats
//
// version 1
//		CStreamHeader
//			reserved0=zero
//			reserved1=zero
//		CStreamFormBlock (a)
//		CStreamItemListHeader
//		for all items
//			CStreamItemBlock
//			item persistant data
//		CStreamScriptHeader (a)(b)
//		script (a)(b)
//		CStreamFooter
//			reserved0=zero
//			reserved1=zero
//
//	(a) not present in the clipboard stream
//	(b) not present in the undo/redo stream
//
// version 2
//		added m_Tag to CStreamItemBlock
//
// version 3
//		CStreamHeader
//			reserved0=zero
//			reserved1=zero
//		CStreamFormBlock (a)
//		CStreamItemListHeader
//		for all items
//			CStreamItemBlock
//			CStreamItemPersistantDataHeader (new)
//			item persistant data
//		CStreamScriptHeader (a)(b)
//		script (a)(b)
//		CStreamFooter
//			reserved0=zero
//			reserved1=zero
//
//	(a) not present in the clipboard stream
//	(b) not present in the undo/redo stream
//
// todo : add additional stream version formats here

/////////////////////////////////////////////////////////////////////////////
// Stream helpers

// reads a simple data type from the passed stream
template <class T>
void ReadFromStream(const CComPtr<IStream> &spStream,T &Data)
{
	if(spStream==NULL)
	{
		throw std::exception();
	}
	DWORD BytesRead=0;
	if(!SUCCEEDED(spStream->Read(&Data,sizeof(T),&BytesRead)))
	{
		throw std::exception();
	}
	if(BytesRead!=sizeof(T))
	{
		throw std::exception();
	}
}

// writes a simple data type to the passed stream
template <class T>
void WriteToStream(const CComPtr<IStream> &spStream,const T &Data)
{
	if(spStream==NULL)
	{
		throw std::exception();
	}
	DWORD BytesWritten=0;
	if(!SUCCEEDED(spStream->Write(&Data,sizeof(T),&BytesWritten)))
	{
		throw std::exception();
	}
	if(BytesWritten!=sizeof(T))
	{
		throw std::exception();
	}
}

// reads a simple data type array from the passed stream
template <class T>
void ReadArrayFromStream(
	const CComPtr<IStream> &spStream,T *pArray,DWORD Length)
{
	if(spStream==NULL)
	{
		throw std::exception();
	}
	if(pArray==NULL)
	{
		throw std::exception();
	}
	DWORD BytesRead=0;
	if(!SUCCEEDED(spStream->Read(pArray,Length*sizeof(T),&BytesRead)))
	{
		throw std::exception();
	}
	if(BytesRead!=Length*sizeof(T))
	{
		throw std::exception();
	}
}

// writes a simple data type array to the passed stream
template <class T>
void WriteArrayToStream(
	const CComPtr<IStream> &spStream,const T *pArray,DWORD Length)
{
	if(spStream==NULL)
	{
		throw std::exception();
	}
	if(pArray==NULL)
	{
		throw std::exception();
	}
	DWORD BytesWritten=0;
	if(!SUCCEEDED(spStream->Write(pArray,Length*sizeof(T),&BytesWritten)))
	{
		throw std::exception();
	}
	if(BytesWritten!=Length*sizeof(T))
	{
		throw std::exception();
	}
}

// reads a simple data type sized array from the passed stream
template <class T>
void ReadSizedArrayFromStream(
	const CComPtr<IStream> &spStream,T *pArray)
{
	// length
	DWORD Length=0;
	ReadFromStream(spStream,Length);
	// data
	ReadArrayFromStream(spStream,pArray,Length);
}

// writes a simple data type sized array to the passed stream
template <class T>
void WriteSizedArrayToStream(
	const CComPtr<IStream> &spStream,const T *pArray,DWORD Length)
{
	// length
	WriteToStream(spStream,Length);
	// data
	WriteArrayToStream(spStream,pArray,Length);
}

// reads a std::wstring from the passed stream
template <>
void ReadFromStream(
	const CComPtr<IStream> &spStream,std::wstring &Data);
// writes a std::wstring to the passed stream
template <>
void WriteToStream(
	const CComPtr<IStream> &spStream,const std::wstring &Data);

#endif // !defined(AFX_STREAM_H__5A2B7AC1_27AE_11D6_B6A6_F2A9931D1E45__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
Web02 | 2.8.190424.1 | Last Updated 1 Aug 2009
Article Copyright 2005 by DaveShep
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid