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 LoadIcon
Keywordsicon, standard icon, MsgBox, exclamation, information, question, critical, winlogo, API, LoadIcon
CategoriesGraphics
 
Use the GetSystemMetrics API function to see how big icons are on the system. Use the LoadIcon 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 IDI_APPLICATION
    icons.Add IDI_QUESTION
    icons.Add IDI_INFORMATION
    icons.Add IDI_EXCLAMATION
    icons.Add IDI_ERROR
    icons.Add IDI_WINLOGO

    ' 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 = LoadIcon(0, icons(i))
            DrawIcon .hdc, 0, 0, h_icon
            .Visible = True
        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