3
votes

So I've got this problem where I'm creating a control in c# .NET, and I can use it just fine in VB6. However, since you can't place borderless controls in .net containers in vb6, I've tried making a special .NET Label and exposing it to vb6.

I can get this label on my form just fine, but I can't make it transparent.

I have tried using UserControl_AmbientChanged but the Ambient.BackColor always seems to be the form's color, and not the actual parent's color (say, a frame). Same when I use UserControl.Parent and then the Parent's BackColor. Same with Extender.Parent. Even if that worked, it wouldn't be pretty in the case where the background is an image.

I've tried using SetWindowLong but that just makes the whole label invisible / transparent with no regards for the Caption.

I've tried using a bliting technique found here: http://www.vbforums.com/showthread.php?438895-transparent-text-box-or-label-with-scrollbars&highlight=transparent%20TextBox But this did not work as my controls are not PictureBoxes.

I'm out of option, has anyone done this before? How? Any help at all would be very appreciated.

1
Are you really creating an application written in Visual Basic 6 in 2013? I have never heard of putting C# controls within a VB6 application.Security Hound
Is there some incredibly good reason why you haven't simply ported the vb6 app to vb.net?Tony Hopkinson
@Ramhound, I work for a large Fortune 500 company, it's not that uncommon to have large-scale production enterprise VB6 applications running in those environments. In fact we have one that serves 20K+ users and millions of transactions daily. However, slowly you begin integrating a more sustainable technology.Mike Perrenoud
Enterprise VB6? Oh boy, glad I don't work there.Tony Hopkinson
@everyoneelse This is a task that was given to me during an internship, I can't really just quit, and so far I've been able to do a lot in VB6, it's just that one transparency problem. We will eventually move to an application entirely in C#, but competition is strong and evolving fast so we can't just stop everything for 2 years and start over in c#Felix

1 Answers

0
votes

If I understand your situation correctly you will want to set the .NET user control background color to something distinct (say a pink color with a specific HEX color code). Then in your VB6 application you'll set this same color code (pink) to be the transparent color within the property sheet.

I've handled transparency in VB6 user controls in this fashion for a number of years and it seems to work fine.

As for the comments regarding VB6 in 2013 for an Enterprise application, well these people obviously haven't working in the software industry for long :) VB6 has been implemented in millions of Enterprise applications that are still in use today. I would ask one question for the users that posted such comments, how can you provide the power of a VB6 ActiveX control in any other language? Answer -> You cannot.