+ Reply to Thread
Results 1 to 2 of 2

Userform Icon

  1. #1
    Forum Contributor
    Join Date
    01-19-2006
    Posts
    142

    Userform Icon

    Hello,

    How do you set an icon/bitmap in the caption field of a userform?

    Thanks all..

  2. #2
    RB Smissaert
    Guest

    Re: Userform Icon

    Have a Userform with an Image control with in it the icon.
    Get the icon in the control by clicking the file browser button in the
    Picture property.
    I don't think the properties of the Image control matter much, but Visible
    would normally be False.

    Then in the Userform have this code:

    Option Explicit
    Private Const ICON_SMALL = 0&
    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

    Then just load the form the normal way.


    RBS



    "gti_jobert" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hello,
    >
    > How do you set an icon/bitmap in the caption field of a userform?
    >
    > Thanks all..
    >
    >
    > --
    > gti_jobert
    > ------------------------------------------------------------------------
    > gti_jobert's Profile:
    > http://www.excelforum.com/member.php...o&userid=30634
    > View this thread: http://www.excelforum.com/showthread...hreadid=521752
    >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1