wxExecute Problem

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
HeReSY
Earned some good credits
Earned some good credits
Posts: 120
Joined: Fri Sep 17, 2004 8:58 pm
Location: Germany

wxExecute Problem

Post by HeReSY » Fri Oct 29, 2004 12:26 pm

Hi,

I want to write a small burning gui for cdrdao etc.
at the Beginning of the application I want to scan the scsi bus. But when I start the wxExecute in the OnInit() function, the Programm starts, but I didn't see my dialog.
So I wrote it in the constructor of my dialog. And there it works.
Now the real problem. When the app starts, I check the programm for arguments. When there is no argument, the dialog should appear. When there are some arguments, a mainframe should appear.
I don't want to write the code for scanning the scsi bus twice, for every constructor, the dialog and the mainframe.
I hope somebody can help me.

HeReSY

Guest

Post by Guest » Fri Oct 29, 2004 1:23 pm

Hello,

Maybe it would be a good idea to post the content of your ...App.h and ...App.cpp files, so that we can all have an idea of what might have gone wrong. I don't think I can be much of much help, if I'm limited to guessing...

HeReSY
Earned some good credits
Earned some good credits
Posts: 120
Joined: Fri Sep 17, 2004 8:58 pm
Location: Germany

Post by HeReSY » Fri Oct 29, 2004 5:54 pm

Ok, here is the main.cpp

Code: Select all

bool CMainApp::OnInit()
{
    wxArrayString output, error;
    wxExecute("bin\cdrdao\cdrdao scanbus", output, error);

    if(argc == 1)
    {
        m_pCreateProject = new CCreateProject((wxDialog*)NULL, IDD_CREATEPROJECT);
        m_pCreateProject->ShowModal();
        SetTopWindow(m_pCreateProject);
        return 0;
    }    
    else 
        wxMessageBox(_("Not implemented yet"),
                     _("Error starting application"));
    return 0;
}
There is nothing more in the class. No constructor and an empty destructor.

I've tested a little bit more and, I now I know, that the application is started (it is shown in the task manager), but the dialog didn't appear.

HeReSY

geon
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Tue Sep 07, 2004 4:10 pm
Location: Sweden, Uppsala

Post by geon » Fri Oct 29, 2004 6:16 pm

Create a function ScanSCSI() and call it from every constructor that needs it.

ezequielv
Earned a small fee
Earned a small fee
Posts: 19
Joined: Sun Oct 10, 2004 9:20 pm
Location: Berkshire, England

Post by ezequielv » Mon Nov 01, 2004 5:14 pm

HeReSY wrote:

Code: Select all

bool CMainApp::OnInit()
{
//...
        m_pCreateProject->ShowModal();
        SetTopWindow(m_pCreateProject);
        return 0;
//...
}
It's at least suspicious that you call wxDialog::ShowModal() in your OnInit() function. Your OnInit() function won't be resumed until the user closes the dialog there, thus (probably) rendering the SetTopWindow() call almost useless.

You could try and remove the ShowModal() call, maybe replacing it with Show(TRUE). That way execution is resumed right away and your application can use that window as the top-level one.

Good luck! :)

Post Reply