Click here to Skip to main content
14,134,933 members
Click here to Skip to main content

Stats

299.2K 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
// FormEditor.h : Declaration of the CFormEditor
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#ifndef __FORMEDITOR_H_
#define __FORMEDITOR_H_

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

#include "DDAxWindow.h"
#include "DragFrame.h"
#include "EditableForm.h"
#include "TabNumber.h"
#include "UndoRedoStorage.h"

#include "DDFormsCP.h"

// show the context menu
// wparam : unused
// lparam : unused
// return : nothing
#define WM_CONTEXTMENU_INDIRECT			(WM_APP+0)
// get extended property page data
// wparam : unused
// lparam : CExtendedPropPageData*
// return : TRUE on success
#define WM_GET_EXTENDED_PROPPAGE_DATA	(WM_APP+1)
// set extended property page data
// wparam : unused
// lparam : CExtendedPropPageData*
// return : TRUE on success
#define WM_SET_EXTENDED_PROPPAGE_DATA	(WM_APP+2)

namespace AxFormEditor {

/////////////////////////////////////////////////////////////////////////////
// CExtendedPropPageData
class CExtendedPropPageData
{
public:
	// name
	std::wstring m_Name;

	CExtendedPropPageData();
	virtual ~CExtendedPropPageData();
};

/////////////////////////////////////////////////////////////////////////////
// CItemInfo
class CItemInfo
{
private:
	// disallow standalone instantiation
	CItemInfo();
	CItemInfo(const CItemInfo &ItemInfo);
	// disallow external destruction
	virtual ~CItemInfo();
	// these private members ensure that an object of this class
	// can only be created using CreateObject() and can only be
	// destroyed using DeleteObject()

	// disallow assignment
	const CItemInfo &operator=(const CItemInfo &ItemInfo);
	// this works in conjunction with the other private members
	// to ensure that there is only ever a single instance of
	// this class per item

public:
	// creates a new object
	static CItemInfo *CreateObject();
	// deletes an existing object
	static void DeleteObject(const CItemInfo *pItemInfo);

	// name
	std::wstring m_Name;
	// tag
	std::wstring m_Tag;
	// host window
	CDDAxWindow m_HostWindow;
	// drag frame
	CDragFrame m_DragFrame;
	// tab number
	CTabNumber m_TabNumber;
	// last move or size drag rect
	CRect m_LastDragRect;
	// todo : add additional item information here as required
};
// CItemInfo pointer list
typedef std::list<CItemInfo *> CItemInfoPtrList;
// CItemInfo pointer vector
typedef std::vector<CItemInfo *> CItemInfoPtrVector;
// CAutoItemInfoPtr
#include "AutoItemInfoPtr.h"

/////////////////////////////////////////////////////////////////////////////
// CEventInfo
class CEventInfo
{
public:
	// source name
	std::wstring m_SourceName;
	// event name
	std::wstring m_EventName;
	// parameter names
	std::wstring m_ParameterNames;

	CEventInfo();
	virtual ~CEventInfo();
};

/////////////////////////////////////////////////////////////////////////////
// CFormEditorState
class CFormEditorState
{
public:
	// this will be set TRUE if the editor is busy
	BOOL m_Busy;
	// this will be set TRUE if the form is modified
	BOOL m_Modified;
	// this will be set TRUE if the clipboard format is available
	BOOL m_CanPaste;
	// this will be set TRUE if the undo storage is not empty
	BOOL m_CanUndo;
	// this will be set TRUE if the redo storage is not empty
	BOOL m_CanRedo;
	// the number of items on the form
	long m_ItemCount;
	// the number of items selected
	long m_SelectedItemCount;

	CFormEditorState();
	virtual ~CFormEditorState();

