VB6 to BASIC+ (OpenInsight 32-Bit)
At 11 JAN 2008 10:02:45AM Don Muskopf wrote:
I'm evaluating a trial version of TeeChart Pro ActiveX Version 8 and I'm having difficulty translating some VB6 code into BASIC+. Below is the VB code to create a simple bar graph, along with my translation to BASIC+. I have tested the VB code and it works fine. However, I have not been able to populate the graph using BASIC+ (the last 4 lines of the BASIC+ code).
Any help would be greatly appreciated. Thanks.
* VISUAL BASIC CODE. TESTED IN VB6. WORKS FINE. * ' Create Bar Chart, add header, add 3 bars. * ' Then remove one line of header. * With TChart1 * .Header.Text.Add ("ACME Monthly Sales") * .Header.Text.Add ("Year 2008") * .AddSeries scBar * * .Series(0).Clear * .Series(0).Add 123, "ABC", vbRed * .Series(0).Add 456, "DEF", vbBlue * .Series(0).Add 321, "GHI", vbGreen * .Series(0).Marks.Style=smsValue * .Header.Text.Remove (1) * End With [/color] * BASIC+ CODE. * These lines work. [/color]Ctrl=[/color]@Window[/color]:[/color]".OLE_CHART" [/color]Send_Message(Ctrl, [/color]"OLE.Header.Text.Add"[/color], [/color]"ACME Monthly Sales"[/color]) Send_Message(Ctrl, [/color]"OLE.Header.Text.Add"[/color], [/color]"Year 2008"[/color]) Send_Message(Ctrl, [/color]"AddSeries"[/color], [/color]1[/color]) ;[/color]* scBar=1 [/color] * These lines DO NOT work. [/color]Send_Message(Ctrl, [/color]"Series(0).Add"[/color], [/color]123[/color], [/color]"ABC"[/color], [/color]65280[/color]) ;[/color]* 65280 is vbGreen. [/color]Send_Message(Ctrl, [/color]"Series(0).Add"[/color], [/color]456[/color], [/color]"DEF"[/color], [/color]65280[/color]) Send_Message(Ctrl, [/color]"Series(0).Add"[/color], [/color]321[/color], [/color]"GHI"[/color], [/color]65280[/color]) Set_Property(Ctrl, [/color]"OLE.Series(0).Marks.Style"[/color], [/color]0[/color]) ;* 0=smsValue.[/color][/color]
At 11 JAN 2008 04:03PM Bob Carten wrote:
Series(0) uses the default Items collection of a Series.
Vb really uses Series.Items(0)
try using that in your code, for example
Send_Message(Ctrl,'Series.Items(0).Add', '321')
At 14 JAN 2008 09:42AM Don Muskopf wrote:
Thanks, Bob. Unfortunately, your suggestion didn't work. I'll work on this again later today. Do you have any other thoughts?
At 14 JAN 2008 11:31AM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:
Don,
Try using square brackets instead of parenthesis:
* These lines DO NOT work. [/color]Send_Message(Ctrl, [/color]"Series.Items0.Add"[/color], [/color]123[/color], [/color]"ABC"[/color], [/color]65280[/color]) ;[/color]* 65280 is vbGreen. [/color]Send_Message(Ctrl, [/color]"Series.Items0.Add"[/color], [/color]456[/color], [/color]"DEF"[/color], [/color]65280[/color]) Send_Message(Ctrl, [/color]"Series.Items0.Add"[/color], [/color]321[/color], [/color]"GHI"[/color], [/color]65280[/color]) Set_Property(Ctrl, [/color]"OLE.Series.Items0.Marks.Style"[/color], [/color]0[/color]) ;[/color]* 0=smsValue. [/color][/color][/size]kfournier@srpcs.com
At 14 JAN 2008 03:49PM Don Muskopf wrote:
Kevin,
I tried using the square brackets instead of parentheses, but still no joy. There must be something about this control I don't understand. I'll keep looking.
Thanks for your help.
At 15 JAN 2008 11:24AM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:
Don,
I should have paid closer attention. The problem is that Send_Message can do the cookie crumb thing. That is, we calling a method within a property within a property. So, we need to drill down the properties first, then use OleCallMethod to call the method. Try this:
* We need to use OLE functions for this [/color]pItem=Get_Property(Ctrl, [/color]"OLE.Series.Items0"[/color]) OleCallMethod(pItem, [/color]"Add"[/color], [/color]123[/color], [/color]"ABC"[/color], [/color]65280[/color]) OleCallMethod(pItem, [/color]"Add"[/color], [/color]456[/color], [/color]"DEF"[/color], [/color]65280[/color]) OleCallMethod(pItem, [/color]"Add"[/color], [/color]321[/color], [/color]"GHI"[/color], [/color]65280[/color])[/color][/color][/size]kfournier@srpcs.com
At 15 JAN 2008 04:27PM Don Muskopf wrote:
Kevin,
I used your code changing the OleCallMethod statements to functions. Still no success.
I was under the impression that to use OleCallMethod, OleCreateInstance had to be used prior to OleCallMethod. Could that be the problem here?
Don
At 15 JAN 2008 05:19PM [url=http://www.srpcs.com]SRP[/url]'s Kevin Fournier wrote:
Don,
OleCreateInstance is only necessary when creating new instances of objects. OleCallMethod only needs a COM object pointer, or in technical terms, a Dispatch object pointer. When you do a Get_Property on a property called "Text", the returned value is a string. When you do a Get_Property on a property that has subproperties, like "Font", then you get Dispatch pointer. Now, Get_Property and Set_Property hides the Dispatch pointer by allowing you to drill down into sub-properties using the period character. So, Get_Property on "Font.Size" gets the size of the font. However, if you just get "Font", you should get a large number. This number is the Dispatch pointer.
Set_Property and Get_Property cannot call methods, even if they are contained within a property. Nor can Send_Message deal with properties. Since we had to deal with both, I attempted to get the Dispatch pointer from the Get_Property call and pass that to the OleCallMethod. Admittedly, I didn't test this on the actual TeeChart control.
I'll see if I can squeeze in a few minutes to play with this. We have another client interested in the possibility of using this control, so it would be time well spent.
At 15 JAN 2008 07:06PM Don Muskopf wrote:
Kevin, thanks for the explanation. Up until now I haven't had a need to use these statements, so I'll admit that I'm new to them. To me, the OI documentation seemed to imply that OleCallMethod is used only for controls that are not bound to a form. In fact, I haven't found an example in the documentation or on the discussion board where it used in the context of the OI OLE container control. Well, I learned something and I appreciate your efforts.