2011-06-16 47 views
0

在窗體上繪製圖像我試圖在所有其他控件的窗體上繪製圖像。 我試圖製作一個透明面板infront的控件,但它只顯示背景和控件不顯示。 我的代碼是:(我使用它來淡化效果)使用Graphics.DrawImage()

Player1ColorMatrix.Matrix33 = Player1Transparency; 

Player1ImageAttributes.SetColorMatrix(Player1ColorMatrix, 
        ColorMatrixFlag.Default, 
        ColorAdjustType.Bitmap); 

    e.Graphics.DrawImage(Player1ScoreImage, Player1rect, 0, 0, 200, 62, GraphicsUnit.Pixel, Player1ImageAttributes); 
    Player1Transparency = 0.0f; 

player1scoreimage是圖像和player1rect是我要畫的圖像

如何使矩形這個圖像是在其他控件的前面?

感謝, 奧菲爾

+0

爲什麼你不能使用Image控件? – jv42 2011-06-16 14:14:21

回答

1

使用一個自定義面板嘗試:

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); 
    } 
    } 
} 
相關問題