I have a c# control that I use inside of VB6, which is basically a panel with rounded corners. I'd like to know if there is a way to make that control a container, sort of like a Frame is a container. Basically I want to be able to place things inside it so they all move together, and most importantly place things In Front of it.
Right now if I place, say, a label or a command on top of it, it goes behind my COM control and using Bring to Front
and Send to Back
does nothing.
Do I need to declare it as a container in vb6? Does the code have to come from c#?
Edit:
I have signed an NDA so I can't post the whole code here, but I'll post some and explain some.
public class AzPanel : Panel
{
protected const int BORDER_WIDTH = 3;
protected int BORDER_RADIUS = 4;
private object _lock = new object();
private bool regionNeedsRefresh = false;
public AzPanel() : base()
{
this.SetStyle(
ControlStyles.DoubleBuffer |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.Selectable, false);
base.BackColor = Color.Transparent;
this.BorderColor = Color.DarkRed;
this.ContentColor = Color.DarkGoldenrod;
this.DoubleBuffered = true;
base.Padding = new Padding(3, 3, 4, 4);
}
}
There's some other stuff to define a region with rounded corners as well, but it's basically just a panel. I have a class that extends AzPanel, AzPanelCOM with the following attributes:
[Guid("...")]
[ProgId...]
[ComVisible(true)]
[ComdefaultInterface...]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
As well as an interface, IAzPanelCOM, to expose it to VB6.
[Guid("...")]
[ComVisible(true)]
public interface IAzPanelCOM
{
void DesignTimeReload();
//some other things
}
On build I use "regasm.exe" to create a type library (tlb) that I import in VB6 on a virtual machine running Windows xp and vs2010 (.net framework 4.0).
I can then instantiate AzPanels, resize them and move them even at design time, and I can add commands (buttons) to them with no problems. When it comes to shapes or labels, however, they seem to appear behind the panel and I can't bring them to the front.
A ContainerControl represents a control that can function as a container for other controls and provides focus management. Controls that inherit from this class can track the active control they contain, even when the focus moves somewhere within a different container.
Container controls, as their name implies, are controls that can host other controls inside them. The Form is the perfect example here, as you put all your controls on the form. The host is known as the parent, and the controls inside the host are known as the children.
To add tabs to a form, you use the Tab Control tool. Each page of a tab control acts as a container for other controls, such as text boxes, combo boxes, or command buttons.
as per @MarkBertenshaw Comment
You can't use windowless controls (shape, label, et.c) with a .NET container component. However, you could use a VB windowed control, e.g. Frame (no border) or Picture Box inside the .NET component, into which you place those windowless controls
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With