-
Apr 9th, 2012, 08:59 AM
#1
Thread Starter
New Member
[RESOLVED] Noob question on custom interface
I'm trying to get a button that filters out clicks based on transparency mask of a background image.
E.g. when I set FormBorderStyle to (none) and TransparencyKey to MyFormImage.GetPixel(0,0), then make a button with no border and a background image that uses the same transparency mask, I get the behavior that I want on the button, but it also punches a square hole in the form - not what I want.
Moreover, by using .maketransparent on the button image, I get the look, but not the behavior - same as clicking in a rectangular region.
Is there a simple way to make this work?
Any manual alternatives are looking rather involved if I happen to have multiple or overlapping buttons.
If not, can I turn off the border that appears around the button region during a click action?
-
Apr 9th, 2012, 10:18 AM
#2
Thread Starter
New Member
Re: Noob question on custom interface
Never mind, got it.
vb.net Code:
Class Form1
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim testButton As New Button
testButton.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(0)
tesButtont.FlatAppearance.BorderSize = 0
testButton.FlatAppearance.MouseDownBackColor = Color.Transparent
testButton.FlatAppearance.MouseOverBackColor = Color.Transparent
testButton.FlatStyle = FlatStyle.Flat
testButton.BackColor = Color.Transparent
testButton.AutoSize = False
Me.imgBackground = New Bitmap("../../Doodley.bmp")
imgBackground.MakeTransparent()
testButton.Size = imgBackground.Size
testButton.BackgroundImage = imgBackground
testButton.Location = New Point(50, 100)
AddHandler test.Click, AddressOf testButton_Click
Me.Controls.Add(test)
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)
MessageBox.Show("Button1 was clicked!")
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|