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
 
 
 
 
 
TitleUse standard system images (min, max, restore, help, scroll arrows, etc.) to make a button
Keywordsframe, draw frame, buttons, help, close, min, max, restore, scroll
CategoriesGraphics, Windows
 
Thanks to Neil Crosby.

Use the DrawFrameControl API function. It takes as parameters a device context on which to draw, a RECT structure indicating where to draw, a frame image type, and a frame image state. The state may include a modifier indicating disabled, pushed, etc.

The DrawFrame subroutine shown in the following code wraps this API call.

 
' Draw a frame control image.
Private Sub DrawFrame(ByVal hDC As Long, ByVal X As Long, _
    ByVal Y As Long, ByVal wid As Long, ByVal hgt As Long, _
    ByVal frame_type As Long, ByVal frame_state As Long, _
    Optional ByVal frame_status As Long = 0)
Dim r As RECT

    With r
        .Left = X
        .Right = X + wid
        .Top = Y
        .Bottom = Y + hgt
    End With

    DrawFrameControl hDC, r, frame_type, frame_state Or _
        frame_status
End Sub
 
The program uses the following code to display appropriate up and down images when the user clicks on the button.
 
Private Sub btnControl_MouseDown(Button As Integer, Shift _
    As Integer, X As Single, Y As Single)
    btnControl.Picture = LoadPicture()
    DrawFrame btnControl.hDC, 0, 0, 16, 14, DFC_CAPTION, _
        DFCS_CAPTIONCLOSE, DFCS_CHECKED
End Sub

Private Sub btnControl_MouseUp(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    btnControl.Picture = LoadPicture()
    DrawFrame btnControl.hDC, 0, 0, 16, 14, DFC_CAPTION, _
        DFCS_CAPTIONCLOSE
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated