Display An Icon -
05-07-2007
, 08:51 AM
I’ve got the name of a file that contains icons and the icon index. How do I
use these to display an icon in a picturebox in a .Net program?
Let’s say that the icon I want is in "c:\Program Files\Windows
NT\Accessories\wordpad.exe" and the index is 2. I think that I need to do
something like this in the “Paint” event:
Private Sub PictureBox1_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles PictureBox1.Paint
e.Graphics.DrawIcon(_
New Icon("C:\Program Files\Windows NT\Accessories\wordpad.exe"), _
0, 0)
End Sub
Of course this doesn’t work. The “Icon” constructor only takes the name of
a .ico file and it only lets you specify the size of the icon, not the index.
How do I create the “Icon” object from any type of file that contains an
icon (.ico, .exe, .dll, etc.)? |