Become nuts with ToolBar
-
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 -
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 SybuxI 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)
-
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)
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 ? -
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 ?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.