[API]
RtlMoveMemory
RECT
DRAWITEMSTRUCT
GetBkColor
SetBkColor
GetTextColor
SetTextColor
FillRect
GetSysColor
DrawFocusRect
SendMessageA
SendMessageW
DrawTextADirect
DrawTextW

[INCLUDE]
GenericInit

[CODE]
Public Sub DrawCheckListBoxItem(ByVal lParam As Long, ByVal MsgGetText As Long)
  Dim xLong1 As Long
  Dim xLong2 As Long
  Dim xLong3 As Long
  Dim xLong4 As Long
  Dim xLong5 As Long
  Dim xType1 As DRAWITEMSTRUCT
  
  Call RtlMoveMemory(xType1, ByVal lParam, 48&)

  If Not xType1.hdc = 0& Then
    xLong1 = GetBkColor(xType1.hdc)
    xLong2 = GetTextColor(xType1.hdc)
    
    If (xType1.itemState And &H10&) Then
      Call FillRect(xType1.hdc, xType1.rcItem, 14&)
      Call SetBkColor(xType1.hdc, GetSysColor(13&))
      Call SetTextColor(xType1.hdc, GetSysColor(14&))
      Else
      Call SetBkColor(xType1.hdc, GetSysColor(5&))
      Call FillRect(xType1.hdc, xType1.rcItem, 6&)
      End If

    If Not xType1.itemID = -1& Then
      xType1.rcItem.Left = xType1.rcItem.Left + 4&
      xLong3 = xType1.rcItem.Right
      xLong4 = xType1.rcItem.Bottom - xType1.rcItem.Top
      xType1.rcItem.Right = xType1.rcItem.Left + xLong4
      
      xType1.rcItem.Top = xType1.rcItem.Top + 1&
      xType1.rcItem.Bottom = xType1.rcItem.Bottom - 2&
      Call DrawFrameControl(xType1.hdc, xType1.rcItem, 4&, &H4000& Or (xType1.itemState And &H1&) * &H400& Or (xType1.itemState And &H1&) * &H1000&)
      xType1.rcItem.Top = xType1.rcItem.Top - 1&
      xType1.rcItem.Bottom = xType1.rcItem.Bottom + 2&
      xType1.rcItem.Right = xLong3
      If IsUnicode Then
        xLong5 = SendMessageW(xType1.hwndItem, MsgGetText, xType1.itemID, ByVal ptrtemp)
        If xLong5 > 0& Then
          xType1.rcItem.Left = xType1.rcItem.Left + 4& + xLong4
          Call DrawTextW(xType1.hdc, ptrtemp, xLong5, xType1.rcItem, &H8924&)
          xType1.rcItem.Left = xType1.rcItem.Left - 8& - xLong4
          Else
          xType1.rcItem.Left = xType1.rcItem.Left - 4&
          End If
        Else
        xLong5 = SendMessageA(xType1.hwndItem, MsgGetText, xType1.itemID, ByVal ptrtemp)
        If xLong5 > 0& Then
          xType1.rcItem.Left = xType1.rcItem.Left + 4& + xLong4
          Call DrawTextADirect(xType1.hdc, ByVal ptrtemp, xLong5, xType1.rcItem, &H8924&)
          xType1.rcItem.Left = xType1.rcItem.Left - 8& - xLong4
          Else
          xType1.rcItem.Left = xType1.rcItem.Left - 4&
          End If
        End If
      End If

    Call SetBkColor(xType1.hdc, xLong1)
    Call SetTextColor(xType1.hdc, xLong2)
    If (xType1.itemState And &H10&) Then
      Call DrawFocusRect(xType1.hdc, xType1.rcItem)
      End If
    End If
  End Sub
