creating custon buttons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • iwdu15

    #1

    creating custon buttons

    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...
  • Cor Ligthert [MVP]

    #2
    Re: creating custon buttons

    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.Graph icsPath()
    p.AddEllipse(0, 0, intDiameter, intDiameter)
    Me.Region = New Region(p)
    Me.BackColor = Color.Red
    ///
    I hope this helps,
    Cor


    Comment

    • iwdu15

      #3
      Re: creating custon buttons

      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

      Comment

      • Brian Henry

        #4
        Re: creating custon buttons

        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" <iwdu15@discuss ions.microsoft. com> wrote in message
        news:845D7131-5E91-4213-8B7C-840F61A64AC3@mi crosoft.com...[color=blue]
        > 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[/color]


        Comment

        • Cor Ligthert [MVP]

          #5
          Re: creating custon buttons

          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.Graph icsPath()
          p.AddEllipse(0, 0, intDiameter, intDiameter)
          Me.Region = New Region(p)
          Me.BackColor = Color.Red
          End sub New
          ///

          Just my idea

          Cor


          Comment

          • iwdu15

            #6
            Re: creating custon buttons

            sorry, im a new programmer..... do u have any sample code or kno anywhere i
            could find some?

            Comment

            • iwdu15

              #7
              Re: creating custon buttons

              i can create buttons easily from within my forms class, now i want to create
              custom ones

              Comment

              • Cor Ligthert [MVP]

                #8
                Re: creating custon buttons

                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(ByVa l sender As Object, _
                ByVal e As System.EventArg s) Handles MyBase.Load
                Me.Controls.Add (butt)
                End Sub
                Private Sub butt_Click(ByVa l sender As Object, _
                ByVal e As System.EventArg s) 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.Graph icsPath
                p.AddEllipse(0, 0, intDiameter, intDiameter)
                Me.Region = New Region(p)
                Me.BackColor = Color.Red
                End Sub
                End Class
                ///

                I hope this helps,

                Cor


                Comment

                • iwdu15

                  #9
                  Re: creating custon buttons

                  sorry, i did see the code but i didnt kno how to use it with a form, thanks a
                  ton for that!

                  Comment

                  • iwdu15

                    #10
                    Re: creating custon buttons

                    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

                    Comment

                    • Cor Ligthert [MVP]

                      #11
                      Re: creating custon buttons

                      > umm i have a problem, if i change the coordinates from "0,0" to anything[color=blue]
                      > else, it wont draw it, the program runs but nothings there[/color]

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

                      Cor


                      Comment

                      • iwdu15

                        #12
                        Re: creating custon buttons

                        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.Graph icsPath
                        p.AddEllipse(10 0, 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)

                        Comment

                        • Chris

                          #13
                          Re: creating custon buttons

                          iwdu15 wrote:[color=blue]
                          > 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.Graph icsPath
                          > p.AddEllipse(10 0, 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)[/color]

                          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)

                          Comment

                          • iwdu15

                            #14
                            Re: creating custon buttons

                            awsome!!! thanks a ton!!!!

                            Comment

                            Working...