	BOOL operator==(const CFormEditorState &Obj) const;
	BOOL operator!=(const CFormEditorState &Obj) const;
};

/////////////////////////////////////////////////////////////////////////////
// type definitions

// maps an object name to an IDispatch interface
typedef std::map<std::wstring,CComPtr<IDispatch> > CObjectNameToIDispatchMap;
// maps a menu item id to a CEventInfo
typedef std::map<DWORD,CEventInfo> CMenuItemIdToEventInfoMap;
// contains a set of available menu item id's
typedef std::set<DWORD> CAvailableMenuItemIdSet;

/////////////////////////////////////////////////////////////////////////////
// CFormEditor

// window traits
typedef CWinTraits<
	// standard styles
	WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|
	// clipping
	WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
	// extended styles
	WS_EX_CONTROLPARENT|WS_EX_CLIENTEDGE> CFormEditorWinTraits;
// base class
typedef CWindowImpl<
	class CFormEditor,CWindow,CFormEditorWinTraits> CFormEditorBase;
// editor CComControl
typedef CComControl<CFormEditor,CFormEditorBase> CFormEditorComControl;
// all these typedefs are required to make CHAIN_MSG_MAP compile

class ATL_NO_VTABLE CFormEditor :
	public CComObjectRootEx<CComSingleThreadModel>,
	public IDispatchImpl<IFormEditor2, &IID_IFormEditor2, &LIBID_DDFORMSLib, TlbVerMaj, TlbVerMin>,
	public CFormEditorComControl,
	public IPersistStreamInitImpl<CFormEditor>,
	public IOleControlImpl<CFormEditor>,
	public IOleObjectImpl<CFormEditor>,
	public IOleInPlaceActiveObjectImpl<CFormEditor>,
	public IViewObjectExImpl<CFormEditor>,
	public IOleInPlaceObjectWindowlessImpl<CFormEditor>,
	public IConnectionPointContainerImpl<CFormEditor>,
	public IPersistStorageImpl<CFormEditor>,
	public IPersistPropertyBagImpl<CFormEditor>,
	public ISpecifyPropertyPagesImpl<CFormEditor>,
	public IQuickActivateImpl<CFormEditor>,
	public IDataObjectImpl<CFormEditor>,
	public IProvideClassInfo2Impl<&CLSID_FormEditor, &DIID__IFormEditorEvents, &LIBID_DDFORMSLib, TlbVerMaj, TlbVerMin>,
	public IPropertyNotifySinkCP<CFormEditor>,
	public CComCoClass<CFormEditor, &CLSID_FormEditor>,
	public CProxy_IFormEditorEvents<CFormEditor>,
	public CDragFrameNotifySink
{
private:
	// the script
	CComPtr<IScript> m_spScript;

	// the form
	CEditableForm m_Form;
	// the form name
	std::wstring m_FormName;
	// the form drag frame
	CDragFrame m_FormDragFrame;
	// the form tab number
	CTabNumber m_FormTabNumber;
	// the last form drag rect
	CRect m_LastFormDragRect;
	// list of items in the form (sorted by zorder)
	CItemInfoPtrList m_ItemInfoPtrList;
	// the window after which all items will be placed
	CWindow m_ItemRootWindow;

	// this will be set TRUE if the selection box is active
	BOOL m_SelectionBoxActive;
	// the selection box anchor position
	CPoint m_SelectionBoxAnchorPos;
	// the last selection box drag rect
	CRect m_LastSelectionBoxDragRect;

	// the custom clipboard format id
	DWORD m_ClipboardFormatId;

	// undo storage
	CUndoRedoStorage m_UndoStorage;
	// redo storage
	CUndoRedoStorage m_RedoStorage;

	// this will be set TRUE if the editor is in tab ordering mode
	BOOL m_TabOrderingModeActive;
	// the next tab number to assign to an item
	DWORD m_NextTabNumber;

	// this will be set TRUE if the editor is busy
	// this can happen for example during an item move or size
	BOOL m_Busy;
	// this will be set TRUE if the form is modified
	BOOL m_Modified;
	// this will be set TRUE if the clipboard format is available
	BOOL m_CanPaste;

	// exposed objects
	CObjectNameToIDispatchMap m_ExposedObjects;

	// this will be set TRUE if the editor is in locked mode
	BOOL m_LockedModeActive;

// properties
	// border visible
	VARIANT_BOOL m_BorderVisible;
	// background color
	OLE_COLOR m_BackColor;
	// default form width
	long m_DefaultFormWidth;
	// default form height
	long m_DefaultFormHeight;
	// default form background color
	OLE_COLOR m_DefaultFormBackColor;
	// default form foreground color
	OLE_COLOR m_DefaultFormForeColor;

	// determines if run mode is active
	BOOL InRunMode();
	// determines if design mode is active
	BOOL InDesignMode();

	// sets the form dimensions
	void SetFormDimensions(long Width,long Height);
	// sets the form colors
	void SetFormColors(OLE_COLOR BackColor,OLE_COLOR ForeColor);

	// determines which item is located at the passed position
	CItemInfo *HitTest(const CPoint &Pos);

	// selects the form
	void SelectForm();
	// unselects the form
	void UnselectForm();
	// determines if the form is selected
	BOOL IsFormSelected();
	// selects an item
	void SelectItem(CItemInfo &ItemInfo);
	// selects all items contained in the passed rectangle
	void SelectAllItemsInRect(const CRect &Rect);
	// selects the passed items
	void SelectItems(const CItemInfoPtrList &ItemInfoPtrList);
	// selects all items
	void SelectAllItems();
	// unselects an item
	void UnselectItem(CItemInfo &ItemInfo);
	// unselects the passed items
	void UnselectItems(const CItemInfoPtrList &ItemInfoPtrList);
	// unselects all items
	void UnselectAllItems();
	// determines if an item is selected
	BOOL IsItemSelected(CItemInfo &ItemInfo);
	// returns a list of selected items
	CItemInfoPtrList GetSelectedItems();
	// returns the number of selected items
	DWORD GetSelectedItemCount();

	// hides all drag frames
	void HideAllDragFrames();
	// restores and repositions all drag frames
	void RestoreAndRepositionAllDragFrames();
	// hides all tab numbers
	void HideAllTabNumbers();
	// restores and repositions all tab numbers
	void RestoreAndRepositionAllTabNumbers();
	// hides all drag frames and tab numbers
	void HideAllDragFramesAndTabNumbers();
	// restores and repositions all drag frames and tab numbers
	void RestoreAndRepositionAllDragFramesAndTabNumbers();

	// returns an item rect reletive to the form
	CRect GetItemRect(CItemInfo &ItemInfo);
	// returns the rectangle which encapsulates the passed items
	CRect GetBoundingRectForItems(const CItemInfoPtrList &ItemInfoPtrList);
	// returns the rectangle which encapsulates all selected items
	CRect GetBoundingRectForSelectedItems();
	// returns the rectangle which encapsulates all items
	CRect GetBoundingRectForAllItems();
	// forces the source rectangle to fit into the destination rectangle
	CRect ForceRectIntoRect(const CRect &Destination,const CRect &Source);

	// converts client position coordinates to form coordinates
	CPoint ClientPosToFormPos(const CPoint &Pos);
	// converts client rectangle coordinates to form coordinates
	CRect ClientRectToFormRect(const CRect &Rect);
	// snaps the passed position to the current gird settings
	CPoint SnapPosToGrid(const CPoint &Pos);
	// snaps the passed rectangle to the current grid settings
	CRect SnapRectToGrid(const CRect &Rect);

	// inserts an item by class id
	CItemInfo &InsertItem(const CLSID &ClassId,const CRect &Rect);
	// inserts an item by prog id
	CItemInfo &InsertItem(const std::wstring &ProgId,const CRect &Rect);
	// deletes an item
	void DeleteItem(CItemInfo &ItemInfo);
	// deletes all selected items
	void DeleteSelectedItems();
	// deletes all items
	void DeleteAllItems();

	// gets the position of an item (including the tab number)
	void GetItemPosition(
		CItemInfo &ItemInfo,CRect &Rect,long &TabNumber);
	// sets the position of an item (including the tab number)
	void SetItemPosition(
		CItemInfo &ItemInfo,const CRect &Rect,long TabNumber);

	// cuts selected items to the clipboard
	void CutSelectedItemsToClipboard();
	// copies selected items to the clipboard
	void CopySelectedItemsToClipboard();
	// pastes items from the clipboard
	CItemInfoPtrList PasteItemsFromClipboard();

	// saves the current form into the undo storage
	void UpdateUndoStorage(BOOL PreserveRedoStorage=FALSE);
	// saves the current form into the redo storage
	void UpdateRedoStorage();
	// undoes the last change
	void UndoLastChange();
	// redoes the last undo
	void RedoLastUndo();
	// clears the undo storage
	void ClearUndoStorage();
	// clears the redo storage
	void ClearRedoStorage();
	// clears the undo and redo storage
	void ClearUndoAndRedoStorage();

	// switches the editor into tab ordering mode
	void BeginSetTabOrder();
	// switches the editor back from tab ordering mode
	void EndSetTabOrder();
	// updates an items tab order
	void UpdateItemTabOrder(CItemInfo &ItemInfo);

	// sets the busy flag
	void SetBusy(BOOL Busy);
	// sets the modified flag
	void SetModified(BOOL Modified);
	// returns the state of the editor
	CFormEditorState GetState();
	// fires a state changed event
	void FireStateChangedEvent(
		const CFormEditorState &OldState,BOOL Force=FALSE);

	// determines if the passed name is valid
	BOOL IsNameValid(const std::wstring &Name);
	// determines if the passed name is unique
	BOOL IsNameUnique(const std::wstring &Name,const CWindow &Ignore=NULL);
	// creates a unique item name given the base name
	std::wstring CreateUniqueItemName(const std::wstring &BaseName);
	// creates a unique item name from the item provided base name
	std::wstring CreateUniqueItemName(const CComPtr<IOleObject> &spOleObject);

	// initialises the form using raw information
	void InitialiseForm(
		const std::wstring &Name,const CSize &Size,
		OLE_COLOR BackColor,OLE_COLOR ForeColor);
	// initialises the form from the passed stream
	void InitialiseFormFromStream(
		const CComPtr<IStream> &spStream,DWORD StreamVersion);
	// saves the form to the passed stream
	void SaveFormToStream(const CComPtr<IStream> &spStream);
	// creates an item using raw information
	CItemInfo &CreateItem(
		const std::wstring &Name,const std::wstring &Tag,
		const CRect &Rect,const CLSID &ClassId,
		const CComPtr<IStream> &spStream);
	// creates items from the passed stream
	CItemInfoPtrList CreateItemsFromStream(
		const CComPtr<IStream> &spStream,DWORD StreamVersion,
		BOOL IsPasting);
	// saves items to the passed stream
	void SaveItemsToStream(const CComPtr<IStream> &spStream,
		const CItemInfoPtrList &ItemInfoPtrList);
	// resets the script
	void ResetScript();
	// loads the script from the passed stream
	void LoadScriptFromStream(
		const CComPtr<IStream> &spStream,DWORD StreamVersion);
	// saves the script to the passed stream
	void SaveScriptToStream(const CComPtr<IStream> &spStream);

	// stream type
	enum StreamType {
		// full stream (form,items,script)
		StreamTypeFull,
		// clipboard stream (items only)
		StreamTypeClipboard,
		// undo or redo stream (form,items)
		StreamTypeUndoRedo };

	// loads components from the passed stream
	CItemInfoPtrList InternalLoad(
		const CComPtr<IStream> &spStream,StreamType Type);
	// saves components to the passed stream
	void InternalSave(
		const CComPtr<IStream> &spStream,StreamType Type);
	// validates the script
	BOOL InternalValidateScript();

	// move type
	enum MoveType {
		// move left
		MoveTypeLeft,
		// move right
		MoveTypeRight,
		// move up
		MoveTypeUp,
		// move down
		MoveTypeDown };

	// moves selected items
	void MoveSelectedItems(MoveType Type);

	// align type
	enum AlignType {
		// align left
		AlignTypeLeft,
		// align right
		AlignTypeRight,
		// align top
		AlignTypeTop,
		// align bottom
		AlignTypeBottom };

	// aligns selected items to one another
	void AlignSelectedItems(AlignType Type);

	// form align type
	enum FormAlignType {
		// align horizontal center
		FormAlignTypeHCenter,
		// align vertical center
		FormAlignTypeVCenter,
		// align both horizontal and vertical center
		FormAlignTypeBoth };

	// aligns selected items to the form
	void AlignSelectedItemsToForm(FormAlignType Type);

	// size type
	enum SizeType {
		// size width
		SizeTypeWidth,
		// size height
		SizeTypeHeight,
		// size both width and height
		SizeTypeBoth };

	// sizes selected items to the largest
	void SizeSelectedItemsToLargest(SizeType Type);
	// sizes selected items to the smallest
	void SizeSelectedItemsToSmallest(SizeType Type);
	// todo : modify the editor to have a dominant control

	// spaces selected items horizontally
	void SpaceSelectedItemsHorizontally();
	// spaces selected items vertically
	void SpaceSelectedItemsVertically();

	// determines if the passed item requires property pages
	BOOL DoesItemRequirePropertyPages(CItemInfo &ItemInfo);
	// shows property pages for the form
	void ShowFormProperties();
	// shows property pages for the selected item
	void ShowSelectedItemProperties();

	// adds an object to the exposed objects map
	void AddExposedObject(
		const std::wstring &Name,const CComPtr<IDispatch> &spDispatch);

	// determines if an event is handled by the script
	BOOL IsEventHandled(const std::wstring &Source,const std::wstring &Event);
	// adds an event handler to the script
	void AddEventHandler(const CEventInfo &EventInfo);
	// edits an event handler in the script
	void EditEventHandler(const std::wstring &Source,const std::wstring &Event);

	// creates an event menu given an objects IDispatch interface
	CMenuHandle CreateEventMenu(
		const std::wstring &SourceName,
		const CComPtr<IDispatch> &spDispatch,
		CAvailableMenuItemIdSet &AvailableMenuItemIdSet,
		CMenuItemIdToEventInfoMap &MenuItemIdToEventInfoMap);
	// creates an event menu given an objects event interface type info
	CMenuHandle CreateEventMenu(
		const std::wstring &SourceName,
		const CComPtr<ITypeInfo> &spTypeInfo,
		CAvailableMenuItemIdSet &AvailableMenuItemIdSet,
		CMenuItemIdToEventInfoMap &MenuItemIdToEventInfoMap);
	// creates an event menu for the form
	CMenuHandle CreateFormEventMenu(
		CAvailableMenuItemIdSet &AvailableMenuItemIdSet,
		CMenuItemIdToEventInfoMap &MenuItemIdToEventInfoMap);
	// creates an event menu for the passed item
	CMenuHandle CreateItemEventMenu(
		CItemInfo &ItemInfo,
		CAvailableMenuItemIdSet &AvailableMenuItemIdSet,
		CMenuItemIdToEventInfoMap &MenuItemIdToEventInfoMap);
	// creates an event menu for the exposed object with the passed name
	CMenuHandle CreateExposedObjectEventMenu(
		const std::wstring &Name,
		CAvailableMenuItemIdSet &AvailableMenuItemIdSet,
		CMenuItemIdToEventInfoMap &MenuItemIdToEventInfoMap);
	// creates an exposed objects menu
	CMenuHandle CreateExposedObjectsMenu(
		CAvailableMenuItemIdSet &AvailableMenuItemIdSet,
		CMenuItemIdToEventInfoMap &MenuItemIdToEventInfoMap);

public:
	CFormEditor();
	virtual ~CFormEditor();

DECLARE_REGISTRY_RESOURCEID(IDR_FORMEDITOR)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CFormEditor)
	COM_INTERFACE_ENTRY(IFormEditor2)
	COM_INTERFACE_ENTRY(IFormEditor)
	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)
