Click here to Skip to main content
13,897,554 members
Click here to Skip to main content

Stats

296.8K views
78.8K 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.cpp
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Stream.h"

// daedoe signature as hex
#define DAEDOE_SIGNATURE	0x000EEDDA	// 0xDAED0E00
// stream version
// todo : increment this whenever the stream format changes
#define STREAM_VERSION		3
// stream header guid
// {5570A1E1-279A-11d6-B6A6-F2A9931D1E45}
DEFINE_GUID(GUID_STREAM_HEADER,
0x5570a1e1, 0x279a, 0x11d6, 0xb6, 0xa6, 0xf2, 0xa9, 0x93, 0x1d, 0x1e, 0x45);
// stream footer guid
// {5CDF6741-279A-11d6-B6A6-F2A9931D1E45}
DEFINE_GUID(GUID_STREAM_FOOTER,
0x5cdf6741, 0x279a, 0x11d6, 0xb6, 0xa6, 0xf2, 0xa9, 0x93, 0x1d, 0x1e, 0x45);

/////////////////////////////////////////////////////////////////////////////
// CStreamHeader

CStreamHeader::CStreamHeader()
{
	// initialise everything
	m_DaeDoe=DAEDOE_SIGNATURE;
	m_Signature=GUID_STREAM_HEADER;
	m_Version=STREAM_VERSION;
	m_Reserved0=0;
	m_Reserved1=0;
}

void CStreamHeader::ReadFromStream(const CComPtr<IStream> &spStream)
{
	// clear the header
	// this is required to correctly check for validity
	ZeroMemory(this,sizeof(*this));
	// read the header from the passed stream
	::ReadFromStream(spStream,*this);
	if(IsValid()==FALSE)
	{
		throw std::exception();
	}
}

void CStreamHeader::WriteToStream(const CComPtr<IStream> &spStream)
{
	// write the header to the passed stream
	::WriteToStream(spStream,*this);
}

BOOL CStreamHeader::IsValid()
{
	// determine if the header is valid
	if(m_DaeDoe!=DAEDOE_SIGNATURE)
	{
		return FALSE;	// invalid
	}
	if(m_Signature!=GUID_STREAM_HEADER)
	{
		return FALSE;	// invalid
	}
	return TRUE;		// valid
}

/////////////////////////////////////////////////////////////////////////////
// CStreamFooter

CStreamFooter::CStreamFooter()
{
	// initialise everything
	m_Signature=GUID_STREAM_FOOTER;
	m_Reserved0=0;
	m_Reserved1=0;
}

void CStreamFooter::ReadFromStream(const CComPtr<IStream> &spStream)
{
	// clear the footer
	// this is required to correctly check for validity
	ZeroMemory(this,sizeof(*this));
	// read the footer from the passed stream
	::ReadFromStream(spStream,*this);
	if(IsValid()==FALSE)
	{
		throw std::exception();
	}
}

void CStreamFooter::WriteToStream(const CComPtr<IStream> &spStream)
{
	// write the footer to the passed stream
	::WriteToStream(spStream,*this);
}

BOOL CStreamFooter::IsValid()
{
	// determine if the footer is valid
	return (m_Signature==GUID_STREAM_FOOTER) ? TRUE : FALSE;
}

/////////////////////////////////////////////////////////////////////////////
// CStreamFormBlock

CStreamFormBlock::CStreamFormBlock()
{
	// initialise everything
	m_Size=CSize(0,0);
}

void CStreamFormBlock::ReadFromStream(
	const CComPtr<IStream> &spStream,DWORD StreamVersion)
{
	// read the form block from the passed stream
	::ReadFromStream(spStream,m_Name);
	::ReadFromStream(spStream,m_Size);
	::ReadFromStream(spStream,m_BackColor);
	::ReadFromStream(spStream,m_ForeColor);
}

void CStreamFormBlock::WriteToStream(const CComPtr<IStream> &spStream)
{
	// write the form block to the passed stream
	::WriteToStream(spStream,m_Name);
	::WriteToStream(spStream,m_Size);
	::WriteToStream(spStream,m_BackColor);
	::WriteToStream(spStream,m_ForeColor);
}

/////////////////////////////////////////////////////////////////////////////
// CStreamItemListHeader

