473,388 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Put icon into Picturebox

yxq
Thank Armin Zingler, the codes below work well!
But i want to put the icon into Picturebox1 instead of the Form1, how to do?

the code
**************************
If retval <> 0 Then
Dim g As Graphics
Dim ico As Icon
Dim hIcon As IntPtr ' handle to the icon once it is extracted
hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image.FromHbitmap(hIcon)
g = Form1.DefInstance.CreateGraphics
g.DrawIcon(ico, 0, 0)
g.Dispose()
retval = DestroyIcon(hIcon.ToInt32)
End If
***************************
Nov 20 '05 #1
6 10010
How about this....?

Dim ico As Icon
Dim p As New PictureBox
Dim hIcon As IntPtr ' handle to the icon once it is extracted
hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image = i.ToBitmap
retval = DestroyIcon(hIcon.ToInt32)

Won't this work?

Just a thought... I think it should work. Is there no easier way for you to
get and icon than to resort to an API call?

Shane

"yxq" <ga***@163.net> wrote in message
news:Op**************@TK2MSFTNGP10.phx.gbl...
Thank Armin Zingler, the codes below work well!
But i want to put the icon into Picturebox1 instead of the Form1, how to do?
the code
**************************
If retval <> 0 Then
Dim g As Graphics
Dim ico As Icon
Dim hIcon As IntPtr ' handle to the icon once it is extracted
hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image.FromHbitmap(hIcon)
g = Form1.DefInstance.CreateGraphics
g.DrawIcon(ico, 0, 0)
g.Dispose()
retval = DestroyIcon(hIcon.ToInt32)
End If
***************************

Nov 20 '05 #2
"yxq" <ga***@163.net> schrieb:
p.Image.FromHbitmap(hIcon)


Can you explain what this line is supposed to do?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
oops... i meant

Dim ico As Icon
Dim p As New PictureBox
Dim hIcon As IntPtr ' handle to the icon once it is extracted
hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image = ico.ToBitmap
retval = DestroyIcon(hIcon.ToInt32)

"SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> wrote in message
news:Oz*************@TK2MSFTNGP10.phx.gbl...
How about this....?

Dim ico As Icon
Dim p As New PictureBox
Dim hIcon As IntPtr ' handle to the icon once it is extracted
hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image = i.ToBitmap
retval = DestroyIcon(hIcon.ToInt32)

Won't this work?

Just a thought... I think it should work. Is there no easier way for you to get and icon than to resort to an API call?

Shane

"yxq" <ga***@163.net> wrote in message
news:Op**************@TK2MSFTNGP10.phx.gbl...
Thank Armin Zingler, the codes below work well!
But i want to put the icon into Picturebox1 instead of the Form1, how to

do?

the code
**************************
If retval <> 0 Then
Dim g As Graphics
Dim ico As Icon
Dim hIcon As IntPtr ' handle to the icon once it is extracted hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image.FromHbitmap(hIcon)
g = Form1.DefInstance.CreateGraphics
g.DrawIcon(ico, 0, 0)
g.Dispose()
retval = DestroyIcon(hIcon.ToInt32)
End If
***************************


Nov 20 '05 #4
yxq
Thank you very much!
It works well!
"SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> дÈëÏûÏ¢ÐÂÎÅ
:#C**************@tk2msftngp13.phx.gbl...
oops... i meant

Dim ico As Icon
Dim p As New PictureBox
Dim hIcon As IntPtr ' handle to the icon once it is extracted hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image = ico.ToBitmap
retval = DestroyIcon(hIcon.ToInt32)

"SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> wrote in message
news:Oz*************@TK2MSFTNGP10.phx.gbl...
How about this....?

Dim ico As Icon
Dim p As New PictureBox
Dim hIcon As IntPtr ' handle to the icon once it is extracted
hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image = i.ToBitmap
retval = DestroyIcon(hIcon.ToInt32)

Won't this work?

Just a thought... I think it should work. Is there no easier way for you
to
get and icon than to resort to an API call?

Shane

"yxq" <ga***@163.net> wrote in message
news:Op**************@TK2MSFTNGP10.phx.gbl...
Thank Armin Zingler, the codes below work well!
But i want to put the icon into Picturebox1 instead of the Form1, how

to do?

the code
**************************
If retval <> 0 Then
Dim g As Graphics
Dim ico As Icon
Dim hIcon As IntPtr ' handle to the icon once it is

extracted hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image.FromHbitmap(hIcon)
g = Form1.DefInstance.CreateGraphics
g.DrawIcon(ico, 0, 0)
g.Dispose()
retval = DestroyIcon(hIcon.ToInt32)
End If
***************************



Nov 20 '05 #5
"yxq" <ga***@163.net> schrieb
Thank Armin Zingler, the codes below work well!
But i want to put the icon into Picturebox1 instead of the Form1, how
to do?

the code
**************************
If retval <> 0 Then
Dim g As Graphics
Dim ico As Icon
Dim hIcon As IntPtr ' handle to the icon once it is
extracted hIcon = ExtractIcon(VB6.GetHInstance, iconfile,
iconindex)
ico = Icon.FromHandle(hIcon)
p.Image.FromHbitmap(hIcon)
g = Form1.DefInstance.CreateGraphics
g.DrawIcon(ico, 0, 0)
g.Dispose()
retval = DestroyIcon(hIcon.ToInt32)
End If
***************************

Declare ico at class level and call DrawIcon in the Picturebox' Paint event.

Or: Derive your own class from Picturebox, add an Icon property and draw the
icon in OnPaint.

--
Armin

Nov 20 '05 #6
Glad to help someone... Need plenty myself.
I am new to .NET and having to learn a lot, but was really good at the
predecessor.

Take care,

Shane
"yxq" <ga***@163.net> wrote in message
news:Od**************@TK2MSFTNGP10.phx.gbl...
Thank you very much!
It works well!
"SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> дÈëÏûÏ¢ÐÂÎÅ
:#C**************@tk2msftngp13.phx.gbl...
oops... i meant

Dim ico As Icon
Dim p As New PictureBox
Dim hIcon As IntPtr ' handle to the icon once it is extracted
hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex)
ico = Icon.FromHandle(hIcon)
p.Image = ico.ToBitmap
retval = DestroyIcon(hIcon.ToInt32)

"SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> wrote in message
news:Oz*************@TK2MSFTNGP10.phx.gbl...
How about this....?

Dim ico As Icon
Dim p As New PictureBox
Dim hIcon As IntPtr ' handle to the icon once it is extracted hIcon = ExtractIcon(VB6.GetHInstance, iconfile, iconindex) ico = Icon.FromHandle(hIcon)
p.Image = i.ToBitmap
retval = DestroyIcon(hIcon.ToInt32)

Won't this work?

Just a thought... I think it should work. Is there no easier way for you
to
get and icon than to resort to an API call?

Shane

"yxq" <ga***@163.net> wrote in message
news:Op**************@TK2MSFTNGP10.phx.gbl...
> Thank Armin Zingler, the codes below work well!
> But i want to put the icon into Picturebox1 instead of the Form1, how to do?
>
> the code
> **************************
> If retval <> 0 Then
> Dim g As Graphics
> Dim ico As Icon
> Dim hIcon As IntPtr ' handle to the icon once it is

extracted
> hIcon = ExtractIcon(VB6.GetHInstance, iconfile,

iconindex) > ico = Icon.FromHandle(hIcon)
> p.Image.FromHbitmap(hIcon)
> g = Form1.DefInstance.CreateGraphics
> g.DrawIcon(ico, 0, 0)
> g.Dispose()
> retval = DestroyIcon(hIcon.ToInt32)
> End If
> ***************************
>
>



Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: kurotsuke | last post by:
Can anybody tell me how I can call the Pick Icon Dialog from C#? I couldn't find any example. Thanks.
4
by: Jacob | last post by:
What's the best way to put an Icon in the client area of a form (not in the ControlBox)? Everything I've tried seems to produce unsatisfactory results. A picture box doesn't give me the icon size I...
5
by: yxq | last post by:
Hello The icons with the alpha channel are supported in WindowsXP. If use the System.Drawing.Bitmap.ToBitmap on the icon handle(ico.ToBitmap), the alpha channel won't be preserved, resulting in an...
2
by: Liu Feng | last post by:
How to display a 32bits icon in pictureBox or button? It can be displayed correct in toolbar, but not work in pictureBox and button. Who can help me? -- Thanks, LiuFeng
7
by: George Oro | last post by:
Hi everybody, just joined and my first post: What I'm trying to do is to have an insert attachment facility in my mailing software like MsOutlook or Outlook Express that shows the File Name, File...
6
by: Laurent Navarro | last post by:
Hello, I have an EXE (.NET assembly) file with an icon which has 8 formats (128x128, 96x961, ..., 24x24 and 16x16). I would like the extract the 128x128 sized icon only to display it on a...
2
by: \(O\)enone | last post by:
I wish to be able to copy a form's icon into a picturebox, in a similar way to how the Windows Taskbar copies each form's icon into each of its task panels. I can easily read out the icon of...
0
by: Bjarne Nielsen | last post by:
Hi all In my about box, I want to show an icon, so I have placed a picturebox control on my form. Now, I want to set the Image property of the picturebox to an icon, but it seems I cannot do it....
7
by: =?Utf-8?B?QmVu?= | last post by:
Hi I am looking for a way to extraxt an icon from a .exe file an save it as an icon not a bitmap or jpeg to a file? The code below extracts the icon but only as a bitmap PictureBox1.Image =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.