Code:
Public Sub OwnerDrawCheckBoxW(frm As Form, obj As Object, ByVal hDC As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)
Dim hTheme As Long
Dim rc As RECT
Dim ST As Long
Dim sz As SIZE
Dim rcGlyph As RECT
Dim rcText As RECT
Dim rcFull As RECT
initOwnerDraws frm ' move obj for alignment
hTheme = OpenThemeData(frm.hWnd, StrPtr("DarkMode_Explorer::Button")) 'BUTTON
If obj.Value = vbChecked Then
ST = CBS_CHECKEDNORMAL
Else
ST = CBS_UNCHECKEDNORMAL
End If
'Check box size
GetThemePartSize hTheme, hDC, BP_CHECKBOX, ST, rcGlyph, TS_DRAW, sz
rcGlyph.Left = Left + 2
rcGlyph.Top = Top + ((Bottom - Top - sz.cy) \ 2)
rcGlyph.Right = rcGlyph.Left + sz.cx: If rcGlyph.Right < 15 Then rcGlyph.Right = 15
rcGlyph.Bottom = rcGlyph.Top + sz.cy: If rcGlyph.Bottom < 15 Then rcGlyph.Bottom = 15
rc.Left = 2
rc.Top = 2
rc.Right = rc.Left + sz.cx: If rc.Right < 15 Then rc.Right = 15 ' rc.Right = 18
rc.Bottom = rc.Top + sz.cy: If rc.Bottom < 15 Then rc.Bottom = 15 ' rc.Bottom = 18
'Draw Check Box
DrawThemeBackground hTheme, hDC, BP_CHECKBOX, ST, rc, 0
' Text zone
GetThemeBackgroundContentRect hTheme, hDC, BP_CHECKBOX, ST, rcFull, rcText
rcText.Left = rcGlyph.Right + 4
rcText.Top = Top
rcText.Right = Right - 4
rcText.Bottom = Bottom
SetBkMode hDC, TRANSPARENT
SetTextColor hDC, frm.ForeColor
DrawText hDC, obj.Caption, -1, rcText, _
DT_LEFT Or DT_WORDBREAK 'DT_LEFT Or DT_VCENTER Or DT_SINGLELINE Or DT_END_ELLIPSIS
CloseThemeData hTheme
End Sub
Public Sub OwnerDrawOptionButtonW(frm As Form, obj As Object, ByVal hDC As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)
Dim hTheme As Long
Dim rc As RECT
Dim ST As Long
Dim sz As SIZE
Dim rcGlyph As RECT
Dim rcText As RECT
Dim rcFull As RECT
initOwnerDraws frm ' move obj for alignment
hTheme = OpenThemeData(frm.hWnd, StrPtr("DarkMode_Explorer::Button")) 'BUTTON
If obj.Value = True Then
ST = RBS_CHECKEDNORMAL
Else
ST = RBS_UNCHECKEDNORMAL
End If
'Radio button size
GetThemePartSize hTheme, hDC, BP_RADIOBUTTON, ST, rcGlyph, TS_DRAW, sz
rcGlyph.Left = Left + 2
rcGlyph.Top = Top + ((Bottom - Top - sz.cy) \ 2)
rcGlyph.Right = rcGlyph.Left + sz.cx: If rcGlyph.Right < 15 Then rcGlyph.Right = 15
rcGlyph.Bottom = rcGlyph.Top + sz.cy: If rcGlyph.Bottom < 15 Then rcGlyph.Bottom = 15
rc.Left = 2
rc.Top = 2
rc.Right = rc.Left + sz.cx: If rc.Right < 15 Then rc.Right = 15
rc.Bottom = rc.Top + sz.cy: If rc.Bottom < 15 Then rc.Bottom = 15
'Draw radio button
DrawThemeBackground hTheme, hDC, BP_RADIOBUTTON, ST, rc, 0
' Text zone
GetThemeBackgroundContentRect hTheme, hDC, BP_CHECKBOX, ST, rcFull, rcText
rcText.Left = rcGlyph.Right + 4
rcText.Top = Top
rcText.Right = Right - 4
rcText.Bottom = Bottom
SetBkMode hDC, TRANSPARENT
SetTextColor hDC, frm.ForeColor
DrawText hDC, obj.Caption, -1, rcText, _
DT_LEFT Or DT_WORDBREAK 'DT_LEFT Or DT_VCENTER Or DT_SINGLELINE Or DT_END_ELLIPSIS
CloseThemeData hTheme
End Sub