CStreamItemListHeader::CStreamItemListHeader()
{
	// initialise everything
	m_Count=0;
	m_BoundingRect=CRect(0,0,0,0);
}

void CStreamItemListHeader::ReadFromStream(
	const CComPtr<IStream> &spStream,DWORD StreamVersion)
{
	// read the item list header from the passed stream
	::ReadFromStream(spStream,*this);
}

void CStreamItemListHeader::WriteToStream(const CComPtr<IStream> &spStream)
{
	// write the item list header to the passed stream
	::WriteToStream(spStream,*this);
}

/////////////////////////////////////////////////////////////////////////////
// CStreamItemBlock

CStreamItemBlock::CStreamItemBlock()
{
	// initialise everything
	m_Rect=CRect(0,0,0,0);
	m_ClassId=CLSID_NULL;
	m_HasPersistantData=FALSE;
}

void CStreamItemBlock::ReadFromStream(
	const CComPtr<IStream> &spStream,DWORD StreamVersion)
{
	// read the item block from the passed stream
	::ReadFromStream(spStream,m_Name);
	if(StreamVersion > 1)
	{
		::ReadFromStream(spStream,m_Tag);
	}
	::ReadFromStream(spStream,m_Rect);
	::ReadFromStream(spStream,m_ClassId);
	::ReadFromStream(spStream,m_HasPersistantData);
}

void CStreamItemBlock::WriteToStream(const CComPtr<IStream> &spStream)
{
	// write the item block to the passed stream
	::WriteToStream(spStream,m_Name);
	::WriteToStream(spStream,m_Tag);
	::WriteToStream(spStream,m_Rect);
	::WriteToStream(spStream,m_ClassId);
	::WriteToStream(spStream,m_HasPersistantData);
}

/////////////////////////////////////////////////////////////////////////////
// CStreamItemPersistantDataHeader

CStreamItemPersistantDataHeader::CStreamItemPersistantDataHeader()
{
	// initialise everything
	m_Length.QuadPart=0;
}

void CStreamItemPersistantDataHeader::ReadFromStream(
	const CComPtr<IStream> &spStream,DWORD StreamVersion)
{
	// read the item persistant data header from the passed stream
	::ReadFromStream(spStream,*this);
}

void CStreamItemPersistantDataHeader::WriteToStream(const CComPtr<IStream> &spStream)
{
	// write the item persistant data header to the passed stream
	::WriteToStream(spStream,*this);
}

/////////////////////////////////////////////////////////////////////////////
// CStreamScriptHeader

CStreamScriptHeader::CStreamScriptHeader()
{
	// initialise everything
	m_LineCount=0;
}

void CStreamScriptHeader::ReadFromStream(
	const CComPtr<IStream> &spStream,DWORD StreamVersion)
{
	// read the script header from the passed stream
	::ReadFromStream(spStream,*this);
}

void CStreamScriptHeader::WriteToStream(const CComPtr<IStream> &spStream)
{
	// write the script header to the passed stream
	::WriteToStream(spStream,*this);
}

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

// reads a std::wstring from the passed stream
template <>
void ReadFromStream(
	const CComPtr<IStream> &spStream,std::wstring &Data)
{
	// length
	DWORD Length=0;
	ReadFromStream(spStream,Length);
	// short data
	const DWORD MAX_LENGTH=1024;
	if(Length < MAX_LENGTH)
	{
		WCHAR Buf[MAX_LENGTH]=L"";
		ReadArrayFromStream(spStream,Buf,Length);
		// null terminate and assign
		Buf[Length]=L'\0';
		Data=Buf;
	}
	// long data
	else
	{
		std::auto_ptr<WCHAR> Buf(new WCHAR [Length+1]);
		ReadArrayFromStream(spStream,Buf.get(),Length);
		// null terminate and assign
		Buf.get()[Length]=L'\0';
		Data=Buf.get();
	}
}

// writes a std::wstring to the passed stream
template <>
void WriteToStream(
	const CComPtr<IStream> &spStream,const std::wstring &Data)
{
	// length
	DWORD Length=Data.length();
	WriteToStream(spStream,Length);
	// data
	WriteArrayToStream(spStream,Data.data(),Data.length());
}

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
Web01 | 2.8.190306.1 | Last Updated 1 Aug 2009
Article Copyright 2005 by DaveShep
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid