Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleDisplay the standard icons used by MsgBox (exclamation, information, etc.) with LoadImage
Keywordsicon, standard icon, MsgBox, exclamation, information, question, critical, winlogo, API, LoadImage
CategoriesGraphics
 
Use the GetSystemMetrics API function to see how big icons are on the system. Use the LoadImage API function to load the icons and use the DrawIcon function to display them.
 
Private Sub Form_Load()
Dim h_icon  As Long
Dim icon_wid As Long
Dim icon_hgt As Long
Dim icons As Collection
Dim i As Integer

    ' See how big the icons are.
    icon_wid = GetSystemMetrics(SM_CXICON)
    icon_hgt = GetSystemMetrics(SM_CYICON)

    ScaleMode = vbPixels

    ' Make a list of the icons.
    Set icons = New Collection
    icons.Add OIC_BANG
    icons.Add OIC_HAND
    icons.Add OIC_NOTE
    icons.Add OIC_QUES
    icons.Add OIC_SAMPLE

    ' Draw the icons.
    For i = 1 To icons.Count
        If i > 1 Then
            Load picIcon(i - 1)
            picIcon(i - 1).Left = picIcon(i - 2).Left + _
                picIcon(i - 2).Width + picIcon(0).Left
        End If
        With picIcon(i - 1)
            .BorderStyle = vbBSNone
            .Width = icon_wid
            .Height = icon_hgt
            .AutoRedraw = True
            h_icon = LoadImage(0, icons(i), _
                IMAGE_ICON, 0, 0, _
                LR_DEFAULTSIZE Or LR_SHARED Or _
                    LR_DEFAULTCOLOR)
            DrawIcon .hdc, 0, 0, h_icon
            .Visible = True
            DestroyIcon h_icon
        End With
    Next i

    ScaleMode = vbTwips
    Width = picIcon(i - 2).Left + picIcon(i - 2).Width + _
        picIcon(0).Left + Width - ScaleWidth
    Height = 2 * picIcon(0).Top + picIcon(0).Height + _
        Height - ScaleHeight
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated