I know this is probobly an easy one, but I didn't find much on it. I'm looking for the best method to get the children to detect the parents size.
i.e. Parent is resized, childern detect the parents resize and take action to resize themselves.
Get children to detect parent event? Topic is solved
-
- Earned some good credits
- Posts: 103
- Joined: Sun Aug 05, 2007 5:49 am
-
- Super wx Problem Solver
- Posts: 426
- Joined: Mon May 29, 2006 10:50 pm
- Location: Jena, Germany
The most cleanest solution is to use a wxSizer or rather a derivate of it. Define some flags on how the child should be resized and the framework will do the rest. There are samples on how to do it.
OS: Windows XP Home, Compiler: MingW, Version: wxWidgets 2.8.0, IDE: wx-Devcpp
-
- Super wx Problem Solver
- Posts: 264
- Joined: Mon Aug 07, 2006 3:25 pm
- Location: Baia Mare, Romania
- Contact:
It's a simple one
You can do it like this
Or, if it's not a custom component
But if you are looking for ayout and stuff, try to use wxSizer. It does all the calculations and much more that is needed for a clean and neat layouyt.
Regards[/code]
You can do it like this
Code: Select all
class wxMyChildWindow : public wxWindow
{
public:
wxMyChildWindow(wxWindow * pParent) : wxWindow(pParent)
{
Connect(pParent->GetId(), wxEVT_SIZE, wxSizeEventHandler(wxMyChildWindow::OnParentResize()), 0L, this );
}
void OnParentResize(wxSizeEvent & event)
{
// do something here
// You can either use GetParent() and use GetSize() or similar methods
// or you can use the properties of the event.
// For more read the wxSizeEvent documentation :)
}
};
Code: Select all
void MyClass::CreateTextCtrl(wxWindow * pParent)
{
// ... //
wxTextCtrl * pTextCtrl = new wxTextCtrl(pParent, wxId_ANY, "");
pTextCtrl->Connect(pParent->GetId(), wxEVT_SIZE, wxSizeEventHandler(MyClass::OnParentResize()), 0L, this);
}
void MyClass::OnParentResize(wxSizeEvent & event)
{
// ur code
}
Regards[/code]
Software is like sex,
It's better when it's free.
~Linus Torvalds
It's better when it's free.
~Linus Torvalds