Really Transparent Controls needed.

No, I tried that. It is not my own control who is earsing itself in the paint method. It is the parent control who does. I cant do the double buffering, because I dont have access to the parent control surface. In fact, I think I started this thread for my own ignorance (I saw what I think now could possibly be a bug:
When I hide the window (not minimize, not covering with another window, but moving the control off-screen and then moving it back in quickly), I get the desired effect on some random regions of the control. On the rest of the control, I either get the same black or grey background, or the form background, whatever is behind the form (usually a piece of the VS.NET IDE).
and I was trying to reproduce it as it was nearly the desired effect)

The 0x20 style was actually the answer to my question - though not the solution to my problem. If the parent paints in its onpaint event, it does exactly what I what it to do. In my case, though, DirectX handles the painting and my app never knows about it. I guess Ill have to keep digging on how to use DirectShows Overlay Mixer from C#, but that should go in the DirectX section.

If any of you have done that/have any ide about how to do it, please let me know! (wrappers, code, etc). If not - it is not urgent now, ill keep exploring, and Ill post here if and when I solve it.

Thanks for the help. I learned a lot in this thread.
 
Can I understand what you mean by that

You say you move it over then back but then say if I hide the window.

I dont understand. You mean dragging a control by the mouse or programmatically. Do you mean hide with the method or maybe I just dont get it. This is interesting and if I understand it more I can help.

if possible a sample app so I can physically see the issue or a code sample would be nice.

nick
 
Sorry, nick, my fault. My english is not as good as it should. I didnt express myself well enough.

I have (had) the window playing the video, with the transparent controls on it - only they werent transparent at all. (by transparent I mean, with the transparent styles set, and doing nothing but painting a line on my onpaint). Then I moved the window out of the screen, and moved it back in (with the mouse, manually, dragging it), and surprise! the control was transparent now.

I tried that on another computer, and it didnt become transparent. A weird bug in my computer, I guess.

Let me dig up some code - if I find wich N in ApplicationN is the one, Ill post it.
 
Code

I didnt find my old code, but I managed to reproduce it... it has the same effect now:

This is the transparent control (I want it to look like just a diagonal static line, and I want the rest to be invisible)
Code:
	class Transpanel : UserControl 
	{
		public Transpanel():base()
		{
			this.SetStyle(ControlStyles.SupportsTransparentBackColor,true);
			this.SetStyle(ControlStyles.UserPaint,true);
			this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
			this.BackColor=Color.Transparent;
		}
		protected override void OnPaint(PaintEventArgs e) 
		{
			e.Graphics.DrawLine(Pens.Red,0,0,this.Width,this.Height);
		}
		protected override void OnPaintBackground(PaintEventArgs e) 
		{
//Do nothing
		}
	}

This works with static background, or when the background is updated on the onpaint. Usually thats how it happens - but in my case, Im calling it from:

Code:
	public class Form1 : System.Windows.Forms.Form
	{
		private UserControl panel1;
		private System.ComponentModel.Container components = null;

		public Form1()
		{

			InitializeComponent();
            this.panel1.BackColor=Color.Transparent;
			Video v = new Video("c:\\videos\\prueba7.avi");
			v.Owner=this;
			v.Play();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.panel1 = new Transpanel();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Location = new System.Drawing.Point(48, 32);
			this.panel1.Name = "panel1";
			this.panel1.TabIndex = 0;
			this.panel1.Height=20;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 273);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.panel1});
			this.Name = "Form1";
			this.Text = "Form1";
			this.ResumeLayout(false);

		}
		#endregion

		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
	}

I run this, and I dont get the control transparent (red line on a grey box on a moving video), wich has a lot of sense. I move it out of the screen and back in (mouse drag and drop) and it becomes transparent (I see the red line on top of the moving video)

I havent been able to reproduce it on another computer, but thats the effect I was looking for. Im sure now, however, that it was a bug (but if it happened as a bug, perhaps there is a way to make it happen for real)

Sorry for posting the whole code. I just wanted to make sure no one reading this would miss anything.

Isilrion.
 
Back
Top