creating custon buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

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
 
sorry, im a new programmer.....do u have any sample code or kno anywhere i
could find some?
 
i can create buttons easily from within my forms class, now i want to create
custom ones
 
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
 
sorry, i did see the code but i didnt kno how to use it with a form, thanks a
ton for that!
 
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
 
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
 
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)
 
iwdu15 said:
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top