Solved

Creating own buttons

Posted on 2002-05-23
8
181 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

840 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