locked
System Colors RRS feed

  • Question

  • I have an application that has a richtextbox, and options to change font color and background. The user can select from a list of preset ones or define their own custom ones. However, I want an option that changes the color to the 'active caption text' color or the 'control light light' color. This is so it can work with high contrast themes that change these colors based on theme settings.

    I can't seem to change the color in the code, because no colors under the 'system' colors category seem to be available.

    "Color.Control Light Light" does not exist.

    How can I get these system colors?

    Saturday, May 3, 2014 2:31 AM

Answers

  • I have an application that has a richtextbox, and options to change font color and background. The user can select from a list of preset ones or define their own custom ones. However, I want an option that changes the color to the 'active caption text' color or the 'control light light' color. This is so it can work with high contrast themes that change these colors based on theme settings.

    I can't seem to change the color in the code, because no colors under the 'system' colors category seem to be available.

    "Color.Control Light Light" does not exist.

    How can I get these system colors?

    Option Strict On
    
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.CenterToScreen()
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Me.BackColor = SystemColors.ControlLightLight
        End Sub
    
    End Class

    Below is using SystemColors.ActiveCaption


    La vida loca


    Saturday, May 3, 2014 3:12 AM

All replies

  • I have an application that has a richtextbox, and options to change font color and background. The user can select from a list of preset ones or define their own custom ones. However, I want an option that changes the color to the 'active caption text' color or the 'control light light' color. This is so it can work with high contrast themes that change these colors based on theme settings.

    I can't seem to change the color in the code, because no colors under the 'system' colors category seem to be available.

    "Color.Control Light Light" does not exist.

    How can I get these system colors?

    Option Strict On
    
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.CenterToScreen()
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Me.BackColor = SystemColors.ControlLightLight
        End Sub
    
    End Class

    Below is using SystemColors.ActiveCaption


    La vida loca


    Saturday, May 3, 2014 3:12 AM
  • Option Strict On
    
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.CenterToScreen()
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim C1 As Color = SystemColors.ActiveCaption
            Dim C2 As Color = SystemColors.ControlLightLight
            Me.Text = C1.A.ToString & " " & C2.A.ToString
            Dim AofARGB As Integer = CInt((CInt(C1.A.ToString) + CInt(C2.A.ToString)) / 2)
            Dim RofARGB As Integer = CInt((CInt(C1.R.ToString) + CInt(C2.R.ToString)) / 2)
            Dim GofARGB As Integer = CInt((CInt(C1.G.ToString) + CInt(C2.G.ToString)) / 2)
            Dim BofARGB As Integer = CInt((CInt(C1.B.ToString) + CInt(C2.B.ToString)) / 2)
            Me.BackColor = Color.FromArgb(AofARGB, RofARGB, GofARGB, BofARGB)
        End Sub
    
    End Class
    


    La vida loca

    Saturday, May 3, 2014 3:29 AM