END_COM_MAP()

BEGIN_PROP_MAP(CFormEditor)
	PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
	PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
	PROP_ENTRY("BorderVisible", DISPID_BORDERVISIBLE, CLSID_PropPageFormEditor)
	PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage)
	PROP_ENTRY("FormWidth", DISPID_FORMWIDTH, CLSID_PropPageFormEditor)
	PROP_ENTRY("FormHeight", DISPID_FORMHEIGHT, CLSID_PropPageFormEditor)
	PROP_ENTRY("FormBackColor", DISPID_FORMBACKCOLOR, CLSID_StockColorPage)
	PROP_ENTRY("FormForeColor", DISPID_FORMFORECOLOR, CLSID_StockColorPage)
	PROP_ENTRY("GridWidth", DISPID_GRIDWIDTH, CLSID_PropPageFormEditor)
	PROP_ENTRY("GridHeight", DISPID_GRIDHEIGHT, CLSID_PropPageFormEditor)
	PROP_ENTRY("GridVisible", DISPID_GRIDVISIBLE, CLSID_PropPageFormEditor)
	PROP_ENTRY("DragFrameBackColor", DISPID_DRAGFRAMEBACKCOLOR, CLSID_StockColorPage)
	PROP_ENTRY("DragFrameForeColor", DISPID_DRAGFRAMEFORECOLOR, CLSID_StockColorPage)
	PROP_ENTRY("TabNumberBackColor", DISPID_TABNUMBERBACKCOLOR, CLSID_StockColorPage)
	PROP_ENTRY("TabNumberForeColor", DISPID_TABNUMBERFORECOLOR, CLSID_StockColorPage)
	// Example entries
	// PROP_ENTRY("Property Description", dispid, clsid)
	// PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()

