在表单上创建透明矩形

时间:2012-02-07 23:47:20

标签: vb.net directx

嘿所有我有这个代码,希望在我的表单上覆盖一个透明的矩形。程序是我不知道应该将“e”设置/定义为:

 e.Graphics.FillRectangle(color.fromargb(127.5,255,255,255), New Rectangle(0, 0, 100, 100))

任何帮助都会很棒!

大卫

更新

  ' Create solid brush.
    Dim blueBrush As New SolidBrush(Color.Blue)

    ' Create location and size of rectangle.
    Dim x As Single = 0.0F
    Dim y As Single = 0.0F
    Dim width As Single = 200.0F
    Dim height As Single = 200.0F
    ' Fill rectangle to screen.
    e.Graphics.FillRectangle(blueBrush, x, y, width, height)

2 个答案:

答案 0 :(得分:2)

您需要在表单的OnPaint方法中实现该代码。 e的类型为PaintEventArgs

答案 1 :(得分:1)

e表示作为参数传递给Paint事件处理程序的PaintEventAgrs:

Graphics.FillRectangle Method (Brush, Rectangle)