Click here to Skip to main content
13,894,465 members
Click here to Skip to main content

Stats

296.7K 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
// DDListBox.h : Declaration of the CDDListBox
//
// Author : David Shepherd
//			Copyright (c) 2003, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "resource.h"       // main symbols
#include <atlctl.h>

// the list box id
#define IDC_LISTBOX			0x1000

/////////////////////////////////////////////////////////////////////////////
// IDDListBox
[
	object,
	uuid("B04EB1C8-7282-4F49-A055-8219BB77799D"),
	dual,
	helpstring("IDDListBox Interface"),
	pointer_default(unique)
]
__interface IDDListBox : public IDispatch
{
	////////////////////////////////////////
	// enabled
	[propget, requestedit, bindable,
		id(DISPID_ENABLED),
		helpstring("")]
	HRESULT Enabled([out, retval] VARIANT_BOOL* pVal);
	[propput, requestedit, bindable,
		id(DISPID_ENABLED),
		helpstring("")]
	HRESULT Enabled([in] VARIANT_BOOL newVal);
	////////////////////////////////////////
	// background color
	[propget, requestedit, bindable,
		id(DISPID_BACKCOLOR),
		helpstring("")]
	HRESULT BackColor([out, retval] OLE_COLOR* pVal);
	[propput, requestedit, bindable,
		id(DISPID_BACKCOLOR),
		helpstring("")]
	HRESULT BackColor([in] OLE_COLOR newVal);
	////////////////////////////////////////
	// foreground color
	[propget, requestedit, bindable,
		id(DISPID_FORECOLOR),
		helpstring("")]
	HRESULT ForeColor([out, retval] OLE_COLOR* pVal);
	[propput, requestedit, bindable,
		id(DISPID_FORECOLOR),
		helpstring("")]
	HRESULT ForeColor([in] OLE_COLOR newVal);
	////////////////////////////////////////
	// font
	[propget, requestedit, bindable,
		id(DISPID_FONT),
		helpstring("")]
	HRESULT Font([out, retval] IFontDisp** pVal);
	[propput, requestedit, bindable,
		id(DISPID_FONT),
		helpstring("")]
	HRESULT Font([in] IFontDisp* newVal);
	[propputref, requestedit, bindable,
		id(DISPID_FONT),
		helpstring("")]
	HRESULT Font([in] IFontDisp* newVal);
	////////////////////////////////////////
	// sorted alphabetically
	[propget, requestedit, bindable,
		id(DISPID_SORTED),
		helpstring("")]
	HRESULT Sorted([out, retval] VARIANT_BOOL* pVal);
	[propput, requestedit, bindable,
		id(DISPID_SORTED),
		helpstring("")]
	HRESULT Sorted([in] VARIANT_BOOL newVal);
	////////////////////////////////////////
	// redraw
	[propget, requestedit, bindable, nonbrowsable,
		id(DISPID_REDRAW),
		helpstring("")]
	HRESULT Redraw([out, retval] VARIANT_BOOL* pVal);
	[propput, requestedit, bindable, nonbrowsable,
		id(DISPID_REDRAW),
		helpstring("")]
	HRESULT Redraw([in] VARIANT_BOOL newVal);
	////////////////////////////////////////
	// selected item
	[propget, bindable, nonbrowsable,
		id(DISPID_SELECTEDITEM),
		helpstring("")]
	HRESULT SelectedItem([out, retval] BSTR* pVal);
	[propput, bindable, nonbrowsable,
		id(DISPID_SELECTEDITEM),
		helpstring("")]
	HRESULT SelectedItem([in] BSTR newVal);
	////////////////////////////////////////
	// default property
	[propget, nonbrowsable,
		id(DISPID_VALUE),
		helpstring("")]
	HRESULT _Default([out, retval] BSTR* pVal);
	[propput, nonbrowsable,
		id(DISPID_VALUE),
		helpstring("")]
	HRESULT _Default([in] BSTR newVal);
	////////////////////////////////////////
	[id(1), helpstring("")] HRESULT AddItem([in] BSTR Text);
	[id(2), helpstring("")] HRESULT RemoveItem([in] BSTR Text);
	[id(3), helpstring("")] HRESULT Clear();
};

/////////////////////////////////////////////////////////////////////////////
// _IDDListBoxEvents
[
	uuid("C9ED76E3-B5E4-4C91-9A38-50EF82D8B385"),
	dispinterface,
	helpstring("_IDDListBoxEvents Interface")
]
__interface _IDDListBoxEvents
{
	[id(1), helpstring("")] HRESULT Change();
};

/////////////////////////////////////////////////////////////////////////////
// CDDListBox
[
	coclass,
	threading("apartment"),
	vi_progid("DDControlPack.DDListBox"),
	progid("DDControlPack.DDListBox.1"),
	version(1.0),
	uuid("41D3E17F-9F77-420E-8E99-DEF10C436159"),
	helpstring("DDListBox Class"),
	event_source("com"),
	support_error_info(IDDListBox),
	registration_script("control.rgs")
]
class ATL_NO_VTABLE CDDListBox :
	public IDispatchImpl<IDDListBox>,
	public IPersistStreamInitImpl<CDDListBox>,
	public IOleControlImpl<CDDListBox>,
	public IOleObjectImpl<CDDListBox>,
	public IOleInPlaceActiveObjectImpl<CDDListBox>,
	public IViewObjectExImpl<CDDListBox>,
	public IOleInPlaceObjectWindowlessImpl<CDDListBox>,
	public IPersistStorageImpl<CDDListBox>,
	public ISpecifyPropertyPagesImpl<CDDListBox>,
	public IQuickActivateImpl<CDDListBox>,
	public IDataObjectImpl<CDDListBox>,
	public CComControl<CDDListBox>
{
private:
	CContainedWindow m_ctlListBox;

	__event __interface _IDDListBoxEvents;

/////////////////////////////////////////////////////////////////////////////
// properties
	LONG					m_Reserved0;			// reserved
	LONG					m_Reserved1;			// reserved
	VARIANT_BOOL			m_Enabled;				// enabled
	OLE_COLOR				m_BackColor;			// background color
	OLE_COLOR				m_ForeColor;			// foreground color
	CComPtr<IFontDisp>		m_spFontDisp;			// font
	VARIANT_BOOL			m_Sorted;				// sorted alphabetically
	VARIANT_BOOL			m_Redraw;				// redraw
	CComBSTR				m_SelectedItem;			// selected item

/////////////////////////////////////////////////////////////////////////////
// property change validators
	HRESULT OnBackColorChanging(OLE_COLOR newVal);

/////////////////////////////////////////////////////////////////////////////
// property change handlers
	void OnEnabledChanged();
	void OnBackColorChanged();
	void OnForeColorChanged();

/////////////////////////////////////////////////////////////////////////////

	// the background brush
	CBrush m_BackBrush;

	// creates the background brush
	void CreateBackgroundBrush(OLE_COLOR BackColor);

public:
	CDDListBox();

DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct();
	void FinalRelease();

static const TCHAR* GetObjectFriendlyName();

DECLARE_OLEMISC_STATUS(
	OLEMISC_RECOMPOSEONRESIZE |
	OLEMISC_CANTLINKINSIDE |
	OLEMISC_INSIDEOUT |
	OLEMISC_ACTIVATEWHENVISIBLE |
	OLEMISC_SETCLIENTSITEFIRST)

BEGIN_PROP_MAP(CDDListBox)
	PROP_DATA_ENTRY("_reserved0", m_Reserved0, VT_I4)
	PROP_DATA_ENTRY("_reserved1", m_Reserved1, VT_I4)
	PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
	PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
	PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
	PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_NULL)
	PROP_ENTRY("ForeColor", DISPID_FORECOLOR, CLSID_NULL)
	PROP_ENTRY("Font", DISPID_FONT, CLSID_NULL)
	PROP_ENTRY("Sorted", DISPID_SORTED, CLSID_NULL)
	// Example entries
	// PROP_ENTRY("Property Description", dispid, clsid)
	// PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()

BEGIN_MSG_MAP(CDDListBox)
	MESSAGE_HANDLER(WM_CREATE, OnCreate)
	MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
	MESSAGE_HANDLER(WM_CTLCOLORLISTBOX, OnCtlColorListBox)
	MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorListBox)
	COMMAND_HANDLER(IDC_LISTBOX, LBN_SELCHANGE, OnListBoxSelChanged)
	CHAIN_MSG_MAP(CComControl<CDDListBox>)
ALT_MSG_MAP(1)
	// Replace this with message map entries for superclassed ListBox
END_MSG_MAP()
// Handler prototypes:
//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

// message handlers
	BOOL PreTranslateAccelerator(LPMSG pMsg, HRESULT& hRet);
	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnCtlColorListBox(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnListBoxSelChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

// IOleInPlaceObjectWindowless
	STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip);

// IViewObjectEx
	DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)

// IDDListBox
	IMPLEMENT_CUSTOM_BOOL_PROPERTY(Enabled,m_Enabled,DISPID_ENABLED);
	IMPLEMENT_CUSTOM_COLOR_PROPERTY(BackColor,m_BackColor,DISPID_BACKCOLOR);
	IMPLEMENT_CUSTOM_COLOR_PROPERTY(ForeColor,m_ForeColor,DISPID_FORECOLOR);
	STDMETHOD(get_Font)(IFontDisp** pVal);
	STDMETHOD(put_Font)(IFontDisp* newVal);
	STDMETHOD(putref_Font)(IFontDisp* newVal);
	IMPLEMENT_CUSTOM_BOOL_PROPERTY(Sorted,m_Sorted,DISPID_SORTED);
	STDMETHOD(get_Redraw)(VARIANT_BOOL* pVal);
	STDMETHOD(put_Redraw)(VARIANT_BOOL newVal);
	STDMETHOD(get_SelectedItem)(BSTR* pVal);
	STDMETHOD(put_SelectedItem)(BSTR newVal);
	STDMETHOD(AddItem)(BSTR Text);
	STDMETHOD(RemoveItem)(BSTR Text);
	STDMETHOD(Clear)();
	STDMETHOD(get__Default)(BSTR* pVal);
	STDMETHOD(put__Default)(BSTR newVal);
};

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