VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Allows you to paint the system stock icons (as used by messageboxes, windows etc.) onto your form

by Duncan Jones (19 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 13th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Allows you to paint the system stock icons (as used by messageboxes, windows etc.) onto your form

API Declarations


'\\ You have a royalty free right to use, reproduce, modify, publish and mess
'\\ with this code
'\\ I'd like you to visit http://www.merrioncomputing.com for updates, but
'\\ won't force you


'\\ Stock icons
Public Enum enStockIcons
IDI_WINLOGO = 32517&
IDI_APPLICATION = 32512&
IDI_ASTERISK = 32516&
IDI_EXCLAMATION = 32515&
IDI_HAND = 32513&
IDI_QUESTION = 32514&
IDI_UNKNOWN = 32518&
End Enum

Private Declare Function LoadIconApi Lib "user32" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As Long) As Long

'\\ Drawing related...
Private Declare Function DrawIconApi Lib "user32" Alias "DrawIcon" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long



Rate Allows you to paint the system stock icons (as used by messageboxes, windows etc.) onto your form




Dim lRet As Long

lRet = LoadIconApi(0, StockIcon)
If Err.LastDllError = 0 Then
    LoadSystemIcon = lRet
End If

End Function

Public Sub DrawIcon(ByVal mHdc As Long,ByVal xPos As Long, ByVal yPos As Long, ByVal hIcon As Long)

Dim lRet As Long

lRet = DrawIconApi(mHDC, xPos, yPos, hIcon)
If (Err.LastDllError > 0) Or (lRet = 0) Then
    Debug.Print "DrawIcon failed"
End If

End Sub


Private Sub Form_Paint()

'...yadda yadda 
Dim hIcon As Long

hIcon = LoadSystemIcon(IDI_QUESTION)
If hIcon > 0 Then
   Call DrawIcon(me.hdc, 20,20,hIcon)
End If

End Sub


Download this snippet    Add to My Saved Code

Allows you to paint the system stock icons (as used by messageboxes, windows etc.) onto your form Comments

No comments have been posted about Allows you to paint the system stock icons (as used by messageboxes, windows etc.) onto your form. Why not be the first to post a comment about Allows you to paint the system stock icons (as used by messageboxes, windows etc.) onto your form.

Post your comment

Subject:
Message:
0/1000 characters