0% found this document useful (0 votes)
54 views1 page

Vba Userform Icon

This document contains VBA code that defines constants and declares Windows API functions for manipulating the system bar of a userform window. It includes a SystemBarMessageASettings subroutine that finds the window handle of a userform, sends a message to set its system icon, and redraws the menu bar. The code also contains a private sub that calls SystemBarMessageASettings when the userform activates to set the icon.

Uploaded by

amine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views1 page

Vba Userform Icon

This document contains VBA code that defines constants and declares Windows API functions for manipulating the system bar of a userform window. It includes a SystemBarMessageASettings subroutine that finds the window handle of a userform, sends a message to set its system icon, and redraws the menu bar. The code also contains a private sub that calls SystemBarMessageASettings when the userform activates to set the icon.

Uploaded by

amine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

'module

Option Explicit

Private Const FOCO_ICONE = &H80


Private Const ICONE = 0&
#If VBA7 Then
Private Declare PtrSafe Function SendMessageA Lib "user32" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
As Long
Private Declare PtrSafe Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long

#Else

Private Declare Function SendMessageA Lib "user32" _


(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long

#End If

Public Sub SystemBarMessageASettings(frm As Object, imj As Object)


Dim windowHandle As Long
Dim hIcone As Long
windowHandle = FindWindowA(vbNullString, frm.Caption)

hIcone = imj.Picture.Handle
Call SendMessageA(windowHandle, FOCO_ICONE, ICONE, ByVal hIcone)

DrawMenuBar windowHandle
End Sub

priv sub userform activate


SystemBarMessageASettings Me, Me.image1
end sub

You might also like