wxDirPickerCtrl validator

James Bigler bigler at cs.utah.edu
Tue Jul 10 10:03:27 PDT 2007


I just recently switched from 2.6 to 2.8 on windows, and I wanted to 
make use of the new wxDirPickerCtrl class.

I tried adding a wxGenericValidator to it to transfer the directory path 
back and forth, but it doesn't seem to work.

   // filename is a wxString.
   filenameCtrl = new wxDirPickerCtrl(this, ID_CHOOSE_DIR,
                                      filename, wxT("Pick a Directory"),
                                      wxDefaultPosition, wxDefaultSize,
                                      wxDIRP_USE_TEXTCTRL);
   itemBoxSizer7->Add(filenameCtrl, 1);

   filenameCtrl->SetValidator( wxGenericValidator(&filename) );

When I run the code I get a warning message stating:

"Could not transfer data to window"

In addition, when I click OK in my dialog, the data is not transfered 
from the control to the string (filename).

I tried attaching the validator the wxTextCtrl passed back via 
wxDirPickerCtrl::GetTextCtrl(), but that didn't work either.

What kind of validator can I use to copy the directory path?

I'm using:

WinXP
wxWidgets 2.8.4
MS VS 2005 Express Edition

Thanks,
James




More information about the wx-users mailing list