Modal Dialog, Controls disappear

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
dd8ei
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Feb 19, 2021 10:36 am
Location: JO31nc

Modal Dialog, Controls disappear

Post by dd8ei »

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?
Last edited by dd8ei on Fri Feb 19, 2021 7:50 pm, edited 1 time in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Modal Dialog, Controls disappear

Post by ONEEYEMAN »

Hi,
Can you build and run dialogs sample?
Thank you.
dd8ei
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Feb 19, 2021 10:36 am
Location: JO31nc

Re: Modal Dialog, Controls disappear

Post by dd8ei »

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.
Attachments
Dialog.jpg
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Modal Dialog, Controls disappear

Post by doublemax »

Can you show the code where you create and show the dialog?

Can the "empty" one still be properly closed?
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Modal Dialog, Controls disappear

Post by ONEEYEMAN »

Hi,
Is the dialog modal or mode-less?
How do you close/hide it?

Did you build the sample?

Thank you.
dd8ei
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Feb 19, 2021 10:36 am
Location: JO31nc

Re: Modal Dialog, Controls disappear

Post by dd8ei »

Hi,
thanks for the quick response.
doublemax wrote: Fri Feb 19, 2021 8:10 pm Can you show the code where you create and show the dialog?
Can the "empty" one still be properly closed?
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();'
}
ONEEYEMAN wrote: Fri Feb 19, 2021 8:38 pm Is the dialog modal or mode-less?
How do you close/hide it?
Did you build the sample?
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
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Modal Dialog, Controls disappear

Post by doublemax »

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

Code: Select all

void MyFrame::Btn_Setup_Click(wxCommandEvent &event)
{
  Setup dlg();
  dlg.ShowModal();
}
3) Close a modal dialog with EndModal();

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!
dd8ei
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Feb 19, 2021 10:36 am
Location: JO31nc

Re: Modal Dialog, Controls disappear

Post by dd8ei »

Hi doublemax,
I changed the code to your recommendations but it did not solve the problem.
Same issue like before.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Modal Dialog, Controls disappear

Post by ONEEYEMAN »

Hi,
So the sample shows same behavior?
How did you build the library? What was your exact configure line?

Thank you.
dd8ei
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Feb 19, 2021 10:36 am
Location: JO31nc

Re: Modal Dialog, Controls disappear

Post by dd8ei »

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
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Modal Dialog, Controls disappear

Post by ONEEYEMAN »

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.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Modal Dialog, Controls disappear

Post by doublemax »

dd8ei wrote: Sat Feb 20, 2021 7:18 pm I changed the code to your recommendations but it did not solve the problem.
Same issue like before.
I find it hard to believe that these changes made no difference at all. Can you post your whole code?
Use the source, Luke!
dd8ei
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Feb 19, 2021 10:36 am
Location: JO31nc

Re: Modal Dialog, Controls disappear

Post by dd8ei »

I zipped my whole project.
How can I upload the file?
dd8ei
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Feb 19, 2021 10:36 am
Location: JO31nc

Re: Modal Dialog, Controls disappear

Post by dd8ei »

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.
I did not 'make ./dialogs'. I can't find it in the wiki.
All was installed and build on this RaspberryPi 4.

Thank you.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Modal Dialog, Controls disappear

Post by ONEEYEMAN »

Hi,
Don't search for that anywhere.
Just do:

Code: Select all

cd ~/wx/wxWidgets-3.1.3/gtk-build/samples/dialogs
make
./dialogs
And see if you can open any dialogs twice.

Thank you.
Post Reply