How can I make a control transparently overlay a DirectShow video?
I have a control, VideoControl, which displays video using DirectShow - it's set as the owner of an IVideoWindow. I have another control, AreaControl, which is supposed to show a dashed rectangle over the video control. AreaControl is set to be transparent using SetStyle(ControlStyles.SupportsTransparentBackColor, true). If I place AreaControl over any other control, it works as expected, showing a dashed rectangle over the controls behind it. But when I place the dashed rectangle control over the video control, the AreaControl is filled in with the VideoControl's BackColor.
What do I need to do to get the video to display through the AreaControl, with the dashed rectangle overlaid on it? Is there a way to get the VideoControl to paint itself with the video, rather than just drawing its BackColor?
As far as I know, there is no way of doing, what you want to do directly. The problem is, the implementation of the transparent style of a control. A control with this style attribute basically just draws, what is behind it making it appear transparent. (In reality it isn't really transparent at all).
The only solution that comes to my mind is to use a window (Form) and put the control in that. A Form can be made transparent by setting its Opacity property to something less than 1.0. A value of 0.0 will be totally transparent (read: Invisible). The dashed border should be totally black. With a opacity of f.e. 0.4 it will appear gray.
Alternatively, you may have some luck with TransparencyKey Property of the Form. Setting this to white may have the desired effect, but I haven't tested this one.
In either case the Form should be completely borderless. You may have to add some code to reposition the form, when the video form moves.
In the end the answer to this turned out to be to use the AreaControl's Region property, since we didn't need partial transparency.