Desk top icons - ID/Name

L

Les

Good day, i do not know if this is the right forum but does anybody know if
it is possible to to get the id/names of the icons in the "SHELL32.dll" and
can one use them from applications such as Excel in VBA ??
 
Z

zz

create a new workbook

Alt+F11 to open the visual basic editor

menu insert ->Userform

copy and paste this code into the userform


play with this part of the code changing the index number to change the
icon,


'Grab the icon from shell32.dll...
hIcon = ExtractIcon(0, "SHELL32.DLL", 165)<-- just change the 165 part
of this call

enjoy!




Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) 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 SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal
lParam As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA"
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA"
(ByVal hWnd As Long, ByVal lpString As String) As Long


Private Sub UserForm_Initialize()

Dim hWnd, eWnd As Long
Dim hIcon As Long
Dim f_style As Long

'Form window
hWnd = FindWindow("ThunderDFrame", Me.Caption)

'Application window
eWnd = FindWindow("XLMAIN", Application.Caption)

'Grab the icon from shell32.dll...
hIcon = ExtractIcon(0, "SHELL32.DLL", 165)

'draw the icon
SendMessage hWnd, &H80, True, hIcon
SendMessage hWnd, &H80, False, hIcon

'Form caption
Me.Caption = "Excel form with Icon"

f_style = GetWindowLong(hWnd, -16)
f_style = f_style Or &H30000 'system toolbox
f_style = f_style Or &H20000 'minimize
f_style = f_style Or &H10000 'maximize

SetWindowLong hWnd, -16, f_style

'Application caption
SetWindowText eWnd, "test123"


End Sub


--
--
--
Error: App. "GetUpAndWork.exe" couldn't be loaded, "ImToTired.exe" is
blocking it's execution.
--
Walter R . [zz]



| Good day, i do not know if this is the right forum but does anybody know
if
| it is possible to to get the id/names of the icons in the "SHELL32.dll"
and
| can one use them from applications such as Excel in VBA ??
| --
| Les
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top