Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27072

draw a semi transparent rectangle over image box

$
0
0
i have made my own image box class

all is working fine but i am attempting to draw a black rectangle over the image box and set the alpha to make it semi transparent to give a diming kind of effect.

this is what i have tried.
Quote:

" IN THE PAINT EVENT "
THE CLASS
Code:


Public Class imageholder


    Inherits Windows.Forms.PictureBox

    Public Sub New()

        Me.Size = New Size(146, 113)
        Me.Location = New Point(100, 100)
        Me.SizeMode = PictureBoxSizeMode.CenterImage
        Me.BackgroundImage = My.Resources.bg_imagecase_fw
        Me.SizeMode = PictureBoxSizeMode.CenterImage
        Me.Padding = New Padding(10, 10, 10, 30)

    End Sub

    Private Sub imageholder_Paint(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Paint

        Dim g As Graphics = Me.CreateGraphics()
        Dim brder As New Pen(Color.Blue)

        Dim myBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Black)
        Dim formGraphics As System.Drawing.Graphics
        g.DrawLine(brder, 10, 50, 200, 50)
        formGraphics = Me.CreateGraphics()
        formGraphics.FillRectangle(myBrush, New Rectangle(0, 0, 200, 300))

        'formGraphics.CompositingQuality = CompositingQuality.GammaCorrected
        formGraphics.FillEllipse(myBrush, 40, 90, 86, 30)
        myBrush.Dispose()
        formGraphics.Dispose()

    End Sub

    Private Sub imageholder_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter

        Me.BackgroundImage = My.Resources.bg_imagecaseHOVER1122dddfgfgfgfgdd_fw

    End Sub

    Private Sub imageholder_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave

        Me.BackgroundImage = My.Resources.bg_imagecase_fw

    End Sub

End Class

this draws the rectangle over the imagebox just fine but its 100% solid in colour so all you can see is a black box.

any help would be greatly appreciated.

Viewing all articles
Browse latest Browse all 27072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>