Modal Dialog, Controls disappear
Modal Dialog, Controls disappear
I'm fighting against a crazy problem.
I wrote C++ code with wxWidgets, testing on Ubuntu Desktop V20.04. Everything works fine.
Now I'm busy with RaspberryPi 4, same C++ code but with a following result:
Compiling and starting of the programm is ok.
First opening of a modal dialog is ok, shows all controls and is usable.
Closing of the dialog is ok.
Second opening of this dialog shows no controls, only a 'screenshot' of the desktop screen behind.
All Controls are usable and the mouse cursor changes for example from arrow to hand, so I can close the dialog by clicking that invisible buttton.
What could be the reason for this?
I wrote C++ code with wxWidgets, testing on Ubuntu Desktop V20.04. Everything works fine.
Now I'm busy with RaspberryPi 4, same C++ code but with a following result:
Compiling and starting of the programm is ok.
First opening of a modal dialog is ok, shows all controls and is usable.
Closing of the dialog is ok.
Second opening of this dialog shows no controls, only a 'screenshot' of the desktop screen behind.
All Controls are usable and the mouse cursor changes for example from arrow to hand, so I can close the dialog by clicking that invisible buttton.
What could be the reason for this?
Last edited by dd8ei on Fri Feb 19, 2021 7:50 pm, edited 1 time in total.
Re: Modal Dialog, Controls disappear
Hi,
Can you build and run dialogs sample?
Thank you.
Can you build and run dialogs sample?
Thank you.
Re: Modal Dialog, Controls disappear
The attaced file contains two screenshots.
The left one ist the dialog opened at first time.
The right one is the dialog opened at second or more times.
Thanks for your help in advanced.
The left one ist the dialog opened at first time.
The right one is the dialog opened at second or more times.
Thanks for your help in advanced.
Re: Modal Dialog, Controls disappear
Can you show the code where you create and show the dialog?
Can the "empty" one still be properly closed?
Can the "empty" one still be properly closed?
Use the source, Luke!
Re: Modal Dialog, Controls disappear
Hi,
Is the dialog modal or mode-less?
How do you close/hide it?
Did you build the sample?
Thank you.
Is the dialog modal or mode-less?
How do you close/hide it?
Did you build the sample?
Thank you.
Re: Modal Dialog, Controls disappear
Hi,
thanks for the quick response.
I can identify the Close-Button by reaction of the mouse cursor when it changes from arrow to hand over the button area.
With mouse click the dialog closes.
Here the code, Main class:
Setup *SetupDlg;
.
MyFrame::MyFrame(const wxString &title)
: wxFrame(NULL, wxID_ANY, title)
{
.
SetupDlg = new Setup(this);
.
}
void MyFrame::Btn_Setup_Click(wxCommandEvent &event)
{
.
SetupDlg->ShowModal();
}
Dialog class:
Setup::Setup(wxWindow* parent_Form) : wxDialog(NULL, wxID_ANY, "Setup", wxDefaultPosition, wxSize(520, 580))
{
Parent_Form = parent_Form;
wxPanel* Tuner_Panel = new wxPanel(this, wxID_ANY);
.
Btn_End = new wxButton(Tuner_Panel, wxID_ANY, "Abbruch", wxPoint(400, 490), wxSize(90, 23), 0);
Btn_End->SetFont(wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false));
Btn_End->SetCursor(wxCURSOR_HAND);
Btn_End->Bind(wxEVT_BUTTON, &Setup::Btn_End_Click, this);
}
void Setup::Btn_End_Click(wxCommandEvent& event)
{
this->Hide(); //I tried also with 'Close();'
}
I tried both, Hide and Close with same result.
I build the sample on RaspberryPi 4. Before I build and test it on RaspberryPi 3 too without any difference.
Could it be a Raspberry or Compiler problem?
Many thanks
thanks for the quick response.
The empty one can be closed properly.
I can identify the Close-Button by reaction of the mouse cursor when it changes from arrow to hand over the button area.
With mouse click the dialog closes.
Here the code, Main class:
Setup *SetupDlg;
.
MyFrame::MyFrame(const wxString &title)
: wxFrame(NULL, wxID_ANY, title)
{
.
SetupDlg = new Setup(this);
.
}
void MyFrame::Btn_Setup_Click(wxCommandEvent &event)
{
.
SetupDlg->ShowModal();
}
Dialog class:
Setup::Setup(wxWindow* parent_Form) : wxDialog(NULL, wxID_ANY, "Setup", wxDefaultPosition, wxSize(520, 580))
{
Parent_Form = parent_Form;
wxPanel* Tuner_Panel = new wxPanel(this, wxID_ANY);
.
Btn_End = new wxButton(Tuner_Panel, wxID_ANY, "Abbruch", wxPoint(400, 490), wxSize(90, 23), 0);
Btn_End->SetFont(wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false));
Btn_End->SetCursor(wxCURSOR_HAND);
Btn_End->Bind(wxEVT_BUTTON, &Setup::Btn_End_Click, this);
}
void Setup::Btn_End_Click(wxCommandEvent& event)
{
this->Hide(); //I tried also with 'Close();'
}
The Dialog is modal.
I tried both, Hide and Close with same result.
I build the sample on RaspberryPi 4. Before I build and test it on RaspberryPi 3 too without any difference.
Could it be a Raspberry or Compiler problem?
Many thanks
Re: Modal Dialog, Controls disappear
There are several issues:
1) It's recommended to create modal dialogs on the stack, not on the heap.
- get rid of "Setup *SetupDlg;"
2) Show the dialog like this
3) Close a modal dialog with EndModal();
1) It's recommended to create modal dialogs on the stack, not on the heap.
- get rid of "Setup *SetupDlg;"
2) Show the dialog like this
Code: Select all
void MyFrame::Btn_Setup_Click(wxCommandEvent &event)
{
Setup dlg();
dlg.ShowModal();
}
Code: Select all
void Setup::Btn_End_Click(wxCommandEvent& event)
{
EndModal(wxID_CANCEL); // you may want to return other values depending on the user action
// the value you pass here is returned by the ShowModal() call above and can be checked there
}
Use the source, Luke!
Re: Modal Dialog, Controls disappear
Hi doublemax,
I changed the code to your recommendations but it did not solve the problem.
Same issue like before.
I changed the code to your recommendations but it did not solve the problem.
Same issue like before.
Re: Modal Dialog, Controls disappear
Hi,
So the sample shows same behavior?
How did you build the library? What was your exact configure line?
Thank you.
So the sample shows same behavior?
How did you build the library? What was your exact configure line?
Thank you.
Re: Modal Dialog, Controls disappear
I've got the informations about install and build from: wiki.wxwidgets.org/Compiling_and_getting_started
cd ~/wx/wxWidgets-3.1.3 # I changed to wxWidgets-3.1.4
mkdir gtk-build
cd gtk-build
../configure
make -j3 # I changed to 4
sudo make install
sudo ldconfig
cd ~/wx/wxWidgets-3.1.3 # I changed to wxWidgets-3.1.4
mkdir gtk-build
cd gtk-build
../configure
make -j3 # I changed to 4
sudo make install
sudo ldconfig
Re: Modal Dialog, Controls disappear
Hi,
And then you do:
?
Are you building on the same machine as you run?
Thank you.
And then you do:
Code: Select all
cd samples/dialogs
make
./dialogs
Are you building on the same machine as you run?
Thank you.
Re: Modal Dialog, Controls disappear
I find it hard to believe that these changes made no difference at all. Can you post your whole code?
Use the source, Luke!
Re: Modal Dialog, Controls disappear
I zipped my whole project.
How can I upload the file?
How can I upload the file?
Re: Modal Dialog, Controls disappear
I did not 'make ./dialogs'. I can't find it in the wiki.ONEEYEMAN wrote: ↑Sat Feb 20, 2021 7:59 pm Hi,
And then you do:
?Code: Select all
cd samples/dialogs make ./dialogs
Are you building on the same machine as you run?
Thank you.
All was installed and build on this RaspberryPi 4.
Thank you.
Re: Modal Dialog, Controls disappear
Hi,
Don't search for that anywhere.
Just do:
And see if you can open any dialogs twice.
Thank you.
Don't search for that anywhere.
Just do:
Code: Select all
cd ~/wx/wxWidgets-3.1.3/gtk-build/samples/dialogs
make
./dialogs
Thank you.