Click here to Skip to main content
14,106,748 members
Click here to Skip to main content

Stats

299.1K views
79.1K downloads
227 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
// TabNumber.cpp: implementation of the CTabNumber class.
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "TabNumber.h"

// border width
#define BORDER_WIDTH	4
// border height
#define BORDER_HEIGHT	0

/////////////////////////////////////////////////////////////////////////////
// CTabNumber

CTabNumber::CTabNumber()
{
	// initialise everything
	m_BackColor=MAKE_OLE_COLOR(COLOR_HIGHLIGHT);
	m_ForeColor=MAKE_OLE_COLOR(COLOR_HIGHLIGHTTEXT);
	m_TabNumber=0;
}

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

CSize CTabNumber::CalcRequiredWindowSize(DWORD MaxTabNumber)
{
	// get the number of digits in the maximum tab number
	TCHAR Buf[16]=_T("");
	(void)_itot(MaxTabNumber,Buf,10);
	long MaxDigits=_tcslen(Buf);

	// create the widest possible string
	FillMemory(Buf,MaxDigits,_T('8'));

	// calculate the required window size
	CClientDC dc(*this);
	CSize Size(0,0);
	(void)dc.GetTextExtent(Buf,MaxDigits,&Size);

	// add the border width and height
	Size.cx+=2*BORDER_WIDTH;
	Size.cy+=2*BORDER_HEIGHT;
	return Size;
}

void CTabNumber::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 CTabNumber::GetColors(OLE_COLOR &BackColor,OLE_COLOR &ForeColor) const
{
	// return the colors
	BackColor=m_BackColor;
	ForeColor=m_ForeColor;
}

BOOL CTabNumber::Create(const CWindow &Parent,
	const CWindow &AssociatedWindow,DWORD MaxTabNumber)
{
	// check parameters
	ATLASSERT(::IsWindow(Parent));
	ATLASSERT(::IsWindow(AssociatedWindow));

	// save settings
	m_AssociatedWindow=AssociatedWindow;

	// create the tab number
	ATLASSERT(IsWindow()==FALSE);
	if(CWindowImpl<CTabNumber>::Create(Parent,
		CRect(CPoint(0,0),CalcRequiredWindowSize(MaxTabNumber)),
			_T("TabNumber"),WS_CHILD|WS_VISIBLE|WS_DISABLED)==NULL)
	{
		return FALSE;
	}
	AutoPosition();	// auto position
	return TRUE;
}

void CTabNumber::AutoPosition()
{
	// get the associated window rectangle
	CRect Rect(0,0,0,0);
	(void)m_AssociatedWindow.GetWindowRect(Rect);

	// convert to our parents coordinates
	CWindow Parent(GetParent());
	(void)Parent.ScreenToClient(Rect);

	// auto position the tab number
	(void)SetWindowPos(NULL,Rect,SWP_NOZORDER|SWP_NOSIZE);
}

void CTabNumber::SetTabNumber(DWORD TabNumber)
{
	// set the tab number
	if(m_TabNumber!=TabNumber)
	{
		m_TabNumber=TabNumber;
		(void)Invalidate(FALSE);
	}
}

DWORD CTabNumber::GetTabNumber() const
{
	// get the tab number
	return m_TabNumber;
}

LRESULT CTabNumber::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	// get the paint device context
	CPaintDC dc(*this);
	if(dc==NULL)
	{
		return 0;
	}
	// get the client rect
	CRect ClientRect(0,0,0,0);
	if(GetClientRect(ClientRect)==FALSE)
	{
		return 0;
	}
	// set background color
	COLORREF RGBBackColor=RGB(0,0,0);
	if(!SUCCEEDED(OleTranslateColor(m_BackColor,NULL,&RGBBackColor)))
	{
		return 0;
	}
	if(dc.SetBkColor(RGBBackColor)==CLR_INVALID)
	{
		return 0;
	}
	// set foreground color
	COLORREF RGBForeColor=RGB(0,0,0);
	if(!SUCCEEDED(OleTranslateColor(m_ForeColor,NULL,&RGBForeColor)))
	{
		return 0;
	}
	if(dc.SetTextColor(RGBForeColor)==CLR_INVALID)
	{
		return 0;
	}
	// fill in the background
	dc.FillSolidRect(ClientRect,RGBBackColor);
	// convert the tab number to text
	TCHAR Buf[16]=_T("");
	(void)_itot(m_TabNumber,Buf,10);
	// draw the text
	if(dc.DrawText(
		Buf,-1,ClientRect,DT_CENTER|DT_SINGLELINE|DT_VCENTER)==0)
	{
		return 0;
	}
	return 0;
}

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