I have had a look at both of those links,
Code: Select all
void BasicFrame::OnOpenFile( wxCommandEvent & event )
{
wxFileDialog* openFileDialog =
new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
wxOPEN, wxDefaultPosition);
if ( openFileDialog->ShowModal() == wxID_OK )
{
SetCurrentFilename(openFileDialog->GetFilename());
theText->LoadFile(openFileDialog->GetFilename());
SetStatusText(GetCurrentFilename(), 0);
SetStatusText(openFileDialog->GetDirectory(),1);
}
}
http://wiki.wxwidgets.org/Beech:Using_common_dialogs This didn't help, theText was not declared, I have no idea what it is (ie string...), and the compiler complains that it han't been declared. The compiler doesn't like the SetCurrentFilename and SetStatusText either, it says they havent been declared either. I tried adding the include file for file dialogs, and it the compiler still says the same thing.
#include <wx/filedlg.h>
When I looked at wxTextInputStream
http://docs.wxwidgets.org/2.8.6/wx_wxte ... readstring
I found this code as an example:
Code: Select all
wxFileInputStream input( "mytext.txt" );
wxTextInputStream text( input );
wxUint8 i1;
float f2;
wxString line;
text >> i1; // read a 8 bit integer.
text >> i1 >> f2; // read a 8 bit integer followed by float.
text >> line; // read a text line
Which needs the include file <wx/txtstrm.h>. When i try that the compiler says wxFileInputStream and wxTextInputStream havent been declared.
The last link
http://docs.wxwidgets.org/stable/wx_wxfiledialog.html I dont know what to use to get information from a text file to a string:
wxFileDialog::wxFileDialog
wxFileDialog::~wxFileDialog
wxFileDialog::GetDirectory
wxFileDialog::GetFilename
wxFileDialog::GetFilenames
wxFileDialog::GetFilterIndex
wxFileDialog::GetMessage
wxFileDialog::GetPath
wxFileDialog::GetPaths
wxFileDialog::GetWildcard
wxFileDialog::SetDirectory
wxFileDialog::SetFilename
wxFileDialog::SetFilterIndex
wxFileDialog::SetMessage
wxFileDialog::SetPath
wxFileDialog::SetWildcard
wxFileDialog::ShowModal
None of them look like anything I can use to do it with.
And my c++ programming book hasn't got anything in about file input output.
I dont know enough to know whats wrong with the code I have tried, and all of it hasn't worked.
Can anyone please post a quick snippet of code that will get everything from a text file into a string?
This will really help me out, I can't do it by myself (yet), but I am right at the end of my program, and I was hoping to finish it off.
Thanks
Mark