ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   icon on userform (https://www.excelbanter.com/excel-programming/404252-icon-userform.html)

pswanie

icon on userform
 
is there a way i can put a icon in the blue bar next to the userform name?

FSt1

icon on userform
 
hi
i don't think so. i think it violates the naming conviction. but if you have
it saved as an image, you can put it on the form. see the form's picture
property on the form's property sheet.

Regards
FSt1

"pswanie" wrote:

is there a way i can put a icon in the blue bar next to the userform name?


RB Smissaert

icon on userform
 
need it to show in the "blue" bar

It does with me.
Could you post your code.

RBS


"pswanie" wrote in message
...
Thanx...

i get no errors now and the userform load. but the picture display in the
userform and i need it to show in the "blue" bar at the top next to the
userform caption...

is that possible?

"RB Smissaert" wrote:

Sorry, I had left that constant out:

Private Const WM_SETICON = &H80

Put this at the other constants.

RBS

"pswanie" wrote in message
...
i get a compile error
variable not defined

at this part (the first "wm_seticon" are highlighted)

If hwnd < 0 Then
SendMessage hwnd, WM_SETICON, ICON_SMALL, ByVal hIcon
SendMessage hwnd, WM_SETICON, ICON_BIG, ByVal hIcon
DrawMenuBar hwnd
End If



"pswanie" wrote:

is there a way i can put a icon in the blue bar next to the userform
name?





pswanie

icon on userform
 
Option Explicit
Private Const ICON_SMALL = 0&
Private Const wm_seticon = &H80
Private Const ICON_BIG = 1&
Private 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 Long, lParam As Any)
As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long


Private Sub UserForm_Initialize()


Dim hwnd As Long
Dim hIcon As Long


hIcon = Image1.Picture


If Val(Application.Version) = 9 Then
hwnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hwnd = FindWindow("ThunderXFrame", Me.Caption)
End If


If hwnd < 0 Then
SendMessage hwnd, wm_seticon, ICON_SMALL, ByVal hIcon
SendMessage hwnd, wm_seticon, ICON_BIG, ByVal hIcon
DrawMenuBar hwnd
End If


End Sub


RB Smissaert

icon on userform
 
Have copied your exact code and added it to a UserForm1
Added an Image control and added an icon.
Made the Image control invisible.
Added a normal module with this:

Sub start()

Load UserForm1
UserForm1.Show

End Sub

Ran this code and all working as it should.
What version of Excel do you have.
What kind of .ico file did you use?

RBS


"pswanie" wrote in message
...
Option Explicit
Private Const ICON_SMALL = 0&
Private Const wm_seticon = &H80
Private Const ICON_BIG = 1&
Private 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 Long, lParam As Any)
As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long


Private Sub UserForm_Initialize()


Dim hwnd As Long
Dim hIcon As Long


hIcon = Image1.Picture


If Val(Application.Version) = 9 Then
hwnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hwnd = FindWindow("ThunderXFrame", Me.Caption)
End If


If hwnd < 0 Then
SendMessage hwnd, wm_seticon, ICON_SMALL, ByVal hIcon
SendMessage hwnd, wm_seticon, ICON_BIG, ByVal hIcon
DrawMenuBar hwnd
End If


End Sub



pswanie

icon on userform
 
wups....!!! that my problem.... what .ico file do i need? where do i put it?
where do i get it?


"RB Smissaert" wrote:

Have copied your exact code and added it to a UserForm1
Added an Image control and added an icon.
Made the Image control invisible.
Added a normal module with this:

Sub start()

Load UserForm1
UserForm1.Show

End Sub

Ran this code and all working as it should.
What version of Excel do you have.
What kind of .ico file did you use?

RBS


"pswanie" wrote in message
...
Option Explicit
Private Const ICON_SMALL = 0&
Private Const wm_seticon = &H80
Private Const ICON_BIG = 1&
Private 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 Long, lParam As Any)
As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long


Private Sub UserForm_Initialize()


Dim hwnd As Long
Dim hIcon As Long


hIcon = Image1.Picture


If Val(Application.Version) = 9 Then
hwnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hwnd = FindWindow("ThunderXFrame", Me.Caption)
End If


If hwnd < 0 Then
SendMessage hwnd, wm_seticon, ICON_SMALL, ByVal hIcon
SendMessage hwnd, wm_seticon, ICON_BIG, ByVal hIcon
DrawMenuBar hwnd
End If


End Sub




RB Smissaert

icon on userform
 
Any normal .ico file will do.
Add the image control (this shows as a mountain and a sun in my control
Toolbox and is called Image)
Then right-click the control and do Properties
Go to picture and select it and then press the browse button and find and
add your .ico file.
Should work now.

RBS

"pswanie" wrote in message
...
wups....!!! that my problem.... what .ico file do i need? where do i put
it?
where do i get it?


"RB Smissaert" wrote:

Have copied your exact code and added it to a UserForm1
Added an Image control and added an icon.
Made the Image control invisible.
Added a normal module with this:

Sub start()

Load UserForm1
UserForm1.Show

End Sub

Ran this code and all working as it should.
What version of Excel do you have.
What kind of .ico file did you use?

RBS


"pswanie" wrote in message
...
Option Explicit
Private Const ICON_SMALL = 0&
Private Const wm_seticon = &H80
Private Const ICON_BIG = 1&
Private 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 Long, lParam As
Any)
As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long


Private Sub UserForm_Initialize()


Dim hwnd As Long
Dim hIcon As Long


hIcon = Image1.Picture


If Val(Application.Version) = 9 Then
hwnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hwnd = FindWindow("ThunderXFrame", Me.Caption)
End If


If hwnd < 0 Then
SendMessage hwnd, wm_seticon, ICON_SMALL, ByVal hIcon
SendMessage hwnd, wm_seticon, ICON_BIG, ByVal hIcon
DrawMenuBar hwnd
End If


End Sub





pswanie

icon on userform
 
worked!!!

thank you very much!! do appreciate

Phillip

"RB Smissaert" wrote:

Any normal .ico file will do.
Add the image control (this shows as a mountain and a sun in my control
Toolbox and is called Image)
Then right-click the control and do Properties
Go to picture and select it and then press the browse button and find and
add your .ico file.
Should work now.

RBS

"pswanie" wrote in message
...
wups....!!! that my problem.... what .ico file do i need? where do i put
it?
where do i get it?


"RB Smissaert" wrote:

Have copied your exact code and added it to a UserForm1
Added an Image control and added an icon.
Made the Image control invisible.
Added a normal module with this:

Sub start()

Load UserForm1
UserForm1.Show

End Sub

Ran this code and all working as it should.
What version of Excel do you have.
What kind of .ico file did you use?

RBS


"pswanie" wrote in message
...
Option Explicit
Private Const ICON_SMALL = 0&
Private Const wm_seticon = &H80
Private Const ICON_BIG = 1&
Private 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 Long, lParam As
Any)
As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long


Private Sub UserForm_Initialize()


Dim hwnd As Long
Dim hIcon As Long


hIcon = Image1.Picture


If Val(Application.Version) = 9 Then
hwnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hwnd = FindWindow("ThunderXFrame", Me.Caption)
End If


If hwnd < 0 Then
SendMessage hwnd, wm_seticon, ICON_SMALL, ByVal hIcon
SendMessage hwnd, wm_seticon, ICON_BIG, ByVal hIcon
DrawMenuBar hwnd
End If


End Sub






RB Smissaert

icon on userform
 
I knew you would get it in the end!

RBS


"pswanie" wrote in message
...
worked!!!

thank you very much!! do appreciate

Phillip

"RB Smissaert" wrote:

Any normal .ico file will do.
Add the image control (this shows as a mountain and a sun in my control
Toolbox and is called Image)
Then right-click the control and do Properties
Go to picture and select it and then press the browse button and find and
add your .ico file.
Should work now.

RBS

"pswanie" wrote in message
...
wups....!!! that my problem.... what .ico file do i need? where do i
put
it?
where do i get it?


"RB Smissaert" wrote:

Have copied your exact code and added it to a UserForm1
Added an Image control and added an icon.
Made the Image control invisible.
Added a normal module with this:

Sub start()

Load UserForm1
UserForm1.Show

End Sub

Ran this code and all working as it should.
What version of Excel do you have.
What kind of .ico file did you use?

RBS


"pswanie" wrote in message
...
Option Explicit
Private Const ICON_SMALL = 0&
Private Const wm_seticon = &H80
Private Const ICON_BIG = 1&
Private 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 Long, lParam As
Any)
As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hwnd As Long) As Long


Private Sub UserForm_Initialize()


Dim hwnd As Long
Dim hIcon As Long


hIcon = Image1.Picture


If Val(Application.Version) = 9 Then
hwnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hwnd = FindWindow("ThunderXFrame", Me.Caption)
End If


If hwnd < 0 Then
SendMessage hwnd, wm_seticon, ICON_SMALL, ByVal hIcon
SendMessage hwnd, wm_seticon, ICON_BIG, ByVal hIcon
DrawMenuBar hwnd
End If


End Sub








All times are GMT +1. The time now is 02:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com