View Single Post
 
Old 05-17-2016, 11:22 AM
derajlance derajlance is offline Windows 10 Office 2013
Novice
 
Join Date: May 2016
Posts: 18
derajlance is on a distinguished road
Default Change Userform Icon in Taskbar

I think I finally got all of my forms completed and working properly. Now I am trying to just do some cosmetic things.

Specifically, at this point, I am wanting to change the icon that shows in the taskbar for the userform.
I want to change this:

Into this:

I've tried the following code, but have not had any success:
Code:
Private Declare Function GetActiveWindow32 Lib "USER32" Alias _ 
"GetActiveWindow" () As Integer 
 
 
Private Declare Function SendMessage32 Lib "USER32" Alias _ 
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _ 
ByVal wParam As Long, ByVal lParam As Long) As Long 
 
 
Private Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias _ 
"ExtractIconA" (ByVal hInst As Long, _ 
ByVal lpszExeFileName As String, _ 
ByVal nIconIndex As Long) As Long 
 
Private Sub ChangeIcon() 
    ChangeApplicationIcon 
End Sub 
 
Sub ChangeIcon() 
     
    Dim Icon& 
     
    Const NewIcon$ = "Image2" 
 
    Icon = ExtractIcon32(0, NewIcon, 0) 
    SendMessage32 GetActiveWindow32(), &H80, 1, Icon 
    SendMessage32 GetActiveWindow32(), &H80, 0, Icon 
     
End Sub
"Image2" is the .ico image that is on the userform and set as not visible.
Reply With Quote