-
Hi again guys,
I can't find a post related to this yet, but does anyone of you guys know how to create an icon?? well, i mean, putting images into the command buttons. I don't mean, creating a image then put in "image_click", just simply a command button with images on it.
thanks guy
-
To put images onto a toolbar button you have to add the imagelist control. You then load all of your images using the insert button. Once you have the images loaded you can then call the imagelist from all most any other control. Hope this helps.
-
erm. sorry.. but where can I find the Imagelist control???
-
It's on Microsoft Common Controls 6-2, I think.
-
Press Ctrl+T Search for the Microsoft Windows Common controls and check it, press ok, the three boxes on each other is the imagelistcontrol
-
thanks guys..
got it working
-
At design time set the command button sytle to 1 (graphical)
then add the picture via the picture property.
-
It'll be better to make your own button using an Image Control. I find that the normal ones are too large when a picture is added.
-
HeSaidIT
i have to agree, HeSaidJoe's method is the most simplest, no hassle. But, u would have to create this images urself to ensure the size you wanted.
-
DrawIcon API?
How about this?
Code:
Option Explicit
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Command2_Click()
Dim Path$, strSave$, MyDC&, return1&
'String Buffer
strSave = String(200, Chr$(0))
'GetRegEDIT Path
Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave))) + "\REGEdit.exe"
return1& = ExtractIcon(Me.hwnd, Path, 3)
MyDC = GetDC(Command1.hwnd)
'Draw the icon on the CommandButton
return1 = DrawIcon(MyDC, 0, 0, return1)
End Sub
-
Yeah that works good, but it covers up the Caption. I suppose, though, that it would be good if you did not want any text of it (Ie, a Toolbar button)