mercredi 16 avril 2014

Contrôle de c# COM dans VB6 : faire un conteneur hors du contrôle - Stack Overflow


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.



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.


0 commentaires:

Enregistrer un commentaire