I have spent the last day or so writing a simple control library in VB.NET to be used in an existing vb6 project. I have most things working; my controls show up in the vb6 toolbox, events work, etc. My current problem is trying to deal with passing complex objects between vb6 and .NET.
For example, the Font property of a .NET TextBox. Now, vb6 uses stdFont objects and .NET (obviously) uses the System.Drawing.Font type. My goal with this project is to make the change transparent from the vb6 side. I would like to completely emulate the vb6 interface for each control to minimize the code that needs to change when we add the new controls in, but I am stuck here. Here is an example (.NET):
Public Overloads Property Font() As stdole.StdFont
Get
Return ???
End Get
Set(ByVal value As stdole.StdFont)
Dim style As FontStyle = GetFontStyle(value)
TextBox1.Font = New Font(value.Name, value.Size, style, GraphicsUnit.Pixel, value.Charset)
End Set
End Property
As you can see, the 'getter' is the problem. How can I mimic the vb6 interface here if I cannot return the textbox's Font property? I don't want to return a stdFont copy of the System.Drawing.Font for obvious reasons.
Now, I could just add methods like SetBold(), SetItalic(), and SetFont() (or boolean properties like "FontIsBold"), but this is exactly what I am trying to avoid. My interop experience is fairly minimal, so any help here would be appreciated.