Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Become nuts with ToolBar

Become nuts with ToolBar

Scheduled Pinned Locked Moved Visual Basic
questiongraphicshelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sybux2000
    wrote on last edited by
    #1

    Hi I'm using toolbar and I've added some icons to my toolbar buttons with the following code Dim myImageList As New ImageList Dim myImage As Image myImage = Image.FromFile("C:\Temp\dvd03.ico") myImageList.Images.Add(myImage) myImage = Image.FromFile("C:\Temp\dvd01.ico") myImageList.Images.Add(myImage) Me.ToolBar1.ImageList = myImageList Me.tbb_Scan.ImageIndex = 0 Me.tbb_show.ImageIndex = 1 My Icons are 48x48 so I've set the toolbar button size property as follow : Me.ToolBar1.ButtonSize = New System.Drawing.Size(48, 48) The problem is when I run my application my buttons are very small somthing like 16x16 pixels :confused: Where I am wrong ? Is it so late so that I need to go bed (22 H GMT !!) Another question : How to specify to load image in a folder that is in the current folder. (p ex: appname.exe is in c:\Temp and I want all my image in c:\Temp\Images). Or is it possible to include them in the exe file so I don't need to distribute them ! Thx Sybux

    S 1 Reply Last reply
    0
    • S sybux2000

      Hi I'm using toolbar and I've added some icons to my toolbar buttons with the following code Dim myImageList As New ImageList Dim myImage As Image myImage = Image.FromFile("C:\Temp\dvd03.ico") myImageList.Images.Add(myImage) myImage = Image.FromFile("C:\Temp\dvd01.ico") myImageList.Images.Add(myImage) Me.ToolBar1.ImageList = myImageList Me.tbb_Scan.ImageIndex = 0 Me.tbb_show.ImageIndex = 1 My Icons are 48x48 so I've set the toolbar button size property as follow : Me.ToolBar1.ButtonSize = New System.Drawing.Size(48, 48) The problem is when I run my application my buttons are very small somthing like 16x16 pixels :confused: Where I am wrong ? Is it so late so that I need to go bed (22 H GMT !!) Another question : How to specify to load image in a folder that is in the current folder. (p ex: appname.exe is in c:\Temp and I want all my image in c:\Temp\Images). Or is it possible to include them in the exe file so I don't need to distribute them ! Thx Sybux

      S Offline
      S Offline
      Syed Abdul Khader
      wrote on last edited by
      #2

      I am just answering ur second question. You can get the current folder which has the exe by Application.Startup property like this myImage = Image.LoadFrom(Application.StartupPath + "\Images\imgName.bmp"). You can attach the images with ur assembly itself. For doing so, do the following steps. You add all the image files to the project by right clicking the project and add existing items. Select all files and press F4 to open the Properties window. Change Build Action property to Embedded Resource. Then make the DefaultNamespace if u want (Assume here "MyNamespace") You can get the images from assembly like this. Dim a as Assembly = [Assembly].GetExecutingAssembly() Dim s as Stream = a.GetManifestResourceStream("MyNamespace.urImage1.bmp") Dim bmp as New Bitmap(s)

      S 1 Reply Last reply
      0
      • S Syed Abdul Khader

        I am just answering ur second question. You can get the current folder which has the exe by Application.Startup property like this myImage = Image.LoadFrom(Application.StartupPath + "\Images\imgName.bmp"). You can attach the images with ur assembly itself. For doing so, do the following steps. You add all the image files to the project by right clicking the project and add existing items. Select all files and press F4 to open the Properties window. Change Build Action property to Embedded Resource. Then make the DefaultNamespace if u want (Assume here "MyNamespace") You can get the images from assembly like this. Dim a as Assembly = [Assembly].GetExecutingAssembly() Dim s as Stream = a.GetManifestResourceStream("MyNamespace.urImage1.bmp") Dim bmp as New Bitmap(s)

        S Offline
        S Offline
        sybux2000
        wrote on last edited by
        #3

        Thx for answer now it's working with the Assembly method but If I can correct you, here is the working code : Dim myAssembly As System.Reflection.Assembly Dim myStream As System.IO.Stream Dim myImage As Image myAssembly = System.Reflection.Assembly.GetExecutingAssembly ' The resource name is Case Sensitive ! myStream = myAssembly.GetManifestResourceStream("myProjectName.icon1.ICO") myImage = Image.FromStream(myStream) Does any1 know with my little icon (48x48) are small in my toolbar ?

        S 1 Reply Last reply
        0
        • S sybux2000

          Thx for answer now it's working with the Assembly method but If I can correct you, here is the working code : Dim myAssembly As System.Reflection.Assembly Dim myStream As System.IO.Stream Dim myImage As Image myAssembly = System.Reflection.Assembly.GetExecutingAssembly ' The resource name is Case Sensitive ! myStream = myAssembly.GetManifestResourceStream("myProjectName.icon1.ICO") myImage = Image.FromStream(myStream) Does any1 know with my little icon (48x48) are small in my toolbar ?

          S Offline
          S Offline
          Syed Abdul Khader
          wrote on last edited by
          #4

          Thanks for ur correction. You have to set the Button Size as well as the ImageList's ImageSize property. By default its value is 16 by 16.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups