Armin said:
<quote>
Where do you get the Icon from? Do you have a System.Drawing.Icon object or
did you receive a icon handle somewhere from unmanaged functions?
Wherever possible, use the Graphics object to draw. In a Paint event, you
get it in e.graphics. Outside Paint, you create it by calling
YourControl.Creategraphics. Then call the Graphics object's DrawIcon method.
</quote>
<quote>
Private Declare Function ExtractAssociatedIcon Lib "shell32.dll"
Alias "ExtractAssociatedIconA" (ByVal hInst As intptr, ByVal
lpIconPath As String, byref lpiIcon As Integer) As intptr
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As intptr,
ByVal xLeft As integer, ByVal yTop As integer, ByVal hIcon As intptr, ByVal
cxWidth As integer, ByVal cyWidth As integer, ByVal istepIfAniCur As
integer,
ByVal hbrFlickerFreeDraw As intptr, ByVal diFlags As integer) As boolean
(In VB 2005 you can use the Unsigned Integer type for istepIfAniCur and
diFlags.)
Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As
intptr) As boolean
But I agree that we should use the managed version wherever possible. BTW,
in Framework 2.0, there is the Icon.ExtractAssociatedIcon method.
</quote>
I do not have the declaration for DrawIconEx, but you can use
Icon.FromHandle to create an Icon and draw it the managed way as shown
above.
Armin
Armin,
1. Up above is the method with which I retrieved the Icon.
2. What the heck is 'the managed version'? Never heard of that before.
3. I must be stupid or whatever, because I don't understand a damn
thing you are saying about Icon.handle and create an Icon, etc.
I extracted the Icon, NOW, How do I draw it into a Picture Box.
Step by Step.
If you can't or no one else can, then forget it.
Thanks for all your time and trouble.
Marshall
PS. Now I know why VB6 coders are fighting moving to VB.Net.
It looks similar to Java and C#.
Now who in their right mind wants to go thru all the trouble of the
name.name.name stuff
when in VB6 you could just do it.
I'm trying to learn VB.Net, but as you can see I have a mindset to
overcome.
VB6 is SO MUCH EASIER to understand and to code for; I started with VB
3.0 on WIndows 3.11 and was writing code within a 1/2 hr.
Now I can't even get the program to run unless I do ctrl+F5
VB6 not being an OOP language, as far as I am concerned is a complaint
of the Publishers of magazines, C++ and Java programmers who have a
propensity to favor total OOP languages.
Now that said, I would be willing to wager that 1,000's of VB6 programs
run companies.
So to say it's not a 'real' language is absurd.
But I digress.
Sorry to go on a rant, but I had to say my 2 cents worth. For whatever
that's worth.