Creating own buttons

Hi

I am in the middle of making a slot machine and I have realized that I want to make some round or oval buttons.  I want to make them myself without using a third party ocx control.  So far I put a picturebox on a form and have used the following code to make a circle

Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.DrawWidth = 26
Picture1.PSet (200, 200), vbBlue
End Sub


Now I need to get my program to somehow detect when only the blue circle in the picturebox has been clicked and not the other parts of the picturebox.  Is this possible?  or is there a better and easier solution.

Any help would be gratefully accepted...
LVL 3
SirNickAsked:
Who is Participating?
 
priya_pbkConnect With a Mentor Commented:
or can be,

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Picture1.Point(X, Y) = vbBlue Then
       'the necessary code goes her
   End If

'else you dont have to do anything

End Sub

0
 
priya_pbkCommented:
Crop-up the border of the Picturebox in such a way that the circle or oval fits exactly in the PictureBox. Then select the BorderStyle of the picture1 as 0-None.

When you run the program, the user will only click the circle/oval which he sees.(Just a workaround)

I hope this helps!
-priya

0
 
priya_pbkCommented:
Also you can put an "Image control" on the form and set the picture property of the image control to an image ie a gif or a jpeg file(ie any picture file, here i guess a big round or oval Picture file).

Then you can write your code at the Image1_click() event..just another work around..

-priya
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
TimCotteeCommented:
If you combine that with the following:

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Picture1.Point(X, Y) <> vbBlue Then
        MsgBox "in the picture but not on the button"
    Else
        MsgBox "Direct Hit"
    End If
End Sub

Instead of the Click event you can be sure that they clicked on your button rather than just somewhere in the region of the picture box.
0
 
SirNickAuthor Commented:
Thank you both for your input, TimCottee I have given the points to priya pbk because I actually used his last comment in my program, but thank you for your comment.
0
 
priya_pbkCommented:
I think TimCottee deserved the points, cos it was a better logic to write the code in Picture1_MouseDown rather than the Click event..what say?
0
 
TimCotteeCommented:
It was 50 points x 4 = 200 I am not that worried about it. In reality all you did was a minor amendment to my suggestion but then again you offered the first part about the borderstyle etc so lets not worry too much about it this time.
0
 
priya_pbkCommented:
thanks Tim!
0
All Courses

From novice to tech pro — start learning today.