C++CLI bug, stacking trackbars (weird visual effect and crash)

83 views Asked by At

I really need help with this but nobody is giving me any information. So I thought I'd just make a really long post detailing the issue and my code. Just as starting info this is a C++ DLL that loads the form upon loading into another program or being forcefully injected.

So first off I am stacking some trackbars. Depending on the selection of a dropdown box menu, certain trackbars will appear and some will go. Each trackbar has individual values. The best way to represent it is like a class.

Player1 -> R, G, B Trackbars Player2 -> R, G, B Trackbars

So each player has 3. Switching players in the dropdown causes these to switch. So laying it out on the designer like so:

enter image description here

It doesn't show too well but they will be directly over eachother and switch each time. In the designer you will obviously only be able to see 3 as the others are underneath the top one.

I create them like so:

        this->trackbar_TeamBlue->Location = System::Drawing::Point(491, 225);
        this->trackbar_TeamBlue->Maximum = 255;
        this->trackbar_TeamBlue->Name = L"trackbar_TeamBlue";
        this->trackbar_TeamBlue->Size = System::Drawing::Size(153, 45);
        this->trackbar_TeamBlue->TabIndex = 10;
        this->trackbar_TeamBlue->Visible = false;

This is the same with each one. On the initialisation of the form I set all the Team trackbars to not visible and all the enemy trackbars to visible:

        trackbar_TeamRed->Visible = 0;
        trackbar_TeamGreen->Visible = 0;
        trackbar_TeamBlue->Visible = 0;

        trackbar_EnemyBlue->Visible = 1;
        trackbar_EnemyGreen->Visible = 1;
        trackbar_EnemyRed->Visible = 1;

The dropdown box menu is most likely not causing the issue but it is created like this anyway:

        this->dropdown_ESPColour->BackColor = System::Drawing::SystemColors::ScrollBar;
        this->dropdown_ESPColour->FormattingEnabled = true;
        this->dropdown_ESPColour->Items->AddRange(gcnew cli::array< System::Object^  >(4) { L"Enemy", L"Team", L"Weapons", L"Bomb" });
        this->dropdown_ESPColour->Location = System::Drawing::Point(353, 177);
        this->dropdown_ESPColour->Name = L"dropdown_ESPColour";
        this->dropdown_ESPColour->Size = System::Drawing::Size(121, 21);
        this->dropdown_ESPColour->TabIndex = 0;
        this->dropdown_ESPColour->Text = L"Enemy";

So basically, whenever the index 0 is selected with the dropdown I went the TeamRed set of trackbars to be usable. And index 1, the TeamBlue trackbars to be usable. I decided to make a very simple function to switch between these if the dropdown selection is changed.

System::Void dropdown_ESPColour_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
    if (dropdown_ESPColour->SelectedIndex == 0) {
        trackbar_EnemyBlue->Visible = 1;
        trackbar_EnemyGreen->Visible = 1;
        trackbar_EnemyRed->Visible = 1;

        trackbar_TeamRed->Visible = 0;
        trackbar_TeamGreen->Visible = 0;
        trackbar_TeamBlue->Visible = 0;

    }
    else if (dropdown_ESPColour->SelectedIndex == 1) {
        trackbar_EnemyBlue->Visible = 0;
        trackbar_EnemyGreen->Visible = 0;
        trackbar_EnemyRed->Visible = 0;

        trackbar_TeamRed->Visible = 1;
        trackbar_TeamGreen->Visible = 1;
        trackbar_TeamBlue->Visible = 1;

    }
}

So building this form works fine. Loading it into a program or any other method works fine. Here is an image of the actual form loaded:

enter image description here

As you can see that works all fine and dandy. Keep note I havent changed anything as of now. That is what the form loads into. I can change all the values on these trackbars. Now trying to change to the other category, you will see that a weird visual effect occurs, a simple greyed out box with no slider appears. In the image you cant see the grey box but I can assure you, it is 100% there. For some reason the bars look white on these images and not on my screen.

enter image description here

Whenever I click on this greyed out area where they are suppose to be the form crashes. If I change the dropdown box back then they appear back again and work fine. Does anybody know what could be causing this issue?

0

There are 0 answers