Private Const DC_ACTIVE = &H1
Private Const DC_ICON = &H4
Private Const DC_TEXT = &H8
Private Const BDR_SUNKENOUTER = &H2
Private Const BDR_RAISEDINNER = &H4
Private Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
Private Const BF_BOTTOM = &H8
Private Const BF_LEFT = &H1
Private Const BF_RIGHT = &H4
Private Const BF_TOP = &H2
Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
Private Const DFC_BUTTON = 4
Private Const DFC_POPUPMENU = 5 'Only Win98/2000 !!
Private Const DFCS_BUTTON3STATE = &H10
Private Const DT_CENTER = &H1
Private Const DC_GRADIENT = &H20 'Only Win98/2000 !!
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawCaption Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long, pcRect As RECT, ByVal un As Long) As Long
Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
Private Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT) As Long
Private Declare Function DrawFrameControl Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) As Long
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Private Sub Form_Paint()
Dim R As RECT
'Clear the picture control
Picture1.Cls
'API uses pixels
Picture1.ScaleMode = vbPixels
'Set the rectangle's values
SetRect R, 0, 0, Picture1.ScaleWidth, 20
'Draw a caption on the picture box
DrawCaption Picture1.hWnd, Picture1.hdc, R, DC_ACTIVE Or DC_ICON Or DC_TEXT Or DC_GRADIENT
'Move the recatangle
OffsetRect R, 0, 22
'Draw an edge on our picture box
DrawEdge Picture1.hdc, R, EDGE_ETCHED, BF_RECT
OffsetRect R, 0, 22
'Draw a focus rectangle on our picture box
DrawFocusRect Picture1.hdc, R
OffsetRect R, 0, 22
'Draw a frame control on our picture box
DrawFrameControl Picture1.hdc, R, DFC_BUTTON, DFCS_BUTTON3STATE
OffsetRect R, 0, 22
'draw some text on our picture box
DrawText Picture1.hdc, "Hello pradeep !", Len("Hello pradeep !"), R, DT_CENTER
End Sub