BEGIN_CONNECTION_POINT_MAP(CFormEditor)
	CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
	CONNECTION_POINT_ENTRY(DIID__IFormEditorEvents)
END_CONNECTION_POINT_MAP()

BEGIN_MSG_MAP(CFormEditor)
	CHAIN_MSG_MAP(CFormEditorComControl)
	DEFAULT_REFLECTION_HANDLER()
	MESSAGE_HANDLER(WM_CREATE, OnCreate)
	MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
	MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
	MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
	MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
	MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
	MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUP)
	MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
	MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
	MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
	MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged)
	MESSAGE_HANDLER(WM_CONTEXTMENU_INDIRECT, OnContextMenuIndirect)
	MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
	MESSAGE_HANDLER(WM_TIMER, OnTimer)
	MESSAGE_HANDLER(WM_GET_EXTENDED_PROPPAGE_DATA, OnGetExtendedPropPageData)
	MESSAGE_HANDLER(WM_SET_EXTENDED_PROPPAGE_DATA, OnSetExtendedPropPageData)
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);

// drag frame notify sink
	void DFNS_BeginMove();
	void DFNS_Move(long cx,long cy);
	void DFNS_EndMove();
	void DFNS_BeginSize();
	void DFNS_Size(CDragFrame::DragHandle Handle,long cx,long cy);
	void DFNS_EndSize();
	void DFNS_ContextMenu();
