Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm using direct show to capture video the problem that I faced that I have to to put a picturebox over the picturebox which displays the live video (call it camerabox). I tried to make the picturebox background transparent and the camerabox the parent of the picture box but when I run the code the picturebox disappeared. Also, I tried to make a custom control and override the background to make it transparent but when I run the code I found that I have to refresh the form with a timer. When I refreshed with a timer the customcontrol disappears and appear (make like flashes).
I don't know what to do. My question is there any way to make a transparent picturebox over the camerabox(the picturebox that displays the live video) ???
Updated 18-Apr-13 13:23pm
Thomas Barbare 19-Apr-13 1:46am    
Little question, why do you need two pictureBox ?

1 solution

You really can't do that. Controls in Windows Forms are never really transparent. The Transparent color only tells the control that it should take on the background properties of the control that is hosting it, giving the ILLUSION of transparency.

The problem with this is that even though you can see the background of the form your control is sitting on, you cannot see any controls that sit between your control and the form. This is because when a control is placed on the form it OWNS all of the pixels that the control is drawn in. Any controls that sit behind your control do not paint themselves in those pixels, therefor, there's no control there for you to see through your control.

You cannot use a control to do this. You either have to custom paint the overlay yourself or scrap Windows Forms and switch to WPF, where this is much easier to do.

Custom painting will also be very difficult to pull off because you have to constantly repaint your overlay in between frames of the video. Don't even begin to think there will be a tutorial for this.
Share this answer
Haytham.Breaka 18-Apr-13 21:37pm    
Can I use WPF with winforms to solve this problem?
Dave Kreskowiak 19-Apr-13 8:20am    
Sure. You better trying hosting the basic controls before you take on something more complex like this. Then you need to do some research into a video overlay in WPF. 18-Apr-13 23:52pm    
I think you need to import some dll for transparency... found some of it on youtube

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900