Control to make the control (such as a panel) transparent when you add a GIF picture to it and use double buffering to make it blink and the background is GIF

Source: Internet
Author: User

Image img = image.fromfile (@ "C:\Users\joeymary\Desktop\3.gif");
pictureBox1.Image =img. Clone () as Image;
Label1. Image = img. Clone () as Image;
Label1. Size = img. Size;
Img. Dispose ();

Label and PictureBox can be used in both.

Because the form redraw causes the control to blink

Method One:

<summary>
Rewrite the CreateParams property of the form to buffer the control two times (double buffer)
</summary>
protected override CreateParams createparams//! I can't believe it's not flashing.
{
Get
{
CreateParams CP = base. CreateParams;
Cp. ExStyle |= 0x02000000;
return CP;
}
}

The second method is to set the control's DoubleBuffered property, and you need to be aware that this property is private and that you need to use reflection to set this property.

This method has not been tried, after all, look dizzy

Public Static void Setdoublebuffered(System.Windows.Forms.ControlC){ Please refer to the blog below Http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx If (System.Windows.Forms.SystemInformation.Terminalserversession) Return; System.Reflection.PropertyInfoAprop= typeof(System.Windows.Forms.Control).GetProperty( "DoubleBuffered", System.  Reflection.  BindingFlags.  NonPublic |  System.  Reflection.  BindingFlags.  Instance); aprop.  SetValue(c, true, null);  }< /c14> 

This.panel1.BackColor = color.transparent;//Panel is set to transparent
This.panel1.Parent = this.picturebox1;//Sets the panel parent control as a background picture control
This.panel1.BringToFront ();//Put panel in front

Control to make the control (such as a panel) transparent when you add a GIF picture to it and use double buffering to make it blink and the background is GIF

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.