Solved

Creating own buttons

Posted on 2002-05-23
8
155 Views
Last Modified: 2010-05-02
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...
0
Comment
Question by:SirNick
  • 5
  • 2
8 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7029394
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
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7029404
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 7029419
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
 
LVL 2

Accepted Solution

by:
priya_pbk earned 50 total points
ID: 7029434
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 3

Author Comment

by:SirNick
ID: 7029724
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
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7031199
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 7031445
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
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7031454
thanks Tim!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now