 |
|
 |
I agree with you that Microsoft doesn't document it very well...even though it's been used in almost all their products (Office, Visual Studio, etc.)
Unfortunately, most of the links are now gone.
Ernest
|
|
|
|
 |
|
 |
I had some problems getting this to work on MSVC .NET.
The rich text edit does not load. The control is not registered on my machine.
There is a workaround - delete the control IDX_TXT_ADDRESS and member variable m_txtAddress. Comment out the usage of m_txtAddress in MFCScriptHostDlg.cpp.
Then the demo runs (without the address edit control).
But adding a Rich Text Control 2.0 offered by MSVC stops the dialog being created, even if no member variable is attached to it. Any ideas why that should be?
|
|
|
|
 |
|
 |
Hello,
I ran into the same problem. I removed the control reference from the .rc file, removed the wrapper class and added a new activeX control called "MSREdit Class", attaching it to the m_txtAddress member and the code works fine.
I believe you are not getting the dialog when using the Rich Text Control 2.0 because it's not an OLE control and the dialog fails to create properly.
Hope that helps
|
|
|
|
 |
|
 |
I want to FireEvent from a thread. Its not working with thread, previously its was running fine.
Please tell me how to work it out.
thank you.
|
|
|
|
 |
|
 |
It's much better to use it from a single thread. But if you want to access the object from a secondary, make sure you initialized COM library....I think the problem could be elsewhere though.
Also, make sure the thread that creates the script object is the same that host the event.
|
|
|
|
 |
|
 |
--------------------Configuration: MFCScriptHost - Win32 Debug--------------------
Linking...
ActiveScriptHost.obj : error LNK2001: unresolved external symbol _IID_IActiveScriptParse32
Debug/MFCScriptHost.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
MFCScriptHost.exe - 2 error(s), 0 warning(s)
|
|
|
|
 |
|
 |
Your article is fantastic, I was able to ge scripting to work in my application. I am a nubie to Com however. Is there a way to single step a script? Or more generally how do you add script debugging capabilities. I looked at the online documention and it would appear this is possible but trying to figure it out from just the interface documentation is almost impossible.
I need a way for users of my application to debug the scripts they create
Thanks
George
|
|
|
|
 |
|
 |
George,
This is a nice thing I'd like to write about but never had time to do it. Hopefully, at the end of my current project (mid of December).
Thanks for great feedback.
Ernest
|
|
|
|
 |
|
 |
I'd be willing to pay you to get the debugging support, if you’re interested, please contact me at aba1@rtmi.com
|
|
|
|
 |
|
 |
Thanks for the offer, but I simply don't have the time. I was able to add debugging using the Microsoft Script Debugger but I used a diffferent implementation then your post.
|
|
|
|
 |
|
 |
I'd also like to use the Microsoft Script Debugger, could you point me in the right direction for its implementation?
or do you know of a sample?
Thanks in advance
Tim
|
|
|
|
 |
|
 |
There is a sample. It's been a while, I will post a link when I find it.
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
How can I enable the UI so that functions like MsgBox can be run?
thank in advance
Stefano
|
|
|
|
 |
|
 |
Probably I did find the solution, I must call
SetHostWindow(...);
ciao
Stefano
|
|
|
|
 |
|
 |
Firstly,thanks for your code.Then,tell you my problems.I am a beginer in COM,and I donot knowe how to get the IDs in your program,I want to knowe how I can get these IDs such as
// Note: we add support for IID_IHost_Proxy to support typesafe binding
// from VBA. This IID must match the GUID that is attached to the
// dispinterface in the .ODL file.
// {BC810D88-1564-46CF-960A-6BD3653E91D7}
static const GUID CLSID_Host_Proxy =
{ 0xBC810D88, 0x1564, 0x46CF, { 0x96, 0x0A, 0x6B, 0xD3, 0x65, 0x3E, 0x91, 0xD7 } };
// {F8235A29-C576-439D-A070-6E7980C9C3F6}
static const IID IID_IHost_Proxy =
{ 0xF8235A29, 0xC576, 0x439D, { 0xA0, 0x70, 0x6E, 0x79, 0x80, 0xC9, 0xC3, 0xF6 } };
// {740C1C2D-692F-43F8-85FF-38DEE1742819}
static const IID IID_IHostEvent =
{ 0x740c1c2d, 0x692f, 0x43f8, { 0x85, 0xff, 0x38, 0xde, 0xe1, 0x74, 0x28, 0x19 } };
// {E662E9C0-01DB-4A0C-9AF9-06F8FFB7ACBE}
static const GUID _tlid =
{ 0xE662E9C0, 0x01DB, 0x4A0C, { 0x9A, 0xF9, 0x06, 0xF8, 0xFF, 0xB7, 0xAC, 0xBE } };
and I also want to knowe the steps to finish my program.
thanks a lot!
I do,I feel,and I happy!
|
|
|
|
 |
|
 |
I would really thank you if you could help me with this problem, I want that my application create objects dynamically and catch the events that the Control Active X generate.
I have a configuration file with the name of the object that I want to create and the name of the control, the application reads the configuration file, create the object and adds it to the list using the following functions:
hResult = CLSIDFromProgID(T2OLE(m_csProgID), &clsid);
// Create the Object
hResult = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER , IID_IDispatch, (void **)&m_pDispatch);
m_ScriptProxy.AddScriptItem(m_csName, m_pDispatch);
Once the object was created I have access to the methods of the control, but I don't know how to catch the events that the controls generate.
The user indicates to the application through the configuration file which control should create and I obtain the name of the events associated to each control.
There is some way to catch the events using this information
|
|
|
|
 |
|
 |
Are you trying to catch the event from the script? [probably!]
JavaScript and VBScript syntax is a bit different but you can catch the event in any of these languages.
The file Script.txt has some examples.
function btnGo::Click()
{
var sUrl = txtAddress.Text;
webBrowser.Navigate( sUrl );
}
function webBrowser::NavigateError(pDisp, sUrl, pFrame, bCancel)
{
ScriptHost.Display("Failed to navigate: " + sUrl );
ScriptHost.QuitApp();
}VBScript event handler uses a different notation.
Sub btnGo_Click
Dim sUrl
sUrl = txtAddress.Text
webBrowser.Navigate( sUrl )
End Sub
ÿFor the bread of God is he who comes down from heaven and gives life to the world. - John 6:33
|
|
|
|
 |
|
 |
Thanks for your answer, this article was really heplful.
The sample works perfect.
I have just one more question, I promise will be the last .
In my last program I was using "MsgBox" to visualize a Message from the script, but when I use your example I can´t use this instruction. Could you tell me how to implement it?
Thanks a lot for all your help.
|
|
|
|
 |
|
 |
Hello, lately I've been trying to find a way to send packets from my application to another running application while viewing other things (In VC++, 2005 beta 2). If anyone knows of a way, please help.
|
|
|
|
 |
|
 |
Sorry Greg! wrong article!
|
|
|
|
 |
|
 |
Looks to me like you intended to create a demo script that links the contents of txtAddress, btnGo event and the browser object.
Did anyone do this?
|
|
|
|
 |
|
 |
Please be a little more specific and I'll try to help out!
ÿFor the bread of God is he who comes down from heaven and gives life to the world. - John 6:33
|
|
|
|
 |
|
 |
Thanks for the quick reply.
After posting I discovered in a later post that you had given an example for catching the btnGo click event. This answered my question - which shows my ignorance of Jscript.
function btnGo::Click()
{
var sUrl = txtAddress.Text;
webBrowser.Navigate( sUrl );
}
What changes would be necessary to allow 2 or more scripts to run concurrently?
|
|
|
|
 |