VbScript and Events

TeeChart for ActiveX, COM and ASP
Post Reply
OptUser
Newbie
Newbie
Posts: 2
Joined: Tue Nov 12, 2002 5:00 am

VbScript and Events

Post by OptUser » Tue Feb 01, 2005 7:39 pm

Hi,
I'm working whit the TChart and VbScript, but I have a problem with the
TChart's events.
When I attach the TChart control to the Scrip Object the properties work
correctly, but the events don't trigger in the Script

This is a example

In a VbProjects add a TChart, RichTextBox, TextBox and a CommandButton objects, and add reference to msscript.ocx

Add the next source in a form

Private WithEvents m_scriptEngine As MSScriptControl.ScriptControl


Private Sub Command1_Click()
m_scriptEngine.AddCode Text1
m_scriptEngine.Run "Activate"
m_scriptEngine.State = Connected
End Sub

Private Sub Form_Initialize()
Set m_scriptEngine = New MSScriptControl.ScriptControl
m_scriptEngine.Language = "VBScript"
m_scriptEngine.AllowUI = True
m_scriptEngine.UseSafeSubset = False
m_scriptEngine.SitehWnd = Me.hWnd
End Sub

Private Sub Form_Load()

m_scriptEngine.AddObject "TChart1", TChart1.Object
m_scriptEngine.AddObject "TChart", TChart1
m_scriptEngine.AddObject "RichTextBox1", RichTextBox1.Object
m_scriptEngine.AddObject "RichTextBox", RichTextBox1

Text1 = "Sub Activate" & vbCrLf & _
" msgbox " & """" & "Activate" & """" & vbCrLf & _
" RichTextBox.Text = " & """" & "VbScript Test" & """" & vbCrLf & _
" TChart.Aspect.View3d = False " & vbCrLf & _
"End Sub" & vbCrLf & vbCrLf & _
"Sub TChart1_OnClick()" & vbCrLf & _
" msgbox " & """" & "OnClick" & """" & vbCrLf & _
"End Sub" & vbCrLf & vbCrLf & _
"Private Sub RichTextBox1_Change()" & vbCrLf & _
" msgbox " & """" & "Change" & """" & vbCrLf & _
"End Sub"

End Sub



Regards

Gustavo.

Marc
Site Admin
Site Admin
Posts: 1219
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Thu Feb 10, 2005 10:53 pm

Hello Gustavo,

We haven't yet succeeded here either to make the events work in this way. Perhaps there is an alternative that may be suitable for your requirements (ie. opening a form or tab with a new Chart on). We may be able to help with further suggestions.

Regards,
Marc Meumann
Steema Support

OptUser
Newbie
Newbie
Posts: 20
Joined: Mon Nov 21, 2005 12:00 am

Post by OptUser » Wed Nov 30, 2005 10:04 pm

Hello again,

I've tried a similar setup in a C++ ATL project, with the same results. In ATL, the first object doing an AtlAdvise (to sink the TeeChart events) works OK, but the second object receives an error code 0x80040202. Looking for it on google groups I found these two posts:


http://groups.google.com/group/borland. ... 374a2fdcea

http://groups.google.com/group/borland. ... 60feb7fcce

They are related to a bug in a Delphi wizard that generates the code to manage the events. That bug makes that the activex controls generated with delphi could only send event notifications to just one destination.
Could it be possible that TeeChart is suffering from this same bug?

Regards,
Gustavo

Post Reply