Answered by:
How to dump icons from Visual Studio?

Question
-
I want to dump icons from VS like those...
Please someone tell me~ thanks.
嗨~我是米豆- Edited by 米豆(Mido) Tuesday, August 18, 2009 7:43 AM
Tuesday, August 18, 2009 5:51 AM
Answers
-
Your question is how to get the icons for .NET controls. These were defined using the ToolboxBitmapAttribute, which has a GetImage method.
Option Explicit On Option Strict On Imports System.Reflection Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim iml As New ImageList Dim lvw As New ListView lvw.SmallImageList = iml lvw.Dock = DockStyle.Fill lvw.View = View.List Me.Controls.Add(lvw) Dim winForms As Assembly = Assembly.GetAssembly(GetType(Form)) For Each t As Type In winForms.GetTypes() If GetType(Control).IsAssignableFrom(t) Then Dim tba As New ToolboxBitmapAttribute(t) Dim img As Image = tba.GetImage(t, False) If Not img Is Nothing Then iml.Images.Add(img) lvw.Items.Add(t.Name, iml.Images.Count - 1) End If End If Next t End Sub End Class
Tuesday, August 18, 2009 11:27 AM -
Hi MIDO I Hope it Help you I Make it because I Find some interesting in the code That BinaryCoder Gave us here, the thing is that there is no other way to get and use This similar icons without save it into and folder in your computer,
I hope you dont get a headache when you check it comment
well after you paste the following code into a Windows form I will explain itOption Explicit On Option Strict On Imports System.Reflection Public Class Form1 WithEvents lvw As New ListView Dim iml As New ImageList WithEvents Button_1 As New Button WithEvents button_2 As New Button WithEvents button_3 As New Button Dim picturebox_1 As New PictureBox Dim label_1 As New Label Public Sub New() '''''''''''''''''''''' InitializeComponent() ''''''''''''''''''''''''''' lvw.Enabled = False lvw.HideSelection = False ' lvw.MultiSelect = False Button_1.Text = "Next Icon" Button_1.Location = New Point(12, 339) Button_1.AutoSize = True Button_1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left button_2.Text = "Previous Icon" button_2.Location = New Point(148, 339) button_2.Enabled = False button_2.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left button_3.Text = "Save Icon As" button_3.Location = New Point(284, 338) button_3.Enabled = False button_3.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left picturebox_1.Location = New Point(246, 338) picturebox_1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left label_1.Text = "Each time you press a button it will show Different Icon" label_1.AutoSize = True label_1.Location = New Point(12, 319) label_1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left lvw.SmallImageList = iml lvw.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top lvw.Size = New Size(473, 314) lvw.View = View.List Me.Controls.Add(Button_1) Me.Controls.Add(button_2) Me.Controls.Add(button_3) Me.Controls.Add(picturebox_1) Me.Controls.Add(label_1) Me.Controls.Add(lvw) Me.Size = CType(New Point(613, 412), Drawing.Size) Me.Text = "Icons Of Visual Studio's ToolBox" Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle Me.WindowState = FormWindowState.Maximized Me.MaximizeBox = False Dim winForms As Reflection.Assembly = Reflection.Assembly.GetAssembly(GetType(Form)) For Each t As Type In winForms.GetTypes() If GetType(Control).IsAssignableFrom(t) Then Dim tba As New ToolboxBitmapAttribute(t) Dim img As Image = tba.GetImage(t, False) If Not img Is Nothing Then iml.Images.Add(img) lvw.Items.Add(t.Name, iml.Images.Count - 1) End If End If Next t End Sub Dim Index As Integer = 0 Dim selecteditem As Integer = 0 Private Sub ShowImageNext() Handles Button_1.Click lvw.Focus() Try Dim selectedItem As Int32 If lvw.SelectedItems.Count > 0 Then ' selectedItem = lvw.SelectedItems(0).Index End If If selectedItem < lvw.Items.Count - 1 Then ' lvw.Items(selectedItem + 1).Selected = True Else End If Index += 1 picturebox_1.Image = iml.Images.Item(Index) button_2.Enabled = True button_3.Enabled = True Catch ex As Exception MessageBox.Show("There is no more Icons To Show") Application.Restart() End Try End Sub Private Sub ShowImagePrevious() Handles button_2.Click lvw.Focus() Try Dim selectedItem As Int32 If lvw.SelectedItems.Count > 0 Then ' selectedItem = lvw.SelectedItems(0).Index End If If selectedItem < lvw.Items.Count - 1 Then ' lvw.Items(selectedItem - 1).Selected = True Else End If Index -= 1 picturebox_1.Image = iml.Images.Item(Index) button_2.Enabled = True Catch ex As Exception MessageBox.Show("There is no more Icons To Show") Application.Restart() End Try End Sub Public Sub SaveImage() Handles button_3.Click Dim saveFile As New SaveFileDialog 'Format to save saveFile.Filter = "Jpg File(*.Jpg)|*.Jpg|Icon File(*.Ico)|*.Ico|Bmp File(*.Bmp)|*.Bmp|Png File(*.Png)|*.Png" If saveFile.ShowDialog = Windows.Forms.DialogResult.OK Then picturebox_1.Image.Save(saveFile.FileName) End If End Sub End Class
Well, now the code is added into a form , Press the boton Next Icon you will see an Icon shown Between thePrevious Icon and Save Icon As Buttons
then if you want to seethe next Icon press The button Next Icon but if you want to see the Previous Icon press the button Previous Icon,,,,,,
Now To Save an Icon you can press The Button Save Icon As
(it will save the icon shown between Previous Icon and Save Icon As Buttons)
when you press it button will show a SaveFileDialog Select a format that you want to need for your image
( select a format in Save as Type), Specify a Name for your image and press save
now you can add these icons For your application,
(add these as Resources or if you know other way you can do it)
I Hope it Help you
: )
Thanks BinaryCoder
It Will help me ..
Best regards.
Melvin.
Todo Es posible si se studia con exfuerso no importando lo de mas, Dios esta con nosotros y no hay mas sabiduria que la de Dios, Everything is posible Do not Turn Off Your Mind Remember Our Decision is Give EveryThing that We have , God Loves us Today Tomorrow and Always... Melvin Saludos U.S.AWednesday, August 19, 2009 7:30 AM
All replies
-
Your question is how to get the icons for .NET controls. These were defined using the ToolboxBitmapAttribute, which has a GetImage method.
Option Explicit On Option Strict On Imports System.Reflection Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim iml As New ImageList Dim lvw As New ListView lvw.SmallImageList = iml lvw.Dock = DockStyle.Fill lvw.View = View.List Me.Controls.Add(lvw) Dim winForms As Assembly = Assembly.GetAssembly(GetType(Form)) For Each t As Type In winForms.GetTypes() If GetType(Control).IsAssignableFrom(t) Then Dim tba As New ToolboxBitmapAttribute(t) Dim img As Image = tba.GetImage(t, False) If Not img Is Nothing Then iml.Images.Add(img) lvw.Items.Add(t.Name, iml.Images.Count - 1) End If End If Next t End Sub End Class
Tuesday, August 18, 2009 11:27 AM -
Thanks Melvin_s.
But I want to use icons at OneNote. How should I do?
嗨~我是米豆Tuesday, August 18, 2009 10:23 PM -
Hi I am Not the Owner of the previous Comment , Please Wait for the answer of BinaryCoder,,
Todo Es posible si se studia con exfuerso no importando lo de mas, Dios esta con nosotros y no hay mas sabiduria que la de Dios, Everything is posible Do not Turn Off Your Mind Remember Our Decision is Give EveryThing that We have , God Loves us Today Tomorrow and Always... Melvin Saludos U.S.ATuesday, August 18, 2009 11:58 PM -
> But I want to use icons at OneNote
I am sorry, I don't understand your question.Wednesday, August 19, 2009 12:23 AM -
BinaryCoder:
Sorry~ my english too poor>_<
Example "IconsExtract" can dump icons from DLL or EXE.
I want to dump icons from toolbox of VS, like those icons...
Have any DLL or EXE inculde it?
嗨~我是米豆Wednesday, August 19, 2009 12:28 AM -
These images are stored as managed resource bitmaps, not unmanaged icons (like in unmanged DLLs and EXEs). You would need code to convert to ico format output. I don't think the .NET Framework includes this support directly.
Wednesday, August 19, 2009 12:49 AM -
Hi MIDO I Hope it Help you I Make it because I Find some interesting in the code That BinaryCoder Gave us here, the thing is that there is no other way to get and use This similar icons without save it into and folder in your computer,
I hope you dont get a headache when you check it comment
well after you paste the following code into a Windows form I will explain itOption Explicit On Option Strict On Imports System.Reflection Public Class Form1 WithEvents lvw As New ListView Dim iml As New ImageList WithEvents Button_1 As New Button WithEvents button_2 As New Button WithEvents button_3 As New Button Dim picturebox_1 As New PictureBox Dim label_1 As New Label Public Sub New() '''''''''''''''''''''' InitializeComponent() ''''''''''''''''''''''''''' lvw.Enabled = False lvw.HideSelection = False ' lvw.MultiSelect = False Button_1.Text = "Next Icon" Button_1.Location = New Point(12, 339) Button_1.AutoSize = True Button_1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left button_2.Text = "Previous Icon" button_2.Location = New Point(148, 339) button_2.Enabled = False button_2.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left button_3.Text = "Save Icon As" button_3.Location = New Point(284, 338) button_3.Enabled = False button_3.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left picturebox_1.Location = New Point(246, 338) picturebox_1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left label_1.Text = "Each time you press a button it will show Different Icon" label_1.AutoSize = True label_1.Location = New Point(12, 319) label_1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left lvw.SmallImageList = iml lvw.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top lvw.Size = New Size(473, 314) lvw.View = View.List Me.Controls.Add(Button_1) Me.Controls.Add(button_2) Me.Controls.Add(button_3) Me.Controls.Add(picturebox_1) Me.Controls.Add(label_1) Me.Controls.Add(lvw) Me.Size = CType(New Point(613, 412), Drawing.Size) Me.Text = "Icons Of Visual Studio's ToolBox" Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle Me.WindowState = FormWindowState.Maximized Me.MaximizeBox = False Dim winForms As Reflection.Assembly = Reflection.Assembly.GetAssembly(GetType(Form)) For Each t As Type In winForms.GetTypes() If GetType(Control).IsAssignableFrom(t) Then Dim tba As New ToolboxBitmapAttribute(t) Dim img As Image = tba.GetImage(t, False) If Not img Is Nothing Then iml.Images.Add(img) lvw.Items.Add(t.Name, iml.Images.Count - 1) End If End If Next t End Sub Dim Index As Integer = 0 Dim selecteditem As Integer = 0 Private Sub ShowImageNext() Handles Button_1.Click lvw.Focus() Try Dim selectedItem As Int32 If lvw.SelectedItems.Count > 0 Then ' selectedItem = lvw.SelectedItems(0).Index End If If selectedItem < lvw.Items.Count - 1 Then ' lvw.Items(selectedItem + 1).Selected = True Else End If Index += 1 picturebox_1.Image = iml.Images.Item(Index) button_2.Enabled = True button_3.Enabled = True Catch ex As Exception MessageBox.Show("There is no more Icons To Show") Application.Restart() End Try End Sub Private Sub ShowImagePrevious() Handles button_2.Click lvw.Focus() Try Dim selectedItem As Int32 If lvw.SelectedItems.Count > 0 Then ' selectedItem = lvw.SelectedItems(0).Index End If If selectedItem < lvw.Items.Count - 1 Then ' lvw.Items(selectedItem - 1).Selected = True Else End If Index -= 1 picturebox_1.Image = iml.Images.Item(Index) button_2.Enabled = True Catch ex As Exception MessageBox.Show("There is no more Icons To Show") Application.Restart() End Try End Sub Public Sub SaveImage() Handles button_3.Click Dim saveFile As New SaveFileDialog 'Format to save saveFile.Filter = "Jpg File(*.Jpg)|*.Jpg|Icon File(*.Ico)|*.Ico|Bmp File(*.Bmp)|*.Bmp|Png File(*.Png)|*.Png" If saveFile.ShowDialog = Windows.Forms.DialogResult.OK Then picturebox_1.Image.Save(saveFile.FileName) End If End Sub End Class
Well, now the code is added into a form , Press the boton Next Icon you will see an Icon shown Between thePrevious Icon and Save Icon As Buttons
then if you want to seethe next Icon press The button Next Icon but if you want to see the Previous Icon press the button Previous Icon,,,,,,
Now To Save an Icon you can press The Button Save Icon As
(it will save the icon shown between Previous Icon and Save Icon As Buttons)
when you press it button will show a SaveFileDialog Select a format that you want to need for your image
( select a format in Save as Type), Specify a Name for your image and press save
now you can add these icons For your application,
(add these as Resources or if you know other way you can do it)
I Hope it Help you
: )
Thanks BinaryCoder
It Will help me ..
Best regards.
Melvin.
Todo Es posible si se studia con exfuerso no importando lo de mas, Dios esta con nosotros y no hay mas sabiduria que la de Dios, Everything is posible Do not Turn Off Your Mind Remember Our Decision is Give EveryThing that We have , God Loves us Today Tomorrow and Always... Melvin Saludos U.S.AWednesday, August 19, 2009 7:30 AM -
Thanks for help. I will try those code ^_^
嗨~我是米豆Wednesday, August 19, 2009 8:36 AM -
Thanks to binaryCode too,,,ALSO YOU CAN MARK AS ANSWER THE COMMENT OF BINARYCODE Apart of my comment too., BECAUSE HE GAVE THE IDEA TO DO IT.
Best Regards.
THANKS
: )
Melvin.
Todo Es posible si se studia con exfuerso no importando lo de mas, Dios esta con nosotros y no hay mas sabiduria que la de Dios, Everything is posible Do not Turn Off Your Mind Remember Our Decision is Give EveryThing that We have , God Loves us Today Tomorrow and Always... Melvin Saludos U.S.AWednesday, August 19, 2009 8:44 AM -
OK ^0^
Thanks to binaryCode too
嗨~我是米豆Wednesday, August 19, 2009 1:52 PM