0

I have a GIF animation here with a transparent background, which will appear every time the user clicks. The GIF animation is a simple PictureBox object.

The GIF animation with a transparent background, which appears every time the user clicks. The animation plays a simple red ripple

My concern here is that the background of the GIF animation shows the background of the Form Window, which covers the buttons here:

Image #1: "Transparent background" of GIF animation appears over the buttons.

Image #2: "Transparent background" of GIF animation appears over the green panel.

I understand that the "transparent background" of the GIF animation is actually the background of the Form Window.

How is it possible to show the GIF animation with a transparent background over the displayed buttons only?

You can check out the flow of my Windows Form here: https://youtu.be/FBuom68dKv4

  • If the PBox is __nested__ in __one__ container and has a `BackColor.Transparent` it should work fine. It does here. If it sits on a non-container, like another PBox or a Button you need to code the nesting like so: `youGifPBox.Parent = someButton; youGifPBox.Location = ... ` – TaW Sep 02 '20 at 12:07
  • The linke duplicate seems to not really meet this post's issues. I see no overlapping here. The answers are also not really good as they do not explain the rules fully.. - Not, of course, is it possible to simply draw animated gifs.. – TaW Sep 02 '20 at 12:16
  • Does that mean I can use a Panel and place the PictureBox inside the said Panel? – FrogRammer658 Sep 02 '20 at 12:19
  • Like what containers? – FrogRammer658 Sep 02 '20 at 12:25
  • As long as the PBox sits on only ONE other control it will work. Panels (and GroupBoxes and then some..) are containers and placing a control onto them will nest the automatically. Button, PBoxes and most other Controls and not containers. You still can nest into them by setting the `Parent` or by doing a `ctl1.Controls.Add(ctl2)` - Did you set the PBox.BackColor correctly? This is the 1st thing you need to get right! – TaW Sep 02 '20 at 12:31
  • I did set the background color of the PictureBox in the Properties tab. Must I do that in code, too? – FrogRammer658 Sep 02 '20 at 12:33
  • No, that should do. But you need to do the nesting in code, as shown in my 1st comment. Make sure the animation in nested in only one button! – TaW Sep 02 '20 at 12:37
  • I have set the background color of the GIF animation to Transparent, and I have set its parent to my Panel. Now what about the Panel? Does it need to have a transparent background color, too? What about the Panel's location and size? – FrogRammer658 Sep 02 '20 at 12:42
  • No need for the extra panel, really. Just do the nesting, including setting the Location, relative to the Button! Example: `pictureBox3.Parent = button13; pictureBox3.Location = new Point(11,11);` - The extra Panel doesn't help as it too would have to be nested in the button.. – TaW Sep 02 '20 at 12:53
  • I think I can handle here. Thank you. – FrogRammer658 Sep 02 '20 at 13:25

0 Answers0