# Best way to show / hide / remove multiple controls

**URL:** <https://iplug2.discourse.group/t/best-way-to-show-hide-remove-multiple-controls/389>\
**Category:** Uncategorized\
**Created:** [3 May 2021 21:13 UTC](https://iplug2.discourse.group/t/best-way-to-show-hide-remove-multiple-controls/389 "2021-05-03T21:13:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![snfk](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/snfk/32/140_2.png) [@snfk](https://iplug2.discourse.group/u/snfk)\
**Post date:** [3 May 2021 21:13 UTC](https://iplug2.discourse.group/t/best-way-to-show-hide-remove-multiple-controls/389/1 "2021-05-03T21:13:28Z")

</div>

Hi everyone,  
I’m in the process of working with a lot of vector controls in different clickable panels and I’m not quite sure what the best practice is for dealing with a lot of elements’ visibility. I am currently using lambda functions, which are beginning to pile up. I tried working with groups and the `ForControlInGroup` function but got the following error:

`no suitable user-defined conversion from type to std::function<void (iplug::igraphics::IControl &control)> exists`

I’m 99% sure a pile of lambda functions isn’t the best way to approach this, so what would be?

Thanks for any help,  
Sean

---

<div class="post-metadata">

**Author:** ![Kay](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/kay/32/8_2.png) [@Kay](https://iplug2.discourse.group/u/Kay)\
**Post date:** [4 May 2021 07:24 UTC](https://iplug2.discourse.group/t/best-way-to-show-hide-remove-multiple-controls/389/2 "2021-05-04T07:24:10Z")

</div>

I have created my own tabstrip control. There I can add panels wich work as a container for all attached controls to that panel. When the tab is changed I simply hide all controls and show only those in the active tab panel.  
The controls are still attached to the regular graphics context.  
Works pretty well so far.

```
void SelectTab(int index)
{
    // Ensure the selected tab index exists
    selectedTabIndex_ = std::min(index, maxIndex_);

    // Show the selected tab panel and hide all others
    for (int i = 0; i < panels_.size(); i++)
    {
        panels_[i]->Hide(i != selectedTabIndex_);
    }
}
```

---

<div class="post-metadata">

**Author:** ![snfk](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/snfk/32/140_2.png) [@snfk](https://iplug2.discourse.group/u/snfk)\
**Post date:** [4 May 2021 13:39 UTC](https://iplug2.discourse.group/t/best-way-to-show-hide-remove-multiple-controls/389/3 "2021-05-04T13:39:07Z")

</div>

Thanks, I didn’t even think about storing controls in a vector. Everything is working now except for when I reopen the UI after closing it in FL Studio. I’m 99% sure this won’t meaning anything though:

`Exception: Access violation at address 00007FFE1853A296 in module 'StupidCompressor.vst3'. Read of address FFFFFFFFFFFFFFFF Callstack: 00007FFE180F0000:00007FFE1853A296: StupidCompressor.vst3 00007FFE180F0000:00007FFE186A85B2: StupidCompressor.vst3 00007FFE180F0000:00007FFE1852C9B1: StupidCompressor.vst3 00007FFE180F0000:00007FFE185282FE: StupidCompressor.vst3 00007FFE180F0000:00007FFE1853CA4A: StupidCompressor.vst3 00007FFE180F0000:00007FFE184F2099: StupidCompressor.vst3 00007FFE180F0000:00007FFE184F3E1A: StupidCompressor.vst3 00007FFE180F0000:00007FFE1848EB85: StupidCompressor.vst3 00007FFE180F0000:00007FFE184FA31C: StupidCompressor.vst3 00007FFE180F0000:00007FFE1851F67B: StupidCompressor.vst3 000000000CAC0000:000000000CE4D3A9: EFruity Wrapper_x64.dll 000000000CAC0000:000000000CE78A2C: EFruity Wrapper_x64.dll 000000000CAC0000:000000000CE7A54D: EFruity Wrapper_x64.dll 000000000CAC0000:000000000CE8E2C8: EFruity Wrapper_x64.dll 0000000002BA0000:00000000032F750A: FLEngine_x64.dll 0000000002BA0000:00000000032ED0BA: FLEngine_x64.dll 0000000002BA0000:00000000032ED5ED: FLEngine_x64.dll 0000000002BA0000:0000000003739E9D: FLEngine_x64.dll 0000000002BA0000:000000000373A0EF: FLEngine_x64.dll 0000000002BA0000:000000000373BACE: FLEngine_x64.dll 0000000002BA0000:00000000036C1860: FLEngine_x64.dll 0000000002BA0000:00000000036C5FD0: FLEngine_x64.dll 0000000002BA0000:00000000036C4B5E: FLEngine_x64.dll 0000000002BA0000:0000000002D4F387: FLEngine_x64.dll 0000000002BA0000:0000000002EAABCD: FLEngine_x64.dll 0000000002BA0000:0000000002D4F48E: FLEngine_x64.dll 0000000002BA0000:0000000002D4F50A: FLEngine_x64.dll 0000000002BA0000:0000000002BAF7B1: FLEngine_x64.dll 0000000002BA0000:0000000002D4EBC6: FLEngine_x64.dll 0000000002BA0000:0000000002D4E6B2: FLEngine_x64.dll 0000000002BA0000:0000000002D55201: FLEngine_x64.dll 0000000002BA0000:0000000002D558E7: FLEngine_x64.dll 0000000002BA0000:0000000002EB2830: FLEngine_x64.dll 0000000002BA0000:0000000002D54E9C: FLEngine_x64.dll 0000000002BA0000:0000000002CAC236: FLEngine_x64.dll 00007FFE75AA0000:00007FFE75AAE858: USER32.dll 00007FFE75AA0000:00007FFE75AAE299: USER32.dll 0000000002BA0000:0000000003059498: FLEngine_x64.dll 0000000002BA0000:0000000003059508: FLEngine_x64.dll 0000000002BA0000:00000000030599F8: FLEngine_x64.dll 0000000002BA0000:000000000377270A: FLEngine_x64.dll 00007FF7AEEC0000:00007FF7AEEC3BE7: FL64.exe 00007FF7AEEC0000:00007FF7AEEC400B: FL64.exe 00007FF7AEEC0000:00007FF7AEEC5287: FL64.exe 00007FFE75910000:00007FFE75927034: KERNEL32.DLL 00007FFE77410000:00007FFE77462651: ntdll.dll`

It appears to happen when I call my `HideGroup(int group)` an d `ShowGroup(int group)` functions, and only after I have closed and reopened the UI. Do the pointers for the controls need to be reinitialized? If so, how?

I am creating the controls as pointers, storing those pointers in structs that also hold a group ID, and then the struct object is the thing added to the vector array. Did you also run into this? And is there a way to fix this? Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Kay](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/kay/32/8_2.png) [@Kay](https://iplug2.discourse.group/u/Kay)\
**Post date:** [4 May 2021 13:46 UTC](https://iplug2.discourse.group/t/best-way-to-show-hide-remove-multiple-controls/389/4 "2021-05-04T13:46:55Z")

</div>

Hard to tell what’s causing the problem. Often I had problems when I had a member variable for a control. Now I recreate everything including containers when the UI is created.

---

<div class="post-metadata">

**Author:** ![snfk](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/snfk/32/140_2.png) [@snfk](https://iplug2.discourse.group/u/snfk)\
**Post date:** [4 May 2021 13:49 UTC](https://iplug2.discourse.group/t/best-way-to-show-hide-remove-multiple-controls/389/5 "2021-05-04T13:49:15Z")

</div>

I see what you mean now - I just made sure to resize the vector array to 0 and it works now. Thanks for your time!
