ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User form - Picture in the caption? (https://www.excelbanter.com/excel-programming/291482-user-form-picture-caption.html)

Ola[_4_]

User form - Picture in the caption?
 
Is there a way to put a picture, like bitmap, in the caption in a use
form?

/Ol

--
Message posted from http://www.ExcelForum.com


Mark Rosenkrantz[_2_]

User form - Picture in the caption?
 
/Ola;
Yes there is, but that is very very difficult.
I've only seen that once.

Check Stephen Bullens site :

http://www.bmsltd.co.uk/Excel/Default.htm

en download formfun.zip.

Then look at the code and think again if you don't know what it means.

Succes;
Mark.

More Excel ? www.rosenkrantz.nl or
--------------------------------------------------------------------

"Ola " wrote in message
...
Is there a way to put a picture, like bitmap, in the caption in a user
form?

/Ola


---
Message posted from
http://www.ExcelForum.com/




Ivan F Moala[_3_]

User form - Picture in the caption?
 
"Mark Rosenkrantz" wrote in message ...
/Ola;
Yes there is, but that is very very difficult.
I've only seen that once.

Check Stephen Bullens site :

http://www.bmsltd.co.uk/Excel/Default.htm

en download formfun.zip.

Then look at the code and think again if you don't know what it means.

Succes;
Mark.

More Excel ? www.rosenkrantz.nl or
--------------------------------------------------------------------

"Ola " wrote in message
...
Is there a way to put a picture, like bitmap, in the caption in a user
form?

/Ola


---
Message posted from
http://www.ExcelForum.com/


It isn't that differcult
Just put an Image control with an Icon in it either on a sheet or the
Userfrom
and run this code...
Assumes Picture control is called ImgIcon

Option Explicit

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 FindWindow _
Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long

Private Const WM_SETICON = &H80
Private Const ICON_SMALL = 0&
Private Const ICON_BIG = 1&

Dim hWnd As Long

'// Draw from Userform
Private Sub CommandButton1_Click()
hWnd = FindWindow(vbNullString, UserForm2.Caption)

Call SendMessage(hWnd, WM_SETICON, ICON_SMALL, ByVal
ImgIcon.Picture.Handle)
Call SendMessage(hWnd, WM_SETICON, ICON_BIG, ByVal
ImgIcon.Picture.Handle)

End Sub
'// Draw from Sheet
Private Sub CommandButton2_Click()
hWnd = FindWindow(vbNullString, UserForm2.Caption)

Call SendMessage(hWnd, WM_SETICON, ICON_SMALL, ByVal
Sheet2.Image1.Picture.Handle)
Call SendMessage(hWnd, WM_SETICON, ICON_BIG, ByVal
Sheet2.Image1.Picture.Handle)

End Sub

The above calls it from commandbuttons ... just amend to call from
initialize event.....


All times are GMT +1. The time now is 05:40 PM.

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