Hi
Ok could someone please tell me how to get a files icon onto a command button, there must be a way you can do this, iv looked everywere for some code but i cant find any.
Please help!!!!
Thanks
Printable View
Hi
Ok could someone please tell me how to get a files icon onto a command button, there must be a way you can do this, iv looked everywere for some code but i cant find any.
Please help!!!!
Thanks
Why don't you use picture box or image box as butons. if you change the picture on events you'll get the same effect as that of a command button;
:D Kinjal :D
Isn't there a graphical setting on the command button? If not, kinjalgp is right about the picture box. It does the same thing.
bob
You can change its style to graphical an you'll be able to show the pictures
add Microsoft Forms 2.0 object library to component reference.
fm20.dll
Now it gives another command button to which you can assign pictures and text.
Ramdas
THANK YOU SO MUCH, I DID NOT KNOW THAT....
this is awesome, thank you, I would have never figured that out.... that form dll thing is awesome, even if it is another dll you have to distribute, THANK YOU
NO
I am wanting the user to be able to ad any file icon to the command button
So it takes the icon from the file and then adds it to the button
For getting the icon out of the file and draw it on a DC:
Code:'In declarations:
Declare Function ExtractIconEx Lib "shell32" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Long, phIconLarge As Long, phIconSmall As Long, ByVal nIcons As Long) As Long
Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hicon As Long) As Long
'In code:
Function GetIconsFromFile(Filename$)
Dim hIcons()
ReDim hIcons(ExtractIconEx(Filename, -1, ByVal 0&, ByVal 0&, 0))
If UBound(hIcons) = 0 Then Exit Function Else ReDim Preserve hIcons(UBound(hIcons) - 1)
ExtractIconEx Filename, 0, hIcons(0), ByVal 0&, 10
GetIconsFromFile = hIcons
End Function
'example:
Dim hicon&()
hicon = GetIconsFromFile(yourfilename)
DrawIcon yourdc&, 0, 0, hicon
Experts? Even i know this one.... But Kedaman is way outa my league..
BTW hey Kedaman ever find that VB3 code you were goin to get 4 me?
What was it about? Sorry, I forget easily.
well i asked you if you could help me find a way to get my program to know any new window that came up. So if i clicked on "My Computer" the textbox #1 would show "My Computer".......You gave me a VB6 code but since that didnt work on my Vb3 you said that you would find it 4 me.
Is it still possible?
Yeah, btw i have vb5 not 6. I'll search for it
I agree with kinjalgp!
after you use kedaman's Code for retrieving the ICOn , then just use Picturebox control to immitate a Command button, go into the Picture Box's Clikc event, set the width and height of the picture to decrease by a small value, creating the click Simulation,,
I know you prob wont use this advice but i jsut poseted it cuz i need more posts in my Credits as i am still a damn Juniour member!!., Heh!
Hmph. Place an image control directly over the command button. Then use the LoadPicture command to load whatever the user wants to the image. I clarify:
***********************
* _______ .
*| | .
*| Image | Button .
*|_______| .
* .
.......................
My kingdom of a @#$%-ing image tag...
Anyway, use a right-click -> Bring To Front to get the image in front of the button. Just make sure your text doesn't land under the picture.
Hi XPS.
I have solved your problem by making an ActiveX control which you'll find at http://www.planetsourcecode.com/vb in the OLE/COM/activeX section you will find the second entry which is my ActiveX control:D The source code is included
:p Kinjal :p