Results 1 to 2 of 2
  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012

    Resolved [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?

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2012

    Re: Noob question on custom interface

    Never mind, got it.

    vb.net Code:
    1. Class Form1
    2.     Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    3.         Dim testButton As New Button
    4.         testButton.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(0)
    5.         tesButtont.FlatAppearance.BorderSize = 0
    6.         testButton.FlatAppearance.MouseDownBackColor = Color.Transparent
    7.         testButton.FlatAppearance.MouseOverBackColor = Color.Transparent
    8.         testButton.FlatStyle = FlatStyle.Flat
    9.         testButton.BackColor = Color.Transparent
    10.         testButton.AutoSize = False
    11.         Me.imgBackground = New Bitmap("../../Doodley.bmp")
    12.         imgBackground.MakeTransparent()
    13.         testButton.Size = imgBackground.Size
    14.         testButton.BackgroundImage = imgBackground
    15.         testButton.Location = New Point(50, 100)
    16.         AddHandler test.Click, AddressOf testButton_Click
    17.         Me.Controls.Add(test)
    18.     End Sub
    20.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)
    21.         MessageBox.Show("Button1 was clicked!")
    22.     End Sub
    23. 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


Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.