If you use userforms as your primary UI (user Interface) then you may wish to add a little extra to it ie. the standard Windows Icon or any icon (See below). Here is how you do this
All you need is;
1) API's - Only 2
2) Icons ( not really required as you can extract your own. See Image 2 )
3) Either an Image Control on a Userform OR Sheet or from a resource control (see example).
Here's how;
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
That's all there is to it!
Now to get a bit more, have a look @ this Userform (Image 2). This example can Extract icons from .exe and dll files as well as from Image controls. I have used a Class module for the button clicks.
This is one I started a while ago BUT never got round to finishing ... in fact it was in 2003, how time flies .... I still didn't finish the save icon bit...... but here it is any way.