Click here to Skip to main content
13,894,495 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
// SimpleScriptEditor.h : Declaration of the CSimpleScriptEditor
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#ifndef __SIMPLESCRIPTEDITOR_H_
#define __SIMPLESCRIPTEDITOR_H_

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

#include "DDFormsCP.h"

// the edit control id
#define IDC_EDIT	0x1000

namespace AxSimpleScriptEditor {

/////////////////////////////////////////////////////////////////////////////
// CSimpleScriptEditor
class ATL_NO_VTABLE CSimpleScriptEditor :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IDispatchImpl<ISimpleScriptEditor, &IID_ISimpleScriptEditor, &LIBID_DDFORMSLib, TlbVerMaj, TlbVerMin>,
	public CComControl<CSimpleScriptEditor>,
	public IPersistStreamInitImpl<CSimpleScriptEditor>,
	public IOleControlImpl<CSimpleScriptEditor>,
	public IOleObjectImpl<CSimpleScriptEditor>,
	public IOleInPlaceActiveObjectImpl<CSimpleScriptEditor>,
	public IViewObjectExImpl<CSimpleScriptEditor>,
	public IOleInPlaceObjectWindowlessImpl<CSimpleScriptEditor>,
	public IConnectionPointContainerImpl<CSimpleScriptEditor>,
	public IPersistStorageImpl<CSimpleScriptEditor>,
	public IPersistPropertyBagImpl<CSimpleScriptEditor>,
	public ISpecifyPropertyPagesImpl<CSimpleScriptEditor>,
	public IQuickActivateImpl<CSimpleScriptEditor>,
	public IDataObjectImpl<CSimpleScriptEditor>,
	public IProvideClassInfo2Impl<&CLSID_SimpleScriptEditor, &DIID__ISimpleScriptEditorEvents, &LIBID_DDFORMSLib, TlbVerMaj, TlbVerMin>,
	public IPropertyNotifySinkCP<CSimpleScriptEditor>,
	public CComCoClass<CSimpleScriptEditor, &CLSID_SimpleScriptEditor>,
	public CProxy_ISimpleScriptEditorEvents<CSimpleScriptEditor>,
	public IScriptBuffer,
	public IScriptNavigation,
	public IScriptState
{
private:
	// the edit control
	// this is represented by both a contained window and an edit control wrapper
	CContainedWindow m_ContainedEdit;
	CEdit m_Edit;
	// edit control accelerators
	HACCEL m_hAccel;
	// while this is greater than zero the edit control will be read only
	DWORD m_LockCount;
	// the modified flag
	BOOL m_Modified;

// properties
	// border visible
	VARIANT_BOOL m_BorderVisible;
	// background color
	OLE_COLOR m_BackColor;
	// foreground color
	OLE_COLOR m_ForeColor;
	// font
	CComPtr<IFontDisp> m_spFontDisp;

	// brush used to paint the edit control background
	HBRUSH m_BackBrush;

	// sets the modified flag
	void SetModified(BOOL Modified);
	// creates the edit control background brush
	void CreateBackgroundBrush(OLE_COLOR BackColor);
	// sets the edit control font
	void SetFont(const CComPtr<IFontDisp> &pFontDisp);
	// determines the length of the longest line in the edit control
	DWORD GetLongestLineLength();

public:
	CSimpleScriptEditor();
	virtual ~CSimpleScriptEditor();

DECLARE_REGISTRY_RESOURCEID(IDR_SIMPLESCRIPTEDITOR)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CSimpleScriptEditor)
	COM_INTERFACE_ENTRY(ISimpleScriptEditor)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IViewObjectEx)
	COM_INTERFACE_ENTRY(IViewObject2)
	COM_INTERFACE_ENTRY(IViewObject)
	COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
	COM_INTERFACE_ENTRY(IOleInPlaceObject)
	COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
	COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
	COM_INTERFACE_ENTRY(IOleControl)
	COM_INTERFACE_ENTRY(IOleObject)
	COM_INTERFACE_ENTRY(IPersistStreamInit)
	COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
	COM_INTERFACE_ENTRY(IConnectionPointContainer)
	COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
	COM_INTERFACE_ENTRY(IQuickActivate)
	COM_INTERFACE_ENTRY(IPersistStorage)
	COM_INTERFACE_ENTRY(IPersistPropertyBag)
	COM_INTERFACE_ENTRY(IDataObject)
	COM_INTERFACE_ENTRY(IProvideClassInfo)
	COM_INTERFACE_ENTRY(IProvideClassInfo2)
	COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
	COM_INTERFACE_ENTRY(IScriptBuffer)
	COM_INTERFACE_ENTRY(IScriptNavigation)
	COM_INTERFACE_ENTRY(IScriptState)
