Click here to Skip to main content
Licence 
First Posted 15 Jul 2003
Views 198,782
Downloads 4,069
Bookmarked 114 times

Embeddable script editor for MFC applications

By Alex Hazanov | 15 Jul 2003
A library that allows you to embed scripting functionality to your C++ MFC application.
1 vote, 1.8%
1

2
2 votes, 3.6%
3
6 votes, 10.7%
4
47 votes, 83.9%
5
4.91/5 - 56 votes
3 removed
μ 4.81, σa 1.21 [?]

Objects Events Listing

Sample screenshot

Pop-Up Object properties and methods list

Sample screenshot

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

  1. Download the source code, and compile it. Make sure to compile the correct version (Debug\Release) or both.
  2. 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!
  3. Copy the DLL to the same folder as your executable.
  4. In your code create an instance of CScripter and initialize it.
  5. 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:

// Run the script
scripter.StartScript();

// Stop the script execution

scripter.StopScript();

// Open the script editor window

scripter.LaunchEditor();

// Reset the script (All added objects are removed and engine is recreated)

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Alex Hazanov

Software Developer (Senior)
RDV Systems
Israel Israel

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralAdding a new Class in the ScripTestLib to add functions in the Script Editor Pinmemberbrestian4:50 15 Jan '07  
GeneralRe: Adding a new Class in the ScripTestLib to add functions in the Script Editor Pinmembervccai4:02 7 Feb '07  
GeneralRe: Adding a new Class in the ScripTestLib to add functions in the Script Editor Pinmemberconfideman20001 hr 38mins ago 
GeneralMulti-threading Pinmemberjkhax0r14:30 8 Nov '06  
GeneralCOM projects Pinmemberdaniel remedi5:06 29 Jul '06  
GeneralLNK2001 Error for CreateEngine Pinmemberrbuchana7:46 5 Jul '06  
GeneralRe: LNK2001 Error for CreateEngine Pinmemberrbuchana12:37 7 Jul '06  
GeneralRe: LNK2001 Error for CreateEngine Pinmemberrbuchana7:39 14 Jul '06  
GeneralRe: LNK2001 Error for CreateEngine Pinmemberbrestian5:51 12 Jan '07  
GeneralRe: LNK2001 Error for CreateEngine Pinmembertotobby7:38 31 Jan '07  
GeneralIt seems headers in demo and source do not match Pinmemberzhaozh13:53 18 Aug '05  
GeneralRe: It seems headers in demo and source do not match PinmemberAlex Hazanov13:02 19 Aug '05  
GeneralMemory leaks Pinmemberarielevt1236:58 30 Jul '05  
GeneralRe: Memory leaks Pinmemberarielevt1239:02 5 Aug '05  
GeneralCreate a new function Pinmemberarielevt12311:08 10 Jul '05  
GeneralRe: Create a new function PinmemberAlex Hazanov22:25 10 Jul '05  
QuestionAnd what about Lua ? PinmemberKochise6:10 18 Feb '05  
AnswerRe: And what about Lua ? PinmemberAlex Hazanov7:47 19 Feb '05  
GeneralBUG? Pinmembercnmusic0:41 1 Aug '04  
GeneralProblem w/ events PinmemberDe Nardis Andrea1:01 20 Jul '04  
GeneralRe: Problem w/ events PinmemberAlex Hazanov7:40 19 Feb '05  
GeneralRe: Problem w/ events PinmemberDe Nardis Andrea22:31 20 Feb '05  
GeneralRe: Problem w/ events PinmemberAlex Hazanov1:06 21 Feb '05  
GeneralDebug assertion failed in debug version! PinmemberTLFLY0:32 8 Apr '04  
QuestionBuilds on VC 7.1? Pinmembergofootn13:59 25 Feb '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120210.1 | Last Updated 16 Jul 2003
Article Copyright 2003 by Alex Hazanov
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid