Click here to Skip to main content
13,769,395 members
Click here to Skip to main content

Stats

291.2K views
78.2K 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
// EditableForm.cpp: implementation of the CEditableForm class.
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "EditableForm.h"

// default form width and height
#define DEFAULT_WIDTH			250
#define DEFAULT_HEIGHT			200
// default grid width and height
#define DEFAULT_GRID_WIDTH		8
#define DEFAULT_GRID_HEIGHT		8

/////////////////////////////////////////////////////////////////////////////
// CEditableForm

CEditableForm::CEditableForm()
{
	// initialise everything
	m_Width=DEFAULT_WIDTH;
	m_Height=DEFAULT_HEIGHT;
	m_BackColor=MAKE_OLE_COLOR(COLOR_BTNFACE);
	m_ForeColor=MAKE_OLE_COLOR(COLOR_BTNTEXT);
	m_GridWidth=DEFAULT_GRID_WIDTH;
	m_GridHeight=DEFAULT_GRID_HEIGHT;
	m_ShowGrid=TRUE;
}

CEditableForm::~CEditableForm()
{
	// clean up
}

void CEditableForm::SetDimensions(long Width,long Height)
{
	// if the dimensions are changing a redraw will be required
	if(m_Width!=Width or m_Height!=Height)
	{
		if(IsWindow())
		{
			(void)SetWindowPos(
				NULL,0,0,Width,Height,SWP_NOZORDER|SWP_NOMOVE);
		}
	}
	// set the dimensions
	m_Width=Width;
	m_Height=Height;
}

void CEditableForm::GetDimensions(long &Width,long &Height) const
{
	// return the dimensions
	Width=m_Width;
	Height=m_Height;
}

void CEditableForm::SetColors(OLE_COLOR BackColor,OLE_COLOR ForeColor)
{
	// if the colors are changing a redraw will be required
	if(m_BackColor!=BackColor or m_ForeColor!=ForeColor)
	{
		if(IsWindow())
		{
			(void)Invalidate(FALSE);
		}
	}
	// set the colors
	m_BackColor=BackColor;
	m_ForeColor=ForeColor;
}

void CEditableForm::GetColors(OLE_COLOR &BackColor,OLE_COLOR &ForeColor) const
{
	// return the colors
	BackColor=m_BackColor;
	ForeColor=m_ForeColor;
}

void CEditableForm::SetGrid(long Width,long Height)
{
	// check parameters
	ATLASSERT(Width > 0);
	ATLASSERT(Height > 0);
	// if either the width or height are changing a redraw will be required
	if(m_GridWidth!=Width or m_GridHeight!=Height)
	{
		if(IsWindow())
		{
			(void)Invalidate(FALSE);
		}
	}
	// set the grid width and height
	m_GridWidth=Width;
	m_GridHeight=Height;
}

void CEditableForm::GetGrid(long &Width,long &Height) const
{
	// return the grid width and height
	Width=m_GridWidth;
	Height=m_GridHeight;
}

void CEditableForm::ShowGrid(BOOL Show/*=TRUE*/)
{
	// if the visibility is changing a redraw will be required
	if(m_ShowGrid!=Show)
	{
		if(IsWindow())
		{
			(void)Invalidate(FALSE);
		}
	}
	// set the grid visibility
	m_ShowGrid=Show;
}

BOOL CEditableForm::IsGridVisible() const
{
	// return the grid visibility
	return m_ShowGrid;
}

LRESULT CEditableForm::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	// get the paint device context
	CPaintDC dc(*this);
	if(dc==NULL)
	{
		return 0;
	}
	// get the clip box
	CRect ClipBox(0,0,0,0);
	dc.GetClipBox(ClipBox);
	// background color
	COLORREF RGBBackColor=RGB(0,0,0);
	if(!SUCCEEDED(OleTranslateColor(m_BackColor,NULL,&RGBBackColor)))
	{
		return 0;
	}
	// foreground color
	COLORREF RGBForeColor=RGB(0,0,0);
	if(!SUCCEEDED(OleTranslateColor(m_ForeColor,NULL,&RGBForeColor)))
	{
		return 0;
	}
	// fill in the background
	dc.FillSolidRect(ClipBox,RGBBackColor);
	// draw the grid
	if(m_ShowGrid)
	{
		// start x pixel
		long xStart=m_GridWidth*(ClipBox.left/m_GridWidth);
		// start y pixel
		long yStart=m_GridHeight*(ClipBox.top/m_GridHeight);
		// draw left->right and top->bottom for a more natural update
		for(long y=yStart; y<ClipBox.bottom; y+=m_GridHeight)
		{
			for(long x=xStart; x<ClipBox.right; x+=m_GridWidth)
			{
				(void)dc.SetPixel(x,y,RGBForeColor);
			}
		}
	}
	return 0;
}

LRESULT CEditableForm::OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	// to prevent flicker do not erase the background
	return TRUE;
}

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