How do I get back to the main form? where's theapp

  • Thread starter Thread starter M
  • Start date Start date
M

M

I used to do this

inline CMyApp* GetApp()
{
extern CMyApp theApp;
return &theApp;
}

I've searched google and cannot find what I'm looking for? A code snippet
would be great

Thanks alot

Best Regards,
 
Maybe you can pass "this" to the second form and use it to return to the
main form when done? Not very pretty, but probably do-able.
 
Michael C said:
Maybe you can pass "this" to the second form and use it to return to the
main form when done? Not very pretty, but probably do-able.

Actually I found the solution

class MainForm
{

public static MainForm Instance
{
get
{
if (MainForm.instance == null)
MainForm.instance = new FCSim.SimScheduler();
return MainForm.instance;
}
}

private static MainForm instance;

}
 
M said:
Actually I found the solution

class MainForm
{

public static MainForm Instance
{
get
{
if (MainForm.instance == null)
MainForm.instance = new FCSim.SimScheduler();
return MainForm.instance;
}
}

private static MainForm instance;

}

Note that that implementation of the singleton pattern isn't thread-
safe.

See http://www.pobox.com/~skeet/csharp/singleton.html for more
information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top