I'm currently writting a multiplatorm library to work with smartcards. The library itself does not have any main window, it just implements some "computing" functions. But in some situations user interaction is required (e.g. confirm or enter pin). So I want use wxWidgets in a non global way (doing some operations completly unrelated to GUI, show window then continue).
This is my GUI class. IMPLEMENT_APP_NO_MAIN is used. InitializeGUI is called in initialization of my own lib.
Code: Select all
class MyGUI: public wxApp {
public:
MyGUI() {};
virtual ~MyGUI(){
wxUninitialize();
};
static void InitializeGUI() {
wxApp::SetInstance(wxCreateApp());
wxGetApp().OnInit();
};
virtual bool OnInit(){
if(!wxInitialize())
throw ..;
m_isInit = true;
return m_isInit;
};
void CreateSignConfirmFrame(){
SignConfirm *confirm = new SignConfirm(...); // wxFrame
confirm->Show(true);
wxGetApp().OnRun();
};
bool ExportPrivateKeyMsgBox(const std::string& keyName) {
std::string capt = "Export";
std::string msg = "Really export %s?";
return wxMessageBox(wxString::Format(msg.c_str(), keyName.c_str()), capt.c_str(),
wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION, NULL) == wxYES;
};
..
..some other CreateFrame functions..
..
};
wxDECLARE_APP(MyGUI);
1) Is there a "correct" way of doing this, without some complex GUI control? I really just want have a few methods to show a certain window.
2) I need show one window in non-blocking way (just window with some text in it). Basically show window with some info for user and continue in program execution with this window still shown. I tried create this window in second thread, but got assertion faild: "assert 'wxThread::IsMain()' failed in wxMutexGuiLeaveOrEnter()". So I really don't know how to achive this.
Code: Select all
m_thread = new std::thread([]() {
m_dialog = new PinPadDialog(); // wxDialog
m_dialog->ShowModal();
});
Thank you.