# CodeGuru Technical FAQs > CodeGuru Individual Visual Basic FAQs >  DrawCaption DrawEdge DrawFocusRect DrawFrameControl DrawText

## TT(n)

Draws a window caption.
Draws one or more edges of rectangle.
Draws a rectangle in the style used to indicate that the rectangle has the focus.
Draws a frame control of the specified type and style.
Draws formatted text in the specified rectangle. It formats the text according to the specified method (expanding tabs, justifying characters, breaking lines, and so forth).



```
    Const DC_ACTIVE As Int32 = 1
    Const DC_NOTACTIVE As Int32 = 2
    Const DC_ICON As Int32 = 4
    Const DC_TEXT As Int32 = 8
    Const BDR_SUNKENOUTER As Int32 = 2
    Const BDR_RAISEDINNER As Int32 = 4
    Const EDGE_ETCHED As Boolean = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
    Const BF_LEFT As Int32 = 1
    Const BF_TOP As Int32 = 2
    Const BF_RIGHT As Int32 = 4
    Const BF_BOTTOM As Int32 = 8
    Const BF_RECT As Boolean = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
    Const DFC_BUTTON As Int32 = 4
    Const DFC_POPUPMENU As Int32 = 5 
    Const DFCS_BUTTON3STATE As Int32 = 16
    Const DT_CENTER As Int32 = 1
    Const DC_GRADIENT As Int32 = 32 
    Const SM_FULLSCREEN As Int32 = 65535
    Private Declare Function apiSetRect Lib "user32" Alias "SetRect" (ByRef lpRect As RECT, ByVal X1 As Int32, ByVal Y1 As Int32, ByVal X2 As Int32, ByVal Y2 As Int32) As Int32
    Private Declare Function apiGetDC Lib "user32" Alias "GetDC" (ByVal hWnd As Int32) As Int32 
    Private Declare Function apiGetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hWnd As Int32) As Int32 
    Private Declare Function apiDrawCaption Lib "user32" Alias "DrawCaption" (ByVal hWnd As Int32, ByVal hDC As Int32, ByRef pcRect As RECT, ByVal un As Int32) As Int32
    Private Declare Function apiDrawEdge Lib "user32" Alias "DrawEdge" (ByVal hDC As Int32, ByRef qrc As RECT, ByVal edge As Int32, ByVal grfFlags As Int32) As Int32
    Private Declare Function apiDrawFocusRect Lib "user32" Alias "DrawFocusRect" (ByVal hDC As Int32, ByRef lpRect As RECT) As Int32
    Private Declare Function apiDrawFrameControl Lib "user32" Alias "DrawFrameControl" (ByVal hDC As Int32, ByRef lpRect As RECT, ByVal un1 As Int32, ByVal un2 As Int32) As Int32
    Private Declare Function apiDrawText Lib "user32" Alias "DrawTextA" (ByVal hDC As Int32, ByVal lpStr As String, ByVal nCount As Int32, ByRef lpRect As RECT, ByVal wFormat As Int32) As Int32
    Private Structure RECT
        Public rLeft, rTop, rRight, rBottom As Int32
    End Structure

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim R As New RECT
        apiSetRect(R, 0, 0, Me.Width, 30) 'Set the rectangle's values
        apiDrawCaption(Me.Handle.ToInt32, apiGetWindowDC(Me.Handle.ToInt32), R, DC_ACTIVE Or DC_ICON Or DC_TEXT Or DC_GRADIENT) 
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim R As New RECT
        apiSetRect(R, 0, 29, Me.Width, 30) 'Set the rectangle's values
        apiDrawEdge(apiGetWindowDC(Me.Handle.ToInt32), R, EDGE_ETCHED, BF_RECT) 'Draw an edge on our window
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim R As New RECT
        apiSetRect(R, 0, 0, Me.Width, 30) 'Set the rectangle's values
        apiDrawFocusRect(apiGetWindowDC(Me.Handle.ToInt32), R) 'Draw a focus rectangle on our window
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim R As New RECT
        apiSetRect(R, 0, 0, Me.Width, 30) 'Set the rectangle's values
        apiDrawFrameControl(apiGetWindowDC(Me.Handle.ToInt32), R, DFC_BUTTON, DFCS_BUTTON3STATE) 'Draw a frame control on our window
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim R As New RECT
        apiSetRect(R, 0, 0, Me.Width, 30) 'Set the rectangle's values
        apiDrawText(apiGetDC(Me.Handle.ToInt32), "Hello World !", "Hello World !".Length, R, DT_CENTER) 'Draw some text on our form
    End Sub
```

----------

