Results 1 to 40 of 111

Thread: Windows 10 Dark Mode & VB6 apps

Threaded View

  1. #11
    Lively Member
    Join Date
    Mar 2020
    Posts
    82

    Re: Windows 10 Dark Mode & VB6 apps

    Quote Originally Posted by Mith View Post
    There is a way to get the Windows DarkMode settings/images when using the normal Windows theme by using OpenThemeData with the DarkMode-classes like "DarkMode_CFD" or "DarkMode_Explorer".
    I personally never tried that. I guess you will find more infos about this when searching for "OpenThemeData+DarkMode_Explorer".
    Thank you, it works great.

    Name:  test06.jpg
Views: 128
Size:  40.5 KB

    Here is what I have changed in my code :

    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
    Last edited by Crapahute; May 4th, 2026 at 11:16 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width