Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Possible to inherit (Read 3673 times)
foucault
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Apr 16th, 2007
Possible to inherit
Apr 17th, 2007 at 9:59am
Print Post  
I would like to know if it's possible to create my own box class by inheriting your's? I would like to add some attributes and methods.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Possible to inherit
Reply #1 - Apr 17th, 2007 at 1:29pm
Print Post  
It is possible; you can use the FlowChart.Add method to add instances of the inherited class. You might also need to use a custom Behavior class if you need to let users draw objects from your class.

It is hard to implement serialization - you will also need to inherit the FlowChart class to allow for serializing the custom objects. And currently it is impossible to implement undo/redo of custom properties because some undo-related methods are internal.

For now it is easier to define additional Serializable class, e.g. BoxProperties and assign its instances to the Tag of standard boxes. We are currently implementing a more straightforward way to inherit the standard node classes in Flowchart.NET version 5.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Possible to inherit
Reply #2 - Apr 17th, 2007 at 6:45pm
Print Post  
I haven't noticed this is in the FlowchartX forum. Unfortunately you can't inherit classes in the ActiveX version. The best method to add your properties to a box is to create a serializable COM class with the additional properties and assign its instance to the Box.VariantTag.

Stoyan
  
Back to top
 
IP Logged
 
foucault
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Apr 16th, 2007
Re: Possible to inherit
Reply #3 - Apr 18th, 2007 at 5:16am
Print Post  
Stoyo wrote on Apr 17th, 2007 at 6:45pm:
The best method to add your properties to a box is to create a serializable COM class with the additional properties and assign its instance to the Box.VariantTag.



It's sounds easy when you say it Smiley
Is it possible to be a little bit more accurate?
What I understood is that I have to implement a Variant Structure (where? what does it look like?) and a serializable COM class (same questions...).
The objective of this is to create a type of box with added information like reference to others nodes, or picture reference, etc.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Possible to inherit
Reply #4 - Apr 18th, 2007 at 6:31am
Print Post  
Smiley You can assign to VariantTag anything that can be stored in an OLE VARIANT structure, including COM objects. So you can create a custom COM class that

- implements the standard IPersistStreamInit interface;
- add your additional properties to it;
- implement serialization using the IStreams passed to the IPersistStreamInit methods.

I can give you some examples in C++ or VB.

And since you use this in IE, you must add the dll that implements the COM object to the downloadable CAB file. We build our CAB using the VB6 Package and Deployment wizard. I can send you the wizard's project file if you wish.

Stoyan
  
Back to top
 
IP Logged
 
foucault
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Apr 16th, 2007
Re: Possible to inherit
Reply #5 - Apr 18th, 2007 at 10:36am
Print Post  
Some examples in VB and the wizard's project would be great Smiley
Thx
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Possible to inherit
Reply #6 - Apr 18th, 2007 at 11:30am
Print Post  
Ok,

- create a new ActiveX dll project in VB
- rename the Class1 class to MyProperties
- set the class Persistable attribute in the property browser to "1 - Persistable"
- add some properties
- select "Class" from the top-left combo box in the source code window
- select ReadProperties and WriteProperties from the top-right combo
- implement the serializaton of properties through the PropertyBag passed above

The end result should look like

Code
Select All
'local variable(s) to hold property value(s)
Private mvarStringProperty As String 'local copy
Private mvarPictureProperty As StdPicture 'local copy

Public Property Set PictureProperty(ByVal vData As StdPicture)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.PictureProperty = Form1
    Set mvarPictureProperty = vData
End Property

Public Property Get PictureProperty() As StdPicture
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.PictureProperty
    Set PictureProperty = mvarPictureProperty
End Property

Public Property Let StringProperty(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.StringProperty = 5
    mvarStringProperty = vData
End Property

Public Property Get StringProperty() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.StringProperty
    StringProperty = mvarStringProperty
End Property

Private Sub Class_Initialize()
    StringProperty = ""
    Set PictureProperty = Nothing
End Sub

Private Sub Class_ReadProperties(PropBag As PropertyBag)
    StringProperty = PropBag.ReadProperty("String")
    Set PictureProperty = PropBag.ReadProperty("Picture")
End Sub

Private Sub Class_WriteProperties(PropBag As PropertyBag)
    PropBag.WriteProperty "String", StringProperty
    PropBag.WriteProperty "Picture", PictureProperty
End Sub
 



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Possible to inherit
Reply #7 - Apr 18th, 2007 at 11:36am
Print Post  
This is the CAB project:
https://www.mindfusion.org/_samples/cab.zip

Add an entry for your dll into the INF file to add it to the CAB. You must also edit the BAT file to set the correct path to the CAB compiler on your system. Now run the bat file, and you will get a CAB that installs both FlowchartX and your COM class.

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