END_COM_MAP()

BEGIN_PROP_MAP(CSimpleScriptEditor)
	PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
	PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
	PROP_ENTRY("BorderVisible", DISPID_BORDERVISIBLE, CLSID_PropPageSimpleScriptEditor)
	PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage)
	PROP_ENTRY("ForeColor", DISPID_FORECOLOR, CLSID_StockColorPage)
	PROP_ENTRY("Font", DISPID_FONT, CLSID_StockFontPage)
	// Example entries
	// PROP_ENTRY("Property Description", dispid, clsid)
	// PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()

BEGIN_CONNECTION_POINT_MAP(CSimpleScriptEditor)
	CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
	CONNECTION_POINT_ENTRY(DIID__ISimpleScriptEditorEvents)
END_CONNECTION_POINT_MAP()

BEGIN_MSG_MAP(CSimpleScriptEditor)
	MESSAGE_HANDLER(WM_CREATE, OnCreate)
	MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
	MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorEdit)
	MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorEdit)	// disabled edit control
	MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
	COMMAND_HANDLER(IDC_EDIT, EN_CHANGE, OnEditChanged)
	COMMAND_ID_HANDLER(ID_CUT, OnCut)
	COMMAND_ID_HANDLER(ID_COPY, OnCopy)
	COMMAND_ID_HANDLER(ID_PASTE, OnPaste)
	COMMAND_ID_HANDLER(ID_UNDO, OnUndo)
	CHAIN_MSG_MAP(CComControl<CSimpleScriptEditor>)
ALT_MSG_MAP(1)
	// Replace this with message map entries for superclassed Edit
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);

// base class overrides
	HRESULT FinalConstruct();
	HRESULT OnDraw(ATL_DRAWINFO &di);

// persistance
	STDMETHOD(put_BorderVisible)(VARIANT_BOOL newVal);
	STDMETHOD(get_BorderVisible)(VARIANT_BOOL *pVal);
	STDMETHOD(put_BackColor)(OLE_COLOR newVal);
	STDMETHOD(get_BackColor)(OLE_COLOR *pVal);
	STDMETHOD(put_ForeColor)(OLE_COLOR newVal);
	STDMETHOD(get_ForeColor)(OLE_COLOR *pVal);
	STDMETHOD(putref_Font)(IFontDisp *pFontDisp);
	STDMETHOD(put_Font)(IFontDisp *pFontDisp);
	STDMETHOD(get_Font)(IFontDisp **ppFontDisp);

// IPersistStreamInit
	STDMETHOD(InitNew)();

// IOleControl
	STDMETHOD(OnAmbientPropertyChange)(DISPID dispid);

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

// IViewObjectEx
	DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)

// message handlers
	BOOL PreTranslateAccelerator(LPMSG pMsg, HRESULT& hRet);
	LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnCtlColorEdit(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnEditChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnUndo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

// ISimpleScriptEditor
public:
	STDMETHOD(About)();
	STDMETHOD(Cut)();
	STDMETHOD(Copy)();
	STDMETHOD(Paste)();
	STDMETHOD(Undo)();
	STDMETHOD(RefreshModifiedState)();
	STDMETHOD(get_Modified)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_Modified)(/*[in]*/ VARIANT_BOOL newVal);

// IScriptBuffer
	STDMETHOD(LockExternal)(/*[in]*/ BOOL Lock);
	STDMETHOD(GetLineCount)(/*[out]*/ DWORD *pCount);
	STDMETHOD(FindText)(
		/*[in]*/ DWORD Start,
		/*[in]*/ LPCOLESTR pText,
		/*[out]*/ BOOL *pFound,
		/*[out]*/ DWORD *pLine);
	STDMETHOD(InsertLines)(
		/*[in]*/ DWORD Start,
		/*[in]*/ DWORD Count,
		/*[in, size_is(Count)]*/ LPCOLESTR *pLines);
	STDMETHOD(GetLines)(
		/*[in]*/ DWORD Start,
		/*[in]*/ DWORD Count,
		/*[out, size_is(,Count)]*/ LPOLESTR **ppLines);
	STDMETHOD(DeleteLines)(
		/*[in]*/ DWORD Start,
		/*[in]*/ DWORD Count);
	STDMETHOD(ModifyLines)(
		/*[in]*/ DWORD Start,
		/*[in]*/ DWORD End,
		/*[in]*/ DWORD Count,
		/*[in, size_is(Count)]*/ LPCOLESTR *pLines);

// IScriptNavigation
	STDMETHOD(GoToLine)(/*[in]*/ DWORD Line);

// IScriptState
};

} // namespace AxSimpleScriptEditor

#endif //__SIMPLESCRIPTEDITOR_H_

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