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

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
buttonsrtoys
Knows some wx things
Knows some wx things
Posts: 45
Joined: Mon Jul 03, 2017 12:03 am

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

Post by buttonsrtoys » Mon Jun 25, 2018 1:28 pm

I have a wxPanel with a wxComboBox and wxTreeListCtrl that render nicely like this:
HideMapFeatures0.JPG
HideMapFeatures0.JPG (16.63 KiB) Viewed 326 times
And I can use their wxWindowBase::Hide() function to hide them, like this:
HideMapFeatures1.JPG
HideMapFeatures1.JPG (11.6 KiB) Viewed 326 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 326 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()?

buttonsrtoys
Knows some wx things
Knows some wx things
Posts: 45
Joined: Mon Jul 03, 2017 12:03 am

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

Post by buttonsrtoys » Mon Jun 25, 2018 5:47 pm

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(?)

User avatar
doublemax
Moderator
Moderator
Posts: 14190
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax » Mon Jun 25, 2018 6:12 pm

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.
Use the source, Luke!

buttonsrtoys
Knows some wx things
Knows some wx things
Posts: 45
Joined: Mon Jul 03, 2017 12:03 am

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

Post by buttonsrtoys » Tue Jun 26, 2018 3:05 pm

Yes! Thanks doublemax. Resizing does restore the widgets. I added Layout() as you suggested and everything works great now.

Post Reply