Thanks for your help.
So, for anyone who reads this, a couple more things that may hopefully help you.
I was actually trying to get the HWND of my component’s parent’s parent’s parent… In such a configuration getPeer() was relying on an unbroken chain of parents up to the top level component. This is not such a hard condition to fulfill, except in constructors. This is actually one more reason why you cannot get the HWND in the constructor’s scope.
What worked for me was accessing the HWND in [color=#0080BF]resized()[/color], storing it in a member, and doing the “release-all-stuff-that-is connected with HWND”-job in destructor.
Making it in [color=#00BF00]visibilityChanged() is, in my opinion, a bad move[/color], as it possible that :
1° the visible flag of your component doesn’t change, but one of its parent’s visibility changes. As a result, your component’s “showing” (in juce’s sense) has changed, but your (child) component’s visibilityChanged isn’t called, and you don’t get a chance to the job you want with the HWND.
2° you simply are set to visible when you don’t have a parent yet, and therefore cannot get the HWND
[color=#505050]I’d like to focus on point 2° for a sec… Of course, one could say, it is possible to call resized() on a component before giving it a parent BUT : my mother always told me to add child components at construction, and call stuff like child->setBounds() NEVER at construction. My mother means it, of course, as a general rule which suffers exceptions, but if you are having the same habit than my mother and me, getting the hWnd in resized() looks like a better choice.
I hope it helps…
Please feel free to correct me if I say anything wrong…