• Advertisement


This topic is now archived and is closed to further replies.

Need Help with VC++ .NET

This topic is 5207 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is what I have so far: #include <iostream> #include <string> #include <fstream> //#include <windows.h> //Sleep(3000); //#include <time.h> #using #using #using #using using namespace std; using namespace System; using namespace System::Drawing; using namespace System::Windows::Forms; __gc class COneChild : public Form { public: COneChild(void); private: TextBox *Editor; //Establish a TextBox named "Editor" }; COneChild::COneChild(void) { this->Text = "Macro1"; WindowState = FormWindowState::Maximized; Editor = new TextBox(); Editor->AcceptsReturn = true; //allow user to hit enter to go to next line Editor->AcceptsTab = true; //allow tab Editor->Multiline = true; //user can create multiple lines Editor->ScrollBars = ScrollBars::Vertical; //add verticle scroll bar Editor->WordWrap = true; //allows wrapping of text Editor->Dock = DockStyle::Fill; //occupy the whole client area Editor->Text = S""; //text in TextBox "Editor" this->Controls->Add(Editor); //add it to the form } __gc class CMainForm : public Form { public: CMainForm(void); private: MainMenu *MMenu; //establishes main menu void CreateTheMenu(); //call CreateTheMenu function void FormLoad(Object *Sender, EventArgs *Args); //call formload function void OnFileNew(Object *Sender, EventArgs *Args); //call new function void OnFileSave(Object *Sender, EventArgs *Args); //call save function void OnFileExit(Object *Sender, EventArgs *Args); //call exit function }; CMainForm::CMainForm(void) { this->Text = "WoWTool"; this->IsMdiContainer = true; this->add_Load(new EventHandler(this, FormLoad)); WindowState = FormWindowState::Maximized; CreateTheMenu(); } void CMainForm::CreateTheMenu() { MMenu = new MainMenu(); // Create a new main menu column MenuItem *mnuFile = MMenu->MenuItems->Add("&File"); //adds file mnuFile->MenuItems->Add("&New", new EventHandler(this, OnFileNew)); //new mnuFile->MenuItems->Add("&Save", new EventHandler(this, OnFileSave)); //save mnuFile->MenuItems->Add("&Exit", new EventHandler(this, OnFileExit)); //exit Menu = MMenu; //after creating the main menu, add it to the form } void CMainForm::FormLoad(Object *Sender, EventArgs *Args) { OnFileNew(Sender, Args); //creates new instance of child on startup } void CMainForm::OnFileNew(Object *Sender, EventArgs *Args) { COneChild *OC = new COneChild(); //create an instance of the Child OC->Text = S"Macro1"; OC->MdiParent = this; OC->Show(); } void CMainForm::OnFileSave(Object *Sender, EventArgs *Args) { ofstream fout; fout.open("TextBox.txt"); fout << "Saved File of Macro1, currently not working"; fout.close(); } void CMainForm::OnFileExit(Object *Sender, EventArgs *Args) { Close(); } int __stdcall WinMain() { CMainForm *MF = new CMainForm(); Application::Run(MF); return 0; } Yes, its a form compiled in VC++ .NET; it creates a parent and a child window. As you can see, when the user clicks save, it will save a .txt file saying: "Saved File of Macro1, currently not working". Is there a way I can change my save function around to save what the user types in the textbox? I know the text in the textbox is represented by Editor->Text, but I can''t seem to set it to a string, any help for a newb?

Share this post

Link to post
Share on other sites

  • Advertisement