| Adding ActiveScript plugin functionality to your MFC Applications. |
CActiveScript_Functions this class exposes global functions for you to use. We have provided some basic functions for you, but you can add you own. You can also use this class as a model to make your own script object that gives functions out, if you wish to namespace scope the functions.To use the classes, you will simply need to create a CActiveScriptSite object (create via new, as a member element, or derive from it), and call the LoadScript function. This function takes 2 parameters, and handles creating and loading of the needed class objects:
CActiveScript_MsgBox this is a class that is used to prevent the VBScript MsgBox function from popping up a dialog, thus halting the application. Instead it writes the data out to a log file you will need to add your own logging code in if you want to capture it.
OLE String pointer to the language string (usually JavaScript or VBScript);If LoadScript returns false, something went wrong – usually the script itself is bad, and you will get messages via the OnScriptError function (a virtual function from the base class of IActiveScriptSite). Otherwise, it will return true with the IDispatch pointer set.
OLE String pointer to the script’s text – loaded from a file into memory.
void AddNamedItems(IActiveScript *pAS); |
pAS->AddNamedItem(oleStrName,flags); |
OLESTR("objectName").
The values for flags are defined within MSDN under AddNamedItem, but you will
generally use SCRIPTITEM_ISVISIBLE,
and add in SCRIPTITEM_GLOBALMEMBERS
when you wish to add new low-level function names to the script (like
“printf” for example).
if (wcscmp(pstrName, OLESTR("objectName")) == 0) |
try
|
long result part for clarity, even though it is not used. For taking output, you
would change the VT_EMPTY value to something like VT_I4, which is a return value
of long. For providing input, you give it the usual COM VT_xyz array of the
items to push into it.
Updated: Thursday, Sep 18, 2008 Contents copyright © 1999-2003 by NOPcode.com and its subsidiaries. Reproduction in part or in whole prohibited unless explicitly granted. All information and products, be it documentation, essays, source code, programs, or installs, are provided "as-is" and neither the author nor NOPcode.com will be held responsible for any resulting damages, either physical or mental. No warranty is expressed nor implied. All rights reserved. All trademarks used are property of their respected companies. For further information contact . |