i'm trying to draw an image on a form in front of all the other controls. i tried to make a transparent panel infront of the controls but it only shows the background and the controls are not shown. my code is that : (i'm using it to make a fading effect)
Player1ColorMatrix.Matrix33 = Player1Transparency;
Player1ImageAttributes.SetColorMatrix(Player1ColorMatrix,
ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
e.Graphics.DrawImage(Player1ScoreIma开发者_如何学Cge, Player1rect, 0, 0, 200, 62, GraphicsUnit.Pixel, Player1ImageAttributes);
Player1Transparency = 0.0f;
player1scoreimage is the image and player1rect is the rectangle in which i want to paint the image
how do i make this image to be in front of the other controls?
thanks, ofir
Try using a custom panel for that:
private class PanelX : Panel
{
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20;
return cp;
}
}
protected override void OnPaint(PaintEventArgs e)
{
using (SolidBrush brush = new SolidBrush(Color.FromArgb(128, 0, 0, 0)))
{
e.Graphics.FillRectangle(brush, this.ClientRectangle);
}
}
}
精彩评论