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
Experienced Solver
Experienced Solver
Posts: 58
Joined: Mon Jul 03, 2017 12:03 am

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

Post by buttonsrtoys »

I have a wxPanel with a wxComboBox and wxTreeListCtrl that render nicely like this:
HideMapFeatures0.JPG
HideMapFeatures0.JPG (16.63 KiB) Viewed 828 times
And I can use their wxWindowBase::Hide() function to hide them, like this:
HideMapFeatures1.JPG
HideMapFeatures1.JPG (11.6 KiB) Viewed 828 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 828 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
Experienced Solver
Experienced Solver
Posts: 58
Joined: Mon Jul 03, 2017 12:03 am

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

Post 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(?)
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post 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.
Use the source, Luke!
buttonsrtoys
Experienced Solver
Experienced Solver
Posts: 58
Joined: Mon Jul 03, 2017 12:03 am

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

Post by buttonsrtoys »

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