ReturnCode of a wxDialog (linux problem) Topic is solved

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.
Post Reply
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

ReturnCode of a wxDialog (linux problem)

Post by xaviou »

Hi

I have a problem on using a wxDialog derived class:

I've created a small dialog witch is showing a few buttons.
When I click on a button, it makes a SetReturnCode(...) and the, hides the dialog.

Code: Select all

void MyDialog::OnButtonClick(wxCommandEvent& event)
{
  SetReturnCode(10); // for example
  Hide();
}
The calling function, in a wxFrame derived window, is like this:

Code: Select all

void MyFrame::ShowDialog()
{
  MyDialog* dlg=new MyDialog(this);
  int iRet=dlg->ShowModal();
  ....................................
  delete dlg;
}
Under linux (Ubuntu Drapper Drake), the returned value is always wxID_CANCEL
Under windows, the returned value is the correct one (10 in this example)

Is it a bug , or a known issue, or am I making a coding error ?

Thanks for your replies...
benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte »

AFAIK, you should call "EndModal(code)", instead of "SetReturnCode(code)" while in a modal dialog.

Maybe try to look at the "EndModal" function code to see what's different between Linux & Windows.
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 437
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Post by xaviou »

Hi
That's ok with EndModal(...)

I don't know why, but I was sure that EndModal() was destroying the wxDialog, and I want it to stay hidden only.
But it does not, so, that's fine.

Thanks a lot.
Post Reply