How do I create transparent labels over a Video control
Asked Answered
J

2

6

I'm pretty much out of ideas here... for everything else, setting the background color to Color.Transparent or setting the TransparencyKey works fine...

I have an mp4 Video which I need to play as a "background" of my form. To do this, I'm currently using the WMP control. My problem: I can't add any controls on top of it, since they always render a background. Which looks ** on the video...

Any suggestions?

Jara answered 31/10, 2011 at 14:26 Comment(1)
Tried Windows Forms and VB.net projects...Jara
D
1

Try rendering your labels using GDI+:

You can see sample here: (the Using GDI+ for drawing images with transparency part): http://www.broculos.net/en/article/how-use-transparent-images-and-labels-windows-forms

Dirk answered 31/10, 2011 at 14:41 Comment(3)
This will not work because the controls still have to be in a container which will render an opaque background.Country
Just found this: #7332601 dunno if it's any help.Dirk
Doesn't work for this case. It seems that the video rendering blocks out whatever was rendered before. I'm probably better off looking into alternatives to render the video and Text on top of it...Jara
C
6

A hack I've used successfully in a similar situation:

  • Create a separate, borderless, transparent form (transparency works best at the Form level)
  • Host button controls on that form
  • Launch the control form when your video form launches
  • Wire event handling such that the floating form always moves, resizes etc. whenever the main form changes
  • Calculate position of the floating for based on parent form's specs
  • Always push the floating form to the top, above the parent form

Told you it was a hack. But if you get all the events and calculations wired up it should work fine.

P.S. I also recall having to do a poll timer with a function that made sure every 250 millis or so that the Z-order of the two forms was what you wanted. (Switching apps and windows changed the z-order unexpectedly and w/o events, thus the polling solution.)

P.S. II It is very easy to prototype the feasibility of this solution. Just create a separate app with the above-mentioned specs and move it over your video. (You will need to retain the Form border to be able to move/resize the window easily.)

Country answered 31/10, 2011 at 14:40 Comment(1)
Totally going to use this! Sometimes you gotta do what you gotta do.Intercommunicate
D
1

Try rendering your labels using GDI+:

You can see sample here: (the Using GDI+ for drawing images with transparency part): http://www.broculos.net/en/article/how-use-transparent-images-and-labels-windows-forms

Dirk answered 31/10, 2011 at 14:41 Comment(3)
This will not work because the controls still have to be in a container which will render an opaque background.Country
Just found this: #7332601 dunno if it's any help.Dirk
Doesn't work for this case. It seems that the video rendering blocks out whatever was rendered before. I'm probably better off looking into alternatives to render the video and Text on top of it...Jara

© 2022 - 2024 — McMap. All rights reserved.