// simulated notification messages
	void DFNS_BeginSizeForm();
	void DFNS_SizeForm(CDragFrame::DragHandle Handle,long cx,long cy);
	void DFNS_EndSizeForm();

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

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

// IViewObjectEx
	DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)

// message handlers
	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnHScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnVScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnLButtonUP(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnRButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnRButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnCaptureChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnContextMenuIndirect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnGetExtendedPropPageData(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnSetExtendedPropPageData(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

// IFormEditor
public:
	STDMETHOD(About)();
	STDMETHOD(SelectAll)();
	STDMETHOD(SelectNone)();
	STDMETHOD(New)();
	STDMETHOD(NewEx)(
		/*[in]*/ long Width,
		/*[in]*/ long Height,
		/*[in]*/ OLE_COLOR BackColor,
		/*[in]*/ OLE_COLOR ForeColor);
	STDMETHOD(ShowInsertDialog)(/*[out, retval]*/ BSTR *pProgID);
	STDMETHOD(Insert)(
		/*[in]*/ BSTR ProgID,
		/*[out, retval]*/ IDispatch **ppDispatch);
	STDMETHOD(InsertEx)(
		/*[in]*/ BSTR ProgID,
		/*[in]*/ long Left,
		/*[in]*/ long Top,
		/*[in]*/ long Width,
		/*[in]*/ long Height,
		/*[out, retval]*/ IDispatch **ppDispatch);
	STDMETHOD(Delete)();
	STDMETHOD(Cut)();
	STDMETHOD(Copy)();
	STDMETHOD(Paste)();
	STDMETHOD(Undo)();
	STDMETHOD(Redo)();
	STDMETHOD(SetTabOrder)();
	STDMETHOD(RefreshState)();
	STDMETHOD(LoadFromFile)(/*[in]*/ BSTR FileName);
	STDMETHOD(SaveToFile)(/*[in]*/ BSTR FileName);
	STDMETHOD(ValidateScript)(/*[out, retval]*/ VARIANT_BOOL *pRet);
	STDMETHOD(MoveLeft)();
	STDMETHOD(MoveRight)();
	STDMETHOD(MoveUp)();
	STDMETHOD(MoveDown)();
	STDMETHOD(AlignLeft)();
	STDMETHOD(AlignRight)();
	STDMETHOD(AlignTop)();
	STDMETHOD(AlignBottom)();
	STDMETHOD(FormAlignHCenter)();
	STDMETHOD(FormAlignVCenter)();
	STDMETHOD(FormAlignBoth)();
	STDMETHOD(SizeWidthToLargest)();
	STDMETHOD(SizeHeightToLargest)();
	STDMETHOD(SizeToLargest)();
	STDMETHOD(SizeWidthToSmallest)();
	STDMETHOD(SizeHeightToSmallest)();
	STDMETHOD(SizeToSmallest)();
	STDMETHOD(SpaceHorizontally)();
	STDMETHOD(SpaceVertically)();
	STDMETHOD(Properties)();
	STDMETHOD(Expose)(
		/*[in]*/ BSTR Name,
		/*[in]*/ IDispatch *pDispatch);
	STDMETHOD(DDUnlock)(
		/*[in]*/ long Data1_High,
		/*[in]*/ long Data1_Low,
		/*[in]*/ long Data2_High,
		/*[in]*/ long Data2_Low);
	STDMETHOD(get_Script)(/*[out, retval]*/ IScript2 **ppScript2);
	STDMETHOD(get_BorderVisible)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_BorderVisible)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_BackColor)(/*[out, retval]*/ OLE_COLOR *pVal);
	STDMETHOD(put_BackColor)(/*[in]*/ OLE_COLOR newVal);
	STDMETHOD(get_FormWidth)(/*[out, retval]*/ long *pVal);
	STDMETHOD(put_FormWidth)(/*[in]*/ long newVal);
	STDMETHOD(get_FormHeight)(/*[out, retval]*/ long *pVal);
	STDMETHOD(put_FormHeight)(/*[in]*/ long newVal);
	STDMETHOD(get_FormBackColor)(/*[out, retval]*/ OLE_COLOR *pVal);
	STDMETHOD(put_FormBackColor)(/*[in]*/ OLE_COLOR newVal);
	STDMETHOD(get_FormForeColor)(/*[out, retval]*/ OLE_COLOR *pVal);
	STDMETHOD(put_FormForeColor)(/*[in]*/ OLE_COLOR newVal);
	STDMETHOD(get_GridWidth)(/*[out, retval]*/ long *pVal);
	STDMETHOD(put_GridWidth)(/*[in]*/ long newVal);
	STDMETHOD(get_GridHeight)(/*[out, retval]*/ long *pVal);
	STDMETHOD(put_GridHeight)(/*[in]*/ long newVal);
	STDMETHOD(get_GridVisible)(/*[out, retval]*/ VARIANT_BOOL *pVal);
	STDMETHOD(put_GridVisible)(/*[in]*/ VARIANT_BOOL newVal);
	STDMETHOD(get_DragFrameBackColor)(/*[out, retval]*/ OLE_COLOR *pVal);
	STDMETHOD(put_DragFrameBackColor)(/*[in]*/ OLE_COLOR newVal);
	STDMETHOD(get_DragFrameForeColor)(/*[out, retval]*/ OLE_COLOR *pVal);
	STDMETHOD(put_DragFrameForeColor)(/*[in]*/ OLE_COLOR newVal);
	STDMETHOD(get_TabNumberBackColor)(/*[out, retval]*/ OLE_COLOR *pVal);
	STDMETHOD(put_TabNumberBackColor)(/*[in]*/ OLE_COLOR newVal);
	STDMETHOD(get_TabNumberForeColor)(/*[out, retval]*/ OLE_COLOR *pVal);
	STDMETHOD(put_TabNumberForeColor)(/*[in]*/ OLE_COLOR newVal);

// IFormEditor2
	STDMETHOD(SendToBack)();
	STDMETHOD(BringToFront)();
	STDMETHOD(GetItemDetails)(
		/*[in]*/ IDispatch *pDispatch,
		/*[out, retval]*/ IFormEditorItemDetails **ppFormEditorItemDetails);
	STDMETHOD(GetItemClassId)(
		/*[in]*/ IDispatch *pDispatch,
		/*[out, retval]*/ BSTR *pClassId);
	STDMETHOD(GetItemName)(
		/*[in]*/ IDispatch *pDispatch,
		/*[out, retval]*/ BSTR *pName);
	STDMETHOD(SetItemName)(
		/*[in]*/ IDispatch *pDispatch,
		/*[in]*/ BSTR Name);
	STDMETHOD(GetItemTag)(
		/*[in]*/ IDispatch *pDispatch,
		/*[out, retval]*/ BSTR *pTag);
	STDMETHOD(SetItemTag)(
		/*[in]*/ IDispatch *pDispatch,
		/*[in]*/ BSTR Tag);
	STDMETHOD(GetItemPosition)(
		/*[in]*/ IDispatch *pDispatch,
		/*[out]*/ long *pLeft,
		/*[out]*/ long *pTop,
		/*[out]*/ long *pWidth,
		/*[out]*/ long *pHeight,
		/*[out]*/ long *pTabNumber);
	STDMETHOD(SetItemPosition)(
		/*[in]*/ IDispatch *pDispatch,
		/*[in]*/ long Left,
		/*[in]*/ long Top,
		/*[in]*/ long Width,
		/*[in]*/ long Height,
		/*[in]*/ long TabNumber);
	STDMETHOD(IsItemSelected)(
		/*[in]*/ IDispatch *pDispatch,
		/*[out, retval]*/ VARIANT_BOOL *pIsSelected);
	STDMETHOD(SelectItem)(
		/*[in]*/ IDispatch *pDispatch,
		/*[in]*/ VARIANT_BOOL KeepCurrentSelection);
	STDMETHOD(UnselectItem)(
		/*[in]*/ IDispatch *pDispatch);
	STDMETHOD(IsItemDeleted)(
		/*[in]*/ IDispatch *pDispatch,
		/*[out, retval]*/ VARIANT_BOOL *pIsDeleted);
	STDMETHOD(get_Items)(
		/*[out, retval]*/ IFormEditorItemCollection **ppFormEditorItemCollection);
	STDMETHOD(get_SelectedItems)(
		/*[out, retval]*/ IFormEditorItemCollection **ppFormEditorItemCollection);
};

} // namespace AxFormEditor

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