Hi
I am trying to change the icon of a running external application , Notepad.
I can n't seem to see figure this out.
Thanks in advance.
The code I am using:
Declaration:
Public Declare Function LoadImage Lib "user32" _
Alias "LoadImageA" _
(ByVal hInst As Long, _
ByVal lpsz As String, _
ByVal un1 As Long, _
ByVal n1 As Long, _
ByVal n2 As Long, _
ByVal un2 As Long) _
As Long
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal LParam As Long) _
As Long
Main code:
SetFormIcon(hwnd, "C:\myicon.ico")
Function:
Public Function SetFormIcon(ByVal hWnd As Long, ByVal IconPath As String) As Boolean
Dim hIcon As Long
hIcon = LoadImage(0&, IconPath, IMAGE_ICON, 16, 16, LR_LOADFROMFILE)
If hIcon <> 0 Then
Call SendMessage(hWnd, WM_SETICON, ICON_SMALL, hIcon)
Call SendMessage(hWnd, WM_SETICON, ICON_BIG, hIcon)
SetFormIcon = True
End If
End Function
I am trying to change the icon of a running external application , Notepad.
I can n't seem to see figure this out.
Thanks in advance.
The code I am using:
Declaration:
Public Declare Function LoadImage Lib "user32" _
Alias "LoadImageA" _
(ByVal hInst As Long, _
ByVal lpsz As String, _
ByVal un1 As Long, _
ByVal n1 As Long, _
ByVal n2 As Long, _
ByVal un2 As Long) _
As Long
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal LParam As Long) _
As Long
Main code:
SetFormIcon(hwnd, "C:\myicon.ico")
Function:
Public Function SetFormIcon(ByVal hWnd As Long, ByVal IconPath As String) As Boolean
Dim hIcon As Long
hIcon = LoadImage(0&, IconPath, IMAGE_ICON, 16, 16, LR_LOADFROMFILE)
If hIcon <> 0 Then
Call SendMessage(hWnd, WM_SETICON, ICON_SMALL, hIcon)
Call SendMessage(hWnd, WM_SETICON, ICON_BIG, hIcon)
SetFormIcon = True
End If
End Function