Click here to Skip to main content
13,898,354 members
Click here to Skip to main content

Stats

296.9K 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
// ValueEditor.cpp: implementation of the CValueEditor class.
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ValueEditor.h"

/////////////////////////////////////////////////////////////////////////////
// CValueEditor

CValueEditor::CValueEditor() : m_Edit(this,VE_MSG_MAP_EDIT)
{
	// initialise everything
	m_RunMessageLoop=TRUE;
}

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

BOOL CValueEditor::EditValue(const CWindow &Parent,const CRect &Rect)
{
TRY
	USES_CONVERSION;

	// reinitialise everything to allow object reuse
	m_RunMessageLoop=TRUE;
	// create the value editor window (invisible)
	if(Create(Parent,CRect(Rect),_T(""),WS_POPUP|WS_CLIPCHILDREN)==NULL)
	{
		throw std::exception();
	}
	// set the edit box text
	if(m_Edit.SetWindowText(W2CT(m_Value.c_str()))==FALSE)
	{
		throw std::exception();
	}
	// give focus to the edit box
	if(m_Edit.SetFocus()==NULL)
	{
		throw std::exception();
	}
	// show the value editor
	(void)ShowWindow(SW_SHOW);
	// run the message loop
	while(m_RunMessageLoop)
	{
		// get the next message
		// todo : check for the WM_QUIT message
		MSG Message;
		(void)GetMessage(&Message,NULL,0,0);
		// process the message
		(void)TranslateMessage(&Message);
		(void)DispatchMessage(&Message);
	}
CATCH_ALL
	// clean up
	if(IsWindow())
	{
		(void)DestroyWindow();
	}
	return Caught ? FALSE : TRUE;	// return TRUE on success
}

LRESULT CValueEditor::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
TRY
	// create the edit box
	if(m_Edit.Create(*this,CRect(0,0,0,0),_T(""),
		// standard window styles
		WS_CHILD|WS_VISIBLE|
		// edit box styles
		ES_AUTOHSCROLL,
		// extended window styles
		0,
		// id
		VE_IDC_EDIT)==NULL)
	{
		throw std::exception();
	}
	// set the edit box font
	CFontHandle hFont=(HFONT)GetStockObject(DEFAULT_GUI_FONT);
	if(hFont==NULL)
	{
		throw std::exception();
	}
	m_Edit.SetFont(hFont);
CATCH_ALL
	return Caught ? -1 : 0;	// fail creation on error
}

LRESULT CValueEditor::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
TRY
	// get the client rect
	CRect ClientRect(0,0,0,0);
	if(GetClientRect(ClientRect)==FALSE)
	{
		throw std::exception();
	}
	// size the edit box to fill the entire client area
	if(m_Edit.SetWindowPos(NULL,ClientRect,SWP_NOZORDER)==FALSE)
	{
		throw std::exception();
	}
CATCH_ALL
	return 0;
}

LRESULT CValueEditor::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
TRY
	// if the window is being deactivated
	if(LOWORD(wParam)==WA_INACTIVE)
	{
		// get the window being activated
		CWindow ActiveWindow=(HWND)lParam;
		// if the value editor is no longer active
		if(ActiveWindow!=*this and ActiveWindow!=m_Edit)
		{
			// hide the value editor immediately
			(void)ShowWindow(SW_HIDE);
			// shut down
			m_RunMessageLoop=FALSE;
		}
	}
CATCH_ALL
	return 0;
}

LRESULT CValueEditor::OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
TRY
	// get the window receiving focus
	CWindow FocusWindow=(HWND)wParam;
	// if the value editor no longer has the focus
	if(FocusWindow!=*this and FocusWindow!=m_Edit)
	{
		// hide the value editor immediately
		(void)ShowWindow(SW_HIDE);
		// shut down
		m_RunMessageLoop=FALSE;
	}
CATCH_ALL
	return 0;
}

LRESULT CValueEditor::OnChangeEdit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
TRY
	// get the edit box text
	CComBSTR Text;
	if(m_Edit.GetWindowText(&Text)==FALSE)
	{
		throw std::exception();
	}
	// update the value
	m_Value=BSTR2W(Text);
CATCH_ALL
	return 0;
}

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