Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic typecasting the AxControl-Value in Delphi (Read 5168 times)
Mischa
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Feb 13th, 2008
typecasting the AxControl-Value in Delphi
Mar 13th, 2008 at 5:44pm
Print Post  
Hello,

I want to implement a  flowchart-control in a box-item to show sub-graphs. My Problem is that the Value returned by the AXControl-property is not typecastable to tflowchart!

My Code:
box.Style :=bsAxControl;
box.AxControlId:='MindFusion.FlowChartPro.4.1';

newFC:= box.AxControl as tflowchart ;
or
newFC:= tflowchart (box.AxControl );
or
newFC:= tflowchart (idispatch(box.AxControl));
or
newFC:= tflowchart (IUnknown(box.AxControl));

using a Variant works, but I need a tflowchart -variable!

Help me Please!

Mischa





  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: typecasting the AxControl-Value in Delphi
Reply #1 - Mar 13th, 2008 at 8:04pm
Print Post  
I will have to install Delphi to try that. Does the Turbo Delphi for Win32 edition come with ActiveX support?

Stoyan
  
Back to top
 
IP Logged
 
Mischa
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Feb 13th, 2008
Re: typecasting the AxControl-Value in Delphi
Reply #2 - Mar 14th, 2008 at 9:55am
Print Post  
no it does not support third-party-components!!! ???
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: typecasting the AxControl-Value in Delphi
Reply #3 - Mar 14th, 2008 at 10:15am
Print Post  
It is a pity. Well then, I am installing their RAD Studio trial version.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: typecasting the AxControl-Value in Delphi
Reply #4 - Mar 14th, 2008 at 12:40pm
Print Post  
This works fine:

Code
Select All
procedure TForm1.Button1Click(Sender: TObject);
var b: box;
	fc: IFlowChart;
begin
	b := FlowChart1.CreateBox(10, 10, 100, 100);
	b.Style :=bsAxControl;
	b.AxControlId:='MindFusion.FlowChartPro.4.1';
	fc := b.AxRawPtr as IFlowChart;
	fc.CreateBox(10, 10, 30, 30);
end;
 



Typecasting does not work, because the flowchart's COM object is not an instance of the TFlowChart class. TFlowChart derives from the TOleControl and TWinControl classes, which in addition to wrapping a COM pointer, also provide various other members used to integrate a control into a VCL form.

From what I can grasp from the code generated by Delphi, it seems that TFlowChart just implements the IFlowChart API, and the members you would call through TFlowChart are exactly the same as the ones you get through IFlowChart.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Mischa
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Feb 13th, 2008
Re: typecasting the AxControl-Value in Delphi
Reply #5 - Mar 14th, 2008 at 1:49pm
Print Post  
You are so fast!!! Only FlowchartX is faster then you Smiley

It helps a little bit:

IFlowchart does not contain a member named Width

IFlowchart does not contain a member named height

IFlowchart does not contain a member named free

IFlowchart does not contain a member named create

IFlowchart does not contain a member named ONboxclicked, On Arrowclicked and every else event

IFlowchart does not contain a member named Parent

IFlowchart does not contain a member named ParentWindow

IFlowchart does not contain a member named Align

is it possible to get the Tflowchart-Variable???
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: typecasting the AxControl-Value in Delphi
Reply #6 - Mar 14th, 2008 at 2:11pm
Print Post  
8) Width, Height, Parent, Align etc. have sense only when a TFlowChart is a child of a VCL form or control. Now that the flowchart is inside a box, you can control its size and location by means of the respective Box methods. I will check how you can attach events to the hosted flowchart.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: typecasting the AxControl-Value in Delphi
Reply #7 - Mar 18th, 2008 at 3:52pm
Print Post  
From what I read in the Delphi help, importing using the "import type library" command should create a TOleServer-derived class that wraps the events and methods of any COM object. Then you could use the TOleServer.Connect method to connect the Delphi object to the COM object interface pointer (the hosted flowchart in our instance). However I cannot make Delphi generate a TOleServer wrapper for the IFlowchart interface - the result is always a TOleControl-derived class.

Do you know of any tool or option of the Delphi IDE that will let you import an ActiveX control as a TOleServer? Another option is to copy the TFlowChart code to another class, rename it to TFlowChartWrapper, and modify it so that it derives from TOleServer and not from TOleControl. Then the TFlowChartWrapper should let you connect to the hosted flowchart and handle its events.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint