[SOLVED] Save fields to a txt

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
rocco.g
Knows some wx things
Knows some wx things
Posts: 37
Joined: Sat Feb 25, 2006 9:48 pm
Location: Italy
Contact:

[SOLVED] Save fields to a txt

Post by rocco.g » Sun Feb 26, 2006 8:52 pm

Hi! (sorry for my English...)

I know that u can open and modify a txt file by using wxwidgets and then save it with a new name.

But i would like to know if i can save in a txt also what i type in some forms...

For Example, i did this window:



Image

and the code of the buttons and forms is:

Code: Select all

	this->SetSize(8,8,440,433);
	this->SetTitle(wxT("Project1"));
	this->Center();
	this->SetIcon(wxNullIcon);
	
	////GUI Items Creation End
    WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Numero 1"), wxPoint(21,14), wxSize(93,17), 0, wxT("WxStaticText1"));
    
    WxButton1 = new wxButton(this, LboxTest_Add, wxT("Sum"), wxPoint(170,130), wxSize(75,25), 0, wxDefaultValidator);
    
    WxEdit2 = new wxTextCtrl(this, LboxTest_AddText, wxT("Num 1"), wxPoint(20,30), wxSize(121,21), 0, wxDefaultValidator );
    
    WxEdit1 = new wxTextCtrl(this, ID_WXEDIT1, wxT(""), wxPoint(20,130), wxSize(121,21), 0, wxDefaultValidator );

    WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Result"), wxPoint(21,114), wxSize(93,17), 0, wxT("WxStaticText1"));
    
    WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Numero 2"), wxPoint(21,64), wxSize(93,17), 0, wxT("WxStaticText1"));
    
    WxEdit3 = new wxTextCtrl(this, ID_WXEDIT3, wxT("Num 2"), wxPoint(20,80), wxSize(121,21), 0, wxDefaultValidator );

    WxButton_clear = new wxButton(this, LboxTest_Clear, wxT("Clear"), wxPoint(250,130), wxSize(75,25), 0, wxDefaultValidator);

    WxButton_Save = new wxButton(this, button_save, wxT("Save to txt"), wxPoint(330,130), wxSize(75,25), 0, wxDefaultValidator);
i would like to press the button "Save to txt" and then to create a txt file in the same folder where the program is run and to have this output:

numero 1: 12
numero 2: 15
result: 27


is it possible? what i have to do in order to have this?

What kind of functions or alghoritms i have to use?

Can u help me with some examples, please?

Thanks to all!
Last edited by rocco.g on Mon Feb 27, 2006 11:01 pm, edited 1 time in total.

ding
Experienced Solver
Experienced Solver
Posts: 70
Joined: Wed Jan 04, 2006 7:55 am
Location: Singapore

Post by ding » Mon Feb 27, 2006 7:57 am

On help>wxwidget>search wxFFile, that may be the one you are looking for

rocco.g
Knows some wx things
Knows some wx things
Posts: 37
Joined: Sat Feb 25, 2006 9:48 pm
Location: Italy
Contact:

Post by rocco.g » Mon Feb 27, 2006 11:56 am

thanks for ur answer!

i found out this:

Code: Select all

wxFFileOutputStream
This class represents data written to a file. There are actually two such groups of classes: this one is based on wxFFile whereas wxFileInputStream is based in the wxFile class.

i looked for some samples on google and on wxdev samples but i found nothing about this...
i'm not able to use this class with form if i don't study some samples... :(

if i use wxString string = form1->GetValue(); i can save in "string" the value of form1 but how i have to use it with wxFFile?

bool Write(const wxString& s, wxMBConv& conv = wxConvUTF8) should write the content of "string" to the file?

(sorry for my English)

tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Post by tbreina » Mon Feb 27, 2006 1:26 pm

Once again, I found this doing a simple SEARCH of the forum archives:

http://forums.wxwidgets.org/viewtopic.p ... ht=wxffile

HTH,
-Tony
Everybody's got something to hide except for me and my monkey.

rocco.g
Knows some wx things
Knows some wx things
Posts: 37
Joined: Sat Feb 25, 2006 9:48 pm
Location: Italy
Contact:

Post by rocco.g » Mon Feb 27, 2006 2:05 pm

sorry u have reason...

i searched for "save file" , "write file" and "wxFFileOutputStream" but not for "wxffile"...

sorry! :(


however... now i solved my problem!

thanks a lot!

Post Reply