'Trackbar functions

I'm learning C++/CLI with .NET in Visual Studio.

I want to create a TrackBar, where the minimum value is RGB white and the maximum value is RGB black.

I've dropped into the Form a Label that shows the value of the TrackBar's pointer position, but I want to show it only while I'm scrolling or holding the TrackBar's pointer with the mouse. Can someone help me?

Here's the TrackBar scroll listener:

private: System::Void trackBar1_Scroll(System::Object^ sender, System::EventArgs^ e) {
    //Set label text to trackbar value
    label2->Text = trackBar1->Value.ToString();
    //Set label2 visible to show trackbar value
    label2->Visible = true;
}


Solution 1:[1]

First of all, thank you all for help! I finally decided to show the label only when trackbar is set to 0 or 100 and instead of showing up 0 or 100 it says Light or Dark. Now i need to get the trackbar to go from rgb white to rgb black and set it as system color for window background... My idea is to use GetSysColor and use the trackbar value as a multiplier for for the actual rgb system window color but i don't know how to convert this to code.

Btw, here's the code for the label behavior:

#pragma endregion
    private: System::Void trackBar1_Scroll(System::Object^ sender, System::EventArgs^ e) {
        
        label2->Text = trackBar1->Value.ToString();
        if (trackBar1->Value == 0 || trackBar1->Value == 100)
        {
            label2->Visible = true;
        }
        else
        {
            label2->Visible = false;
        }

        if (trackBar1->Value == 0)
        {
            label2->Text = "Light";
        }
        if (trackBar1->Value == 100)
        {
            label2->Text = "Dark";
        }
        
    }
    };

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thomas Basile