Objects Events Listing
Pop-Up Object properties and methods list
IntelliSense - like function parameters tooltips
Introduction
I've been searching the net for a suitable and affordable solution that will allow me to embed scripting functionality in my C++ application. What I found was either not sufficient or cost a lot of money.
So I've decided to make one of my own. After about a month of work and testing I've come up with this embeddable scripter.
I made it a separate DLL , which is really easy to use.
Usage
- Download the source code, and compile it. Make sure to compile the correct version (Debug\Release) or both.
- Include ScriptEditor.h in your project and add the library ScriptEditor.lib to your additional libraries. Make sure to reference the correct version! Debug version for debugging and release version for release!
- Copy the DLL to the same folder as your executable.
- In your code create an instance of
CScripter
and initialize it.
- Add your objects to the script and optionally the script text.
Example
In the header of your main application window add:
#include "..\ScriptEditor\Scripter.h"
Add member variable:
CScripter scripter;
Then when initializing add:
scripter.CreateEngine("VBScript");
After that add your objects to the script:
scripter.AddObject("MPlayer",(IDispatch *)m_mediaPlayer.GetControlUnknown());
scripter.AddObject("PlayButton",
(IDispatch *)m_commandButton.GetControlUnknown());
scripter.AddObject("TabStrip",(IDispatch *)m_tabStrip.GetControlUnknown());
scripter.AddObject("SimpleObject",m_simpleObject.GetIDispatch(TRUE));
And optionally set the script text:
scripter.scriptText = "MsgBox \"Test message\"";
After that the script is ready to run, you now may do one of the following:
scripter.StartScript();
scripter.StopScript();
scripter.LaunchEditor();
scripter.Reset();
History
This is the first release so it's probably not bug free. I've done my best to track any bugs but there are always surprises. So I will post here any additions, patches and fixes that will follow.
- 19/07/03 - The DLL source was updated to compile in VS.NET (read the messages below)
Credits
- Gil Eizenburg for debugging and testing.
- Smaller Animals Software, Inc. for ColorEditWnd class.
- Daniel Madden for CTokenEx class.