User form - Picture in the caption?

  • Thread starter Thread starter Ola
  • Start date Start date
Mark Rosenkrantz said:
/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 (e-mail address removed)

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.....
 
Back
Top