Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do you load an image into the top left hand cornder of a userform. For
example all userforms have the small coloured trip that runs from top left to right. How do you load a small icon intot the top left of that strip? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This how you can do that:
Have a userform, UserForm1, with an image control, Image1. This control will show in the control toolbox as Picture. In the properties of the image control find the property Picture and in the values column browse to an .ico file of your choice. You could set the property Visible of this image control to False. In the UserForm events, in the initialize event put this: Option Explicit Private Sub UserForm_Initialize() LoadPicture End Sub Then in a normal module put all this code: Option Explicit Public Declare Function FindWindow _ Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) 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 Public Declare Function DrawMenuBar Lib "user32" _ (ByVal hwnd As Long) As Long Private Const WM_SETICON = &H80 Private Const ICON_SMALL = 0& Private Const ICON_BIG = 1& Sub LoadForm() Load UserForm1 UserForm1.Show End Sub Sub LoadPicture() Dim hIcon As Long Dim hwnd As Long With UserForm1 hIcon = .Image1.Picture If Val(Application.Version) = 9 Then hwnd = FindWindow("ThunderDFrame", .Caption) Else hwnd = FindWindow("ThunderXFrame", .Caption) End If If hwnd = 0 Then Exit Sub Else SendMessage hwnd, WM_SETICON, ICON_SMALL, ByVal hIcon SendMessage hwnd, WM_SETICON, ICON_BIG, ByVal hIcon DrawMenuBar hwnd End If End With End Sub Then run the Sub LoadForma and there is your userform with icon. RBS "ExcelMonkey" wrote in message ... How do you load an image into the top left hand cornder of a userform. For example all userforms have the small coloured trip that runs from top left to right. How do you load a small icon intot the top left of that strip? Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks I will give a try.
EM "RB Smissaert" wrote: This how you can do that: Have a userform, UserForm1, with an image control, Image1. This control will show in the control toolbox as Picture. In the properties of the image control find the property Picture and in the values column browse to an .ico file of your choice. You could set the property Visible of this image control to False. In the UserForm events, in the initialize event put this: Option Explicit Private Sub UserForm_Initialize() LoadPicture End Sub Then in a normal module put all this code: Option Explicit Public Declare Function FindWindow _ Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) 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 Public Declare Function DrawMenuBar Lib "user32" _ (ByVal hwnd As Long) As Long Private Const WM_SETICON = &H80 Private Const ICON_SMALL = 0& Private Const ICON_BIG = 1& Sub LoadForm() Load UserForm1 UserForm1.Show End Sub Sub LoadPicture() Dim hIcon As Long Dim hwnd As Long With UserForm1 hIcon = .Image1.Picture If Val(Application.Version) = 9 Then hwnd = FindWindow("ThunderDFrame", .Caption) Else hwnd = FindWindow("ThunderXFrame", .Caption) End If If hwnd = 0 Then Exit Sub Else SendMessage hwnd, WM_SETICON, ICON_SMALL, ByVal hIcon SendMessage hwnd, WM_SETICON, ICON_BIG, ByVal hIcon DrawMenuBar hwnd End If End With End Sub Then run the Sub LoadForma and there is your userform with icon. RBS "ExcelMonkey" wrote in message ... How do you load an image into the top left hand cornder of a userform. For example all userforms have the small coloured trip that runs from top left to right. How do you load a small icon intot the top left of that strip? Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One more question. How would I pass a graphic to every msgbox that I have in
a routine. That is, my routine is littered with msgbox that I use to alert/promt the user to do things. Is it possible to pass this graphic to all of the Windows msgboxes used in a routine as well? Thanks "RB Smissaert" wrote: This how you can do that: Have a userform, UserForm1, with an image control, Image1. This control will show in the control toolbox as Picture. In the properties of the image control find the property Picture and in the values column browse to an .ico file of your choice. You could set the property Visible of this image control to False. In the UserForm events, in the initialize event put this: Option Explicit Private Sub UserForm_Initialize() LoadPicture End Sub Then in a normal module put all this code: Option Explicit Public Declare Function FindWindow _ Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) 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 Public Declare Function DrawMenuBar Lib "user32" _ (ByVal hwnd As Long) As Long Private Const WM_SETICON = &H80 Private Const ICON_SMALL = 0& Private Const ICON_BIG = 1& Sub LoadForm() Load UserForm1 UserForm1.Show End Sub Sub LoadPicture() Dim hIcon As Long Dim hwnd As Long With UserForm1 hIcon = .Image1.Picture If Val(Application.Version) = 9 Then hwnd = FindWindow("ThunderDFrame", .Caption) Else hwnd = FindWindow("ThunderXFrame", .Caption) End If If hwnd = 0 Then Exit Sub Else SendMessage hwnd, WM_SETICON, ICON_SMALL, ByVal hIcon SendMessage hwnd, WM_SETICON, ICON_BIG, ByVal hIcon DrawMenuBar hwnd End If End With End Sub Then run the Sub LoadForma and there is your userform with icon. RBS "ExcelMonkey" wrote in message ... How do you load an image into the top left hand cornder of a userform. For example all userforms have the small coloured trip that runs from top left to right. How do you load a small icon intot the top left of that strip? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loading UserForm gives error | Excel Programming | |||
strip minus signs from right to left | Excel Discussion (Misc queries) | |||
TAB STRIP | Excel Discussion (Misc queries) | |||
tab strip | New Users to Excel | |||
Loading UserForm on start up. | Excel Programming |