0

In my vb.net program, I would like to display an image with alpha channel that makes the window partially transparent.

My goal is to create a window with a custom title bar with custom buttons(which I've done already), but doing this by setting the "FormBorderStyle" property to "None" removes all window decorations from Windows. This removes the shadow and I would like to bring that back, with that shadow being the sort of "touch target" for resizing the window.

I've tried using the TransparencyKey property but it creates this ugly outline for every pixel that has an alpha value other than 0 and 255.

What happens with the TransparencyKey property:

What happens with the TransparencyKey property

What I would like is rather something like this:

What I would like to happen, with no ugly outline

Is it even possible to do this?

Any help is appreciated! Thank you!

  • https://stackoverflow.com/questions/26871869/per-pixel-alpha-blend – Hans Passant Apr 29 '23 at 11:31
  • [Form's TransparencyKey leaves ghastly colored edging](https://stackoverflow.com/a/60688580/7444103) -- Still using per-pixel-alpha blending, VB.Net code – Jimi Apr 29 '23 at 12:18
  • Please remove the vb.net tag. because this question applies generally to Windows Forms and is language-independent. – Quirin F. Schroll Apr 29 '23 at 14:39
  • Thank you for giving me a vb.net version of the code, which I've already found but only for C#. What I'm trying to do now is to create a shadow for an existing window. However this solution creates another window and hides anything else I put in the designer as well as everything I try to add manually in the code (declare a new panel for instance). Is there a way to do that? – La Mayenne Apr 29 '23 at 15:31
  • That's how alpha blending works. You cannot show any Control on that Form when its surface is rendered like that. There are other ways, but you may want to use a WPF Window instead. That kind of transparency is achieved setting a single property (and of course you can add UI elements to the Window) – Jimi Apr 29 '23 at 16:45

0 Answers0