SirNick
asked on
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...
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...
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
Then you can write your code at the Image1_click() event..just another work around..
-priya
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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?
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.
thanks Tim!
When you run the program, the user will only click the circle/oval which he sees.(Just a workaround)
I hope this helps!
-priya