By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,421 Members | 1,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,421 IT Pros & Developers. It's quick & easy.

creating custon buttons

P: n/a
hi, i was wondering how i could create my own buttons, like with unique
shapes and such. i kno theres a way but i dont kno how...
Nov 21 '05 #1
Share this Question
Share on Google+
13 Replies

P: n/a
iwdu

From an old message from Herfried, be aware that region only works on
24Kbits color setting and not on W98/Me.

\\\
Dim intDiameter As Integer = 300
Me.Height = intDiameter
Me.Width = intDiameter
Dim p As New Drawing2D.GraphicsPath()
p.AddEllipse(0, 0, intDiameter, intDiameter)
Me.Region = New Region(p)
Me.BackColor = Color.Red
///
I hope this helps,
Cor
Nov 21 '05 #2

P: n/a
that didnt create a button....i dunno if i explained myself rite but like,
create a button from scratch so i can use it in events and it can be any
shape and such
Nov 21 '05 #3

P: n/a
inherit the buttonbase class in a control, and if you need any standard
shapes look at the controlpaint class to draw things like 3D boarders,
glyphs (arrows, shapes, etc) that are common in windows
"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:84**********************************@microsof t.com...
that didnt create a button....i dunno if i explained myself rite but like,
create a button from scratch so i can use it in events and it can be any
shape and such

Nov 21 '05 #4

P: n/a
Iwdu15,

If you don't know how to create a button, than I would in your case wait
until that I know that very good before you start at a shaped button.

Class mybutton
inherits butoon
Public Sub New
Dim intDiameter As Integer = 300
Me.Height = intDiameter
Me.Width = intDiameter
Dim p As New Drawing2D.GraphicsPath()
p.AddEllipse(0, 0, intDiameter, intDiameter)
Me.Region = New Region(p)
Me.BackColor = Color.Red
End sub New
///

Just my idea

Cor
Nov 21 '05 #5

P: n/a
sorry, im a new programmer.....do u have any sample code or kno anywhere i
could find some?
Nov 21 '05 #6

P: n/a
i can create buttons easily from within my forms class, now i want to create
custom ones
Nov 21 '05 #7

P: n/a
Did you not see the sample that I made

However, here I made it complete in a form

\\\\
Private WithEvents butt As New mybutton
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Controls.Add(butt)
End Sub
Private Sub butt_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles butt.Click
MessageBox.Show("Hello it is red")
End Sub
End Class
Class mybutton
Inherits Button
Public Sub New()
Dim intDiameter As Integer = 30
Me.Height = intDiameter
Me.Width = intDiameter
Dim p As New Drawing2D.GraphicsPath
p.AddEllipse(0, 0, intDiameter, intDiameter)
Me.Region = New Region(p)
Me.BackColor = Color.Red
End Sub
End Class
///

I hope this helps,

Cor
Nov 21 '05 #8

P: n/a
sorry, i did see the code but i didnt kno how to use it with a form, thanks a
ton for that!
Nov 21 '05 #9

P: n/a
umm i have a problem, if i change the coordinates from "0,0" to anything
else, it wont draw it, the program runs but nothings there
Nov 21 '05 #10

P: n/a
> umm i have a problem, if i change the coordinates from "0,0" to anything
else, it wont draw it, the program runs but nothings there


Can you show how you did that, don't than expect an answer today from me,
you get that than probably tomorrow.

Cor
Nov 21 '05 #11

P: n/a
sure, heres the code that relates to it:

Class mybutton

Inherits Button

Public Sub New()

Dim intDiameter As Integer = 55
Me.Height = intDiameter
Me.Width = intDiameter
Dim p As New Drawing2D.GraphicsPath
p.AddEllipse(100, 100, intDiameter, intDiameter)
Me.Region = New Region(p)
Me.BackColor = Color.Red

End Sub
End Class

Dim WithEvents butt As New mybutton 'ive tired using "Public" also, but i
prefer using dim

Me.Controls.Add(butt)
Nov 21 '05 #12

P: n/a
iwdu15 wrote:
sure, heres the code that relates to it:

Class mybutton

Inherits Button

Public Sub New()

Dim intDiameter As Integer = 55
Me.Height = intDiameter
Me.Width = intDiameter
Dim p As New Drawing2D.GraphicsPath
p.AddEllipse(100, 100, intDiameter, intDiameter)
Me.Region = New Region(p)
Me.BackColor = Color.Red

End Sub
End Class

Dim WithEvents butt As New mybutton 'ive tired using "Public" also, but i
prefer using dim

Me.Controls.Add(butt)


You don't want to change the placement of the ellipse, since that is
drawing in relation to the button, not the form. what you told it to do
is to start drawing the ellipse 100px left of the top of the button and
100px down from the top of the button, which is probably in no man's
land as far as the button is concerned. If you want to move the button,
you need to change the button's location.

Try:
Butt.Top = 100
Butt.Left = 100
Me.Controls.Add(butt)
Nov 21 '05 #13

P: n/a
awsome!!! thanks a ton!!!!
Nov 21 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.