User forums > General (but related to Code::Blocks)

How to do Frame ptr be a member of app class when using wxSmith

(1/2) > >>

eranon:
I would like to keep a reference to the main frame of my app. So, just adding this in testapp.h :

--- Code: ---TestFrame* m_pFrame;
--- End code ---

And assignation in testapp.cpp, when the app class creates the main frame during its initialization. But wxSmith generates its own code like this :

--- Code: ---    //(*AppInitialize
    bool wxsOK = true;
    wxInitAllImageHandlers();
    if ( wxsOK )
    {
     TestFrame* Frame = new TestFrame(0);
     Frame->Show();
     SetTopWindow(Frame);
    }
    //*)
--- End code ---
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 ?

oBFusCATed:
Remove "//(*AppInitialize" and "//*)" and change the code however you like.

eranon:
Oops :o And wxSmith will not regenerate its block of code ?

oBFusCATed:
Yes, because after you remove the wxsmith markers the code becomes yours.

Jenna:
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() .

Navigation

[0] Message Index

[#] Next page

Go to full version