Page 1 of 1

Issue calling wxWindowBase::Hide() before full initialization?

Posted: Mon Jun 25, 2018 1:28 pm
by buttonsrtoys
I have a wxPanel with a wxComboBox and wxTreeListCtrl that render nicely like this:
HideMapFeatures0.JPG
HideMapFeatures0.JPG (16.63 KiB) Viewed 325 times
And I can use their wxWindowBase::Hide() function to hide them, like this:
HideMapFeatures1.JPG
HideMapFeatures1.JPG (11.6 KiB) Viewed 325 times
The problem I'm having is during my apps startup, if I call ::Hide() too soon, subsequent calls to ::Show() gives this:
HideMapFeatures2.JPG
HideMapFeatures2.JPG (11.71 KiB) Viewed 325 times
An obvious fix is to call ::Hide() further down the startup chain, but I'm working with some legacy code and it's non-trivial to do that. My question is, is there a function I can call to check whether it's too soon to call Hide()?

Re: Issue calling wxWindowBase::Hide() before full initialization?

Posted: Mon Jun 25, 2018 5:47 pm
by buttonsrtoys
The order of my screengrabs is inverted. The one with the tiny white square is what I get when I call Hide() before Wx is fully initialized(?)

Re: Issue calling wxWindowBase::Hide() before full initialization?

Posted: Mon Jun 25, 2018 6:12 pm
by doublemax
is there a function I can call to check whether it's too soon to call Hide()?
No. And there is also no golden rule about what to do in this situation. It's more or less trial-and-error.

Does the "bad" case resolve itself when you resize the window? Than it's a layout issue and can probably be fixed by a call to Layout() at the end of the method.

Re: Issue calling wxWindowBase::Hide() before full initialization?

Posted: Tue Jun 26, 2018 3:05 pm
by buttonsrtoys
Yes! Thanks doublemax. Resizing does restore the widgets. I added Layout() as you suggested and everything works great now.