Article ID: 141999
Article Last Modified on 7/13/2004
'*****************************************************************
' DrawFram.bas - Contains API declarations and constants for the
' DrawFrameControl API function.
'*****************************************************************
Option Explicit
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
' flags for DrawFrameControl
Public Const DFC_CAPTION = 1 'Title bar
Public Const DFC_MENU = 2 'Menu
Public Const DFC_SCROLL = 3 'Scroll bar
Public Const DFC_BUTTON = 4 'Standard button
Public Const DFCS_CAPTIONCLOSE = &H0 'Close button
Public Const DFCS_CAPTIONMIN = &H1 'Minimize button
Public Const DFCS_CAPTIONMAX = &H2 'Maximize button
Public Const DFCS_CAPTIONRESTORE = &H3 'Restore button
Public Const DFCS_CAPTIONHELP = &H4 'Windows 95 only:
'Help button
Public Const DFCS_MENUARROW = &H0 'Submenu arrow
Public Const DFCS_MENUCHECK = &H1 'Check mark
Public Const DFCS_MENUBULLET = &H2 'Bullet
Public Const DFCS_MENUARROWRIGHT = &H4
Public Const DFCS_SCROLLUP = &H0 'Up arrow of scroll
'bar
Public Const DFCS_SCROLLDOWN = &H1 'Down arrow of
'scroll bar
Public Const DFCS_SCROLLLEFT = &H2 'Left arrow of
'scroll bar
Public Const DFCS_SCROLLRIGHT = &H3 'Right arrow of
'scroll bar
Public Const DFCS_SCROLLCOMBOBOX = &H5 'Combo box scroll
'bar
Public Const DFCS_SCROLLSIZEGRIP = &H8 'Size grip
Public Const DFCS_SCROLLSIZEGRIPRIGHT = &H10 'Size grip in
'bottom-right
'corner of window
Public Const DFCS_BUTTONCHECK = &H0 'Check box
Public Const DFCS_BUTTONRADIO = &H4 'Radio button
Public Const DFCS_BUTTON3STATE = &H8 'Three-state button
Public Const DFCS_BUTTONPUSH = &H10 'Push button
Public Const DFCS_INACTIVE = &H100 'Button is inactive
'(grayed)
Public Const DFCS_PUSHED = &H200 'Button is pushed
Public Const DFCS_CHECKED = &H400 'Button is checked
Public Const DFCS_ADJUSTRECT = &H2000 'Bounding rectangle is
'adjusted to exclude the
'surrounding edge of the
'push button
Public Const DFCS_FLAT = &H4000 'Button has a flat border
Public Const DFCS_MONO = &H8000 'Button has a monochrome
'border
Public Declare Function DrawFrameControl Lib "user32" (ByVal _
hDC&, lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) _
As Boolean
'********************************************************************
' DrawFram.frm - Demonstrates how to use DrawFrameControl
'********************************************************************
Option Explicit
'********************************************************************
' Helper function that allows a you to load a rect on one line
'********************************************************************
Private Function MakeRect(l As Long, t As Long, w As Long, _
h As Long) As RECT
With MakeRect
.Left = l
.Top = t
.Right = l + w
.Bottom = t + h
End With
End Function
Private Sub Form_Load()
ScaleMode = vbPixels
AutoRedraw = True
'Captions
DrawFrameControl hDC, MakeRect(10, 10, 15, 15), DFC_CAPTION, _
DFCS_CAPTIONCLOSE
DrawFrameControl hDC, MakeRect(10, 30, 15, 15), DFC_CAPTION, _
DFCS_CAPTIONRESTORE
DrawFrameControl hDC, MakeRect(10, 50, 15, 15), DFC_CAPTION, _
DFCS_CAPTIONMAX Or DFCS_INACTIVE
' Menus
DrawFrameControl hDC, MakeRect(30, 10, 15, 15), DFC_MENU, _
DFCS_MENUARROW
DrawFrameControl hDC, MakeRect(30, 30, 15, 15), DFC_MENU, _
DFCS_MENUCHECK
DrawFrameControl hDC, MakeRect(30, 50, 15, 15), DFC_MENU, _
DFCS_MENUBULLET
' Scrollbars
DrawFrameControl hDC, MakeRect(50, 10, 15, 15), DFC_SCROLL, _
DFCS_SCROLLUP
DrawFrameControl hDC, MakeRect(50, 30, 15, 15), DFC_SCROLL, _
DFCS_SCROLLSIZEGRIP
DrawFrameControl hDC, MakeRect(50, 50, 15, 15), DFC_SCROLL, _
DFCS_SCROLLRIGHT Or DFCS_INACTIVE
' Checkboxes
DrawFrameControl hDC, MakeRect(70, 10, 15, 15), DFC_BUTTON, _
DFCS_BUTTONCHECK
DrawFrameControl hDC, MakeRect(70, 30, 15, 15), DFC_BUTTON, _
DFCS_BUTTONCHECK Or DFCS_CHECKED
DrawFrameControl hDC, MakeRect(70, 50, 15, 15), DFC_BUTTON, _
DFCS_BUTTONCHECK Or DFCS_CHECKED Or DFCS_BUTTON3STATE
' Option Buttons
DrawFrameControl hDC, MakeRect(90, 10, 15, 15), DFC_BUTTON, _
DFCS_BUTTONRADIO
DrawFrameControl hDC, MakeRect(90, 30, 15, 15), DFC_BUTTON, _
DFCS_BUTTONRADIO Or DFCS_CHECKED
DrawFrameControl hDC, MakeRect(90, 50, 15, 15), DFC_BUTTON, _
DFCS_BUTTONRADIO Or DFCS_CHECKED Or DFCS_FLAT
' Push Button
DrawFrameControl hDC, MakeRect(110, 10, 50, 20), DFC_BUTTON, _
DFCS_BUTTONPUSH
DrawFrameControl hDC, MakeRect(110, 40, 50, 20), DFC_BUTTON, _
DFCS_BUTTONPUSH Or DFCS_PUSHED
End Sub
Additional query words: THREED DRAWFRAMECONTROL kbCtrl DRAWEDGE WIN95 KBWIN32SDK
Keywords: kbhowto kbapi KB141999