Menu

#5 Win32 - examples - HostApp

closed
nobody
None
5
2002-03-22
2002-02-11
No

Hey there.

I'm not sure whether this is a bug report or a feature
request...
It's about the HostApp that is delivered somewhere in
the examples dir. After running the tests, if you
close the TestRunner window, the parent HostApp window
stays open. This way you always have to close two
windows after you're done.
Is this intentional? If not, can anyone change that?

I have found a dirty patch myself: in HostApp.cpp, in
CHostAppApp::InitInstance change these two lines:
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
to this:
m_pMainWnd->DestroyWindow();

However, I'm sure this is not the clean way. If you
run this in debug you'll see warnings come out if you
close the app. I don't know anything about MFC really
so I can't judge whether this is too dirty.

best regards,
Loko

Discussion

  • Nobody/Anonymous

    Logged In: NO

    You could try replacing HostApp with a dialog based windows
    app. Create an new Visual C++ project using the MFC
    AppWizard, choose the Dialog Based application on the first
    page of the Wizard.

    Let the wizard generate the files and then edit the
    apps .cpp file. In this change the apps InitInstance()
    member by replacing the following code:-

    CUnitTestDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
    // TODO: Place code here to handle when the dialog
    is
    // dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
    // TODO: Place code here to handle when the dialog
    is
    // dismissed with Cancel
    }

    with:

    SetRegistryKey(_T("Local AppWizard-Generated
    Applications"));

    // Create and show the test-runner dialog
    TestRunner runner;

    runner.addTest (CppUnit::TestFactoryRegistry::getRegistry
    ().makeTest());
    runner.run ();

    You'll have to include the CppUnit libs, header etc in
    project.

     
  • Baptiste Lepilleur

    • status: open --> closed
     
  • Baptiste Lepilleur

    Logged In: YES
    user_id=196852

    Running the test from MyApp::InitInstance() is indeed the
    solution. That way, when you run the test, you may not open
    the window.

     

Log in to post a comment.