1 has Frame and the other just a MessageBox
The Problem is in the example that has no frame! When it is executed it is showing a message on the screen that doesn't even exist in the program, and I don't know why!
Example with frame that works!
Code: Select all
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/msgdlg.h>
#include <wx/snglinst.h>
class MyProgram: public wxApp {
public:
wxSingleInstanceChecker *m_checker = new wxSingleInstanceChecker;
bool OnInit() {
if (m_checker->IsAnotherRunning()) {
wxLogError(_("Another program instance is already running, aborting."));
delete m_checker;
m_checker = NULL;
return false;
}
(new wxFrame(NULL, wxID_ANY, ""))->Show();
return true;
}
virtual int OnExit() {
delete m_checker;
m_checker = NULL;
return 0;
}
};
wxIMPLEMENT_APP(MyProgram);
Deleted stale lock file '/home/nick/Test2-nick'.
Code: Select all
#include <wx/app.h>
#include <wx/msgdlg.h>
#include <wx/snglinst.h>
class MyProgram: public wxApp {
public:
wxSingleInstanceChecker *m_checker = new wxSingleInstanceChecker;
bool OnInit() {
if (m_checker->IsAnotherRunning()) {
wxLogError(_("Another program instance is already running, aborting."));
delete m_checker;
m_checker = NULL;
return false;
}
wxMessageBox("Hello");
return false;
}
virtual int OnExit() {
delete m_checker;
m_checker = NULL;
return 0;
}
};
wxIMPLEMENT_APP(MyProgram);