Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Loading graphic into top left strip of userform

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Loading graphic into top left strip of userform

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Loading graphic into top left strip of userform

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Loading graphic into top left strip of userform

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading UserForm gives error Mats Samson Excel Programming 3 August 3rd 05 08:06 AM
strip minus signs from right to left Heather Excel Discussion (Misc queries) 2 April 21st 05 05:52 PM
TAB STRIP icebreaker914 Excel Discussion (Misc queries) 1 April 16th 05 01:24 PM
tab strip icebreaker914 New Users to Excel 1 April 16th 05 01:24 PM
Loading UserForm on start up. Kobus Excel Programming 2 April 1st 05 11:13 AM


All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"