Solved

Creating own buttons

Posted on 2002-05-23
8
175 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

803 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