Icon to Image

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

    Icon to Image

    Hi,
    I have simple needs but I don't know how to implement it.
    I have application that create Dynamic Button. I need to set the image
    on this button, getting the icon from a form.

    So pratically I need to convert dinamically a Form.Icon to
    Button.Image runtime, but i don't know how.
    Any help would be appreciated.

    Many Thanks

    Marco
  • kimiraikkonen

    #2
    Re: Icon to Image

    On Feb 28, 5:15 am, Marcolino <marco.pozzu... @gmail.comwrote :
    Hi,
    I have simple needs but I don't know how to implement it.
    I have application that create Dynamic Button. I need to set the image
    on this button, getting the icon from a form.
    >
    So pratically I need to convert dinamically a Form.Icon to
    Button.Image runtime, but i don't know how.
    Any help would be appreciated.
    >
    Many Thanks
    >
    Marco
    Marco,
    IIUC correctly you want to synronize form's icon to a button, you can
    do this with the following:

    ' First save form's icon to somewhere (eg: C: drive)
    Me.Icon.ToBitma p.Save("c:\icon .ico",
    System.Drawing. Imaging.ImageFo rmat.Icon)

    'Then call this icon image as button's image
    Button1.Image = Button1.Image.F romFile("c:\ico n.ico")

    '
    -------------------------------------------------------------------------------

    If you button is present and you want to create a new one on runtime:

    'Set button properties as you wish (optional)
    Me.Icon.ToBitma p.Save("c:\icon .ico",
    System.Drawing. Imaging.ImageFo rmat.Icon)
    Dim button As New Button
    Me.Controls.Add (button)
    button.Name = "button1"
    button.Image = button.Image.Fr omFile("c:\icon .ico")

    Hope this helps!

    Comment

    • kimiraikkonen

      #3
      Re: Icon to Image

      On Feb 28, 10:55 am, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
      On Feb 28, 5:15 am, Marcolino <marco.pozzu... @gmail.comwrote :
      >
      Hi,
      I have simple needs but I don't know how to implement it.
      I have application that create Dynamic Button. I need to set the image
      on this button, getting the icon from a form.
      >
      So pratically I need to convert dinamically a Form.Icon to
      Button.Image runtime, but i don't know how.
      Any help would be appreciated.
      >
      Many Thanks
      >
      Marco
      >
      Marco,
      IIUC correctly you want to synronize form's icon to a button, you can
      do this with the following:
      >
      ' First save form's icon to somewhere (eg: C: drive)
      Me.Icon.ToBitma p.Save("c:\icon .ico",
      System.Drawing. Imaging.ImageFo rmat.Icon)
      >
      'Then call this icon image as button's image
      Button1.Image = Button1.Image.F romFile("c:\ico n.ico")
      >
      '
      -------------------------------------------------------------------------------
      >
      If you button is present and you want to create a new one on runtime:
      >
      'Set button properties as you wish (optional)
      Me.Icon.ToBitma p.Save("c:\icon .ico",
      System.Drawing. Imaging.ImageFo rmat.Icon)
      Dim button As New Button
      Me.Controls.Add (button)
      button.Name = "button1"
      button.Image = button.Image.Fr omFile("c:\icon .ico")
      >
      Hope this helps
      Sorry, some grammer mistakes :-)
      (I meant if your button is "not" present);

      If i understood your issue correctly, you want to syncronize form's
      icon to a button, you can
      do this with the following:

      ' First save form's icon to somewhere (eg: C: drive)
      Me.Icon.ToBitma p.Save("c:\icon .ico",
      System.Drawing. Imaging.ImageFo rmat.Icon)

      'Then call this icon image as button's image
      Button1.Image = Button1.Image.F romFile("c:\ico n.ico")

      '
      -------------------------------------------------------------------------------

      If your button is NOT present and you want to create a new one on
      runtime:

      'Set button properties as you wish (optional)
      Me.Icon.ToBitma p.Save("c:\icon .ico",
      System.Drawing. Imaging.ImageFo rmat.Icon)
      Dim button As New Button
      Me.Controls.Add (button)
      button.Name = "button1"
      button.Image = button.Image.Fr omFile("c:\icon .ico")

      Hope this helps!

      Comment

      • Thorsten Doerfler

        #4
        Re: Icon to Image

        Marcolino schrieb:
        I have simple needs but I don't know how to implement it.
        I have application that create Dynamic Button. I need to set the image
        on this button, getting the icon from a form.
        >
        So pratically I need to convert dinamically a Form.Icon to
        Button.Image runtime, but i don't know how.
        Private Sub Button1_Click(B yVal sender As System.Object, _
        ByVal e As System.EventArg s _
        ) Handles Button1.Click
        Using lIcon As New Icon(Me.Icon, 16, 16)
        Button1.Image = lIcon.ToBitmap
        End Using
        End Sub

        Thorsten Dörfler
        --
        Microsoft MVP Visual Basic

        vb-hellfire visual basic faq | vb-hellfire - einfach anders
        http://vb-faq.de/ | http://www.vb-hellfire.de/

        Comment

        • Marcolino

          #5
          Re: Icon to Image

          On 28 Feb, 10:47, Thorsten Doerfler <t.doerfler_nos ...@bdsw.dewrot e:
          Marcolino schrieb:
          >
          I have simple needs but I don't know how to implement it.
          I have application that create Dynamic Button. I need to set the image
          on this button, getting the icon from a form.
          >
          So pratically I need to convert dinamically a Form.Icon to
          Button.Image runtime, but i don't know how.
          >
            Private Sub Button1_Click(B yVal sender As System.Object, _
                                  ByVal e As System.EventArg s _
                                          ) Handles Button1.Click
              Using lIcon As New Icon(Me.Icon, 16, 16)
                Button1.Image = lIcon.ToBitmap
              End Using
            End Sub
          >
          Thorsten Dörfler
          --
          Microsoft MVP Visual Basic
          >
          vb-hellfire visual basic faq  | vb-hellfire - einfach andershttp://vb-faq.de/            |http://www.vb-hellfire.de/
          Thanks to all, it works.
          Bye

          Marco

          Comment

          Working...