wxMSW2.8.3 - 'OnOK' : is not a member of 'wxDialog' ??

Carsten A. Arnholm arnholm at offline.no
Wed Apr 18 11:49:59 PDT 2007


Vadim Zeitlin wrote:
> On Wed, 18 Apr 2007 01:38:37 +0200 "Carsten A. Arnholm"
> <arnholm at offline.no> wrote:
>
>> Ok, Many thanks for that. It does make things clearer. I wasn't
>> aware of any abuse.
>
> In general you shouldn't call the event handlers directly, including
> the those of the base class.

Ok, thank you. I will keep that in mind.

> You're not using wxUniv (which uses the headers in wx/univ
> subdirectory).

Yes, I think I understand what happened now, I pointed to "wxDialog" in my 
class and used the IDE's "Go to definition" feature. I ended up in 
wxWidgets-2.8.3\include\wx\univ\dialog.h and obviously I was misled, since I 
was on Windows XP and now I realise I should have been looking at 
wxWidgets-2.8.3\include\wx\dialog.h instead.

>> Evaluating TextCtrl1->GetValue(); before  event.Skip(); will not
>> work, but after it has completed it seems ok. Is this safe?
>
> It's safe but it's completely and utterly equivalent to calling it
> before, event.Skip() just indicates that the base class handler will
> be called but
> doesn't call it at all so there is absolutely no difference between
> using TextCtrl1 before and after it.

Hmm. Well, I must admit that what I am trying to do is really find the 
equivalent and proper wxWidgets pattern to using OnOk handlers in MFC where 
one might use UpdateData(TRUE) to get the dialog members updated and reflect 
the controls, and then use the values within the OnOk function..

> Anyhow, if you want to do something after the changes in the dialog
> were successfully accepted, don't do it in OnOK() at all, just do it
> after calling ShowModal().

I can see that working.

There are still some thoughts around that approach. First, I would like to 
have the actions performed in the dialog class itself (I might have a large 
number of reusable dialog classes). Maybe that can be done by overloading 
the virtual function ShowModal()

int Settings::ShowModal()
{
   int retval = wxDialog::ShowModal();
   if(wxID_OK == retval) {
       // changes accepted, do "OnOk" handling here
    }
   return retval;
}

But that only solves the issue for the case where the dialog is used 
modally, not when it is modeless....

Maybe validators can help, I must read more.

Best regards
Carsten A. Arnholm
http://arnholm.org/
N59.776 E10.457 








More information about the wx-users mailing list