I am using TabControl with several tabs in my application. And I am having a problem hiding a child element within the tab. I usually hide elements with
ShowWindow(hElementName, SW_HIDE))
and show them with
ShowWindow(hElementName, SW_SHOW))
But for some reason it does not work for any element that is located inside the tabs.
I have tried calling
RedrawWindow(hElementName, NULL, NULL, RDW_INVALIDATE);
RedrawWindow(hTabElementName, NULL, NULL, RDW_INVALIDATE);
RedrawWindow(hTabControlElementName, NULL, NULL, RDW_INVALIDATE);
But that did not change the behavior. Any advice on what I may be doing wrong here?
UPDATE:
Thanks, for your comments, peterchen and Jonathan Potter. I really appreciate your help with an issue. I am still having the same problem though.
What I have done so far:
- Made sure that WS_CLIPSIBLINGS and WS_CLIPCHILDREN style flags are set for the tab control and actual tab windows
- Made sure that the window handle is valid for the element I am addressing
- Made sure that the window handle is not messed around with anywhere else in the code. Now (for debugging purpose) it is only mentioned in four places in the code. When it is initialized to NULL, when the window is created using CreateWindowEx and twice in the code segment where I am showing/hiding it.
I sill get the same problem.
One more observation I have made:
My application has a functionality to be minimized to tray and then restored. I do that by hiding the main application window. So here is what I have noticed: if the element on the tab control is supposed to be hidden (and it is not), and I minimize and then restore the application, after the entire window is redrawn, the element is hidden as expected. This is why I am 100% sure that I am calling ShowWindow
on the right element and that I don't show it somewhere else in the code. It has something to do with the elements not being repainted, but I cannot understand what exactly is the issue.