Click here to Skip to main content
15,885,546 members
Articles / Desktop Programming / WTL

Form Designer

26 Jul 2021CPOL24 min read 351.2K   82.5K   230  
Component for adding scriptable forms capabilities to an application.
// Driver.h : Declaration of the CDriver
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////

#pragma once
#include "resource.h"       // main symbols

#include "..\..\DDForms\DDForms.h"

// codemax type library
#import "CMax20.ocx"		\
	raw_interfaces_only		\
	rename("ReplaceText","_ReplaceText")

// IDriver
[
	object,
	uuid("B0DE2A22-2B9A-4A8E-A6AD-74877BE832D9"),
	dual,	helpstring("IDriver Interface"),
	pointer_default(unique)
]
__interface IDriver : IDispatch
{
	[propget, id(1), helpstring("Returns/sets the CodeMax editor object")] HRESULT Editor([out, retval] IUnknown** pVal);
	[propput, id(1), helpstring("Returns/sets the CodeMax editor object")] HRESULT Editor([in] IUnknown* newVal);
};

// CDriver
#define CDriver Driver	// for correct coclass naming
[
	coclass,
	threading("apartment"),
	vi_progid("CodeMaxDriver.Driver"),
	progid("CodeMaxDriver.Driver.1"),
	version(1.0),
	uuid("C40EC78F-4A4C-4258-8D64-827A59D6DA91"),
	helpstring("Driver Class")
]
class ATL_NO_VTABLE CDriver : 
	public IDispatchImpl<IDriver>,
	public IScriptBuffer,
	public IScriptNavigation,
	public IScriptState
{
private:
	// the editor
	CComPtr<IUnknown> m_spEditor;
	// while this is greater than zero the editor will be read only
	DWORD m_LockCount;

	// returns the number of lines in the editor
	DWORD GetLineCount();
	// returns the length of the specified line in the editor
	DWORD GetLineLength(DWORD Line);

	// creates a position
	CComPtr<CodeMax::IPosition> CreatePosition(DWORD Line,DWORD Col);
	// creates a range
	CComPtr<CodeMax::IRange> CreateRange(
		DWORD StartLine,DWORD StartCol,DWORD EndLine,DWORD EndCol);

public:
	CDriver();

	DECLARE_PROTECT_FINAL_CONSTRUCT()
	HRESULT FinalConstruct();
	void FinalRelease();

public:
// IDriver
	STDMETHOD(get_Editor)(IUnknown** pVal);
	STDMETHOD(put_Editor)(IUnknown* 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
};

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)


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions