I would like to keep a reference to the main frame of my app. So, just adding this in testapp.h :
TestFrame* m_pFrame;
And assignation in testapp.cpp, when the app class creates the main frame during its initialization. But wxSmith generates its own code like this :
//(*AppInitialize
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
TestFrame* Frame = new TestFrame(0);
Frame->Show();
SetTopWindow(Frame);
}
//*)
Then, how to do the most simple, from the point I can't modify the autogenerated wxSmith code block and Frame has no existence beyond the limited {} scope. Is there an option I didn't seen in wxSmith which could do Frame becomes a member of the app class ?
Remove "//(*AppInitialize" and "//*)" and change the code however you like.
Oops :o And wxSmith will not regenerate its block of code ?
Yes, because after you remove the wxsmith markers the code becomes yours.
What do you want to achieve ?
If you are inside the frame, it should know it's own address, if you are outside, you need the address to ask for the member variable.
The easiest way to get the address of the topmost window (frame, dialog or whatever) is wxTheApp->GetTopWindow() .
Oops, solved since "long" time, jens. I didn't tagged any post as SOLVED because not any one matched exactly the solution I've adopted (I've just created a public method in app class which returns top level frame w/o relaying on any member). However, my main problem was orginally because of the wxSmith's block of code which doesn't store the pointer to the created frame as member... And I didn't liked the idea to remove the wxSmith tags (we never know the evolution of a tool by advance and he could need this code block a day or another ; better to not break natural working of tools chain in my mind).
--
EDIT : here is the fct ; also, I tag this post as SOLVED to close the thread ; it's not a self-congratulation, don't worry ;)
MyFrame* MyApp::GetMainFrame()
{
// Return a casted ptr to the toplevel frame of the app
return (MyFrame*) GetTopWindow();
}
--
EDIT #2 : I should sleep during the night... I don't see any SOLVED button ; surely mixed with the wxWidgets forum in my mind ; oops, I said ;D