I want to create a round button. How do I do this?
Printable View
I want to create a round button. How do I do this?
By inserting your code into the Click() event of an ImageBox, you can make it act like a Button.
Are you saying I have to manually code the simulation of a button by using images and add the button properties. I want to have this as a seperate activeX control.
put this code in your usercontrol
Code:Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As Long) As Long
Private Sub UserControl_Resize()
Dim rcWindowSize As RECT
'check the window is square
If Not (UserControl.Width = UserControl.Height) Then
UserControl.Height = UserControl.Width
Exit Sub
End If
'get the window rectangle
Call GetWindowRect(UserControl.hwnd, rcWindowSize)
'convert to usercontrol coords
'Top Left Corner
Call ScreenToClient(UserControl.hwnd, rcWindowSize.Left)
'Bottom right corner
Call ScreenToClient(UserControl.hwnd, rcWindowSize.Right)
'Make the window an ellipse
Call SetWindowRgn(UserControl.hwnd, CreateEllipticRgn(rcWindowSize.Left, rcWindowSize.Top, rcWindowSize.Bottom, rcWindowSize.Right), True)
End Sub
I get the odd control sent to me to review....caren't remember why this is the case....but anyway have one for what you want called "npbutton".
So all you have to do is register the control, and then use it rather than the standard command button. Drop me a line at [email protected] if you want the control. Am out of the office for a few days but will send it to you if you want when l get back.
why do you want to use a control?
just use sams code on a normal command button, then there is nothing you need to register.
The control might have more features than that code. (Of course you can manipulate it to suit your standards but all that depends on the person)
using a custom controls would be easier, especially as a command button would look pretty terrible if it was just made round, it avoids all of that, although If you use the activeX control Interface wizard (comes as an addin with VB6) then you can get most of the work done for you making your own control, plus you can customize it to look however you want it to look.
Dennis
Using code or a third party tool is really up to the individual and their time constraints. For example we have just finished putting together a small package which automatically emails purchase orders to suppliers, we could have spent a couple of weeks developing our own tool, then a few weeks testing it, followed by the end user also testing it under business conditions. But we had a time constraint so brought a third party control which only took a couple of hours to hookup and test.
If you have time on your hands you can develop all aspects of a project, if you don't, third party controls can reduce the project life cycle.
With the round button thing, it's a nice control with a lot of features which has clearly taken some time to develop. Why would l want to spend the time reproducing it. Am currently spending all spare time developing some business graphics controls, cos we caren't locate what we want, and it's a fun project.