why doesnt this work in VC++?
I am guessing it has to do with the fact that Text is some different datatype than string but I have no idea what it might be.Code:std::string un, pw; un = fUsername->Text; pw = fPassword->Text;
why doesnt this work in VC++?
I am guessing it has to do with the fact that Text is some different datatype than string but I have no idea what it might be.Code:std::string un, pw; un = fUsername->Text; pw = fPassword->Text;
Last edited by Ken Fitlike; 07-07-2006 at 03:05 PM. Reason: fixed code tags
Uhm, what is fUsername or fPassword for that matter?
You need to give some more info on what they are...
Are they edit controls?
sorry. yes they are text fields where the user can enter information.
Are they pointers? References?
We need more information.
sorry this is my first time with vc++ so I guess I am taking the different capablities for granted. This is so simple that I kind of overlooked how it could have been interpreted. Here are all the pieces of code associated with fUsername to give some more insight. fPassword is pretty much the exact same.
here is the code attached to my button:Code:void InitializeComponent(void) { this->fUsername = (gcnew System::Windows::Forms::TextBox()); //.....skip some code // fUsername // this->fUsername->Location = System::Drawing::Point(70, 7); this->fUsername->Name = L"fUsername"; this->fUsername->Size = System::Drawing::Size(80, 20); this->fUsername->TabIndex = 0; this->fUsername->Text = L"username here"; //.... skip some code this->Controls->Add(this->fUsername);
This is my first time using visual c++, first time creating any GUI c++ app for that matter. I didnt think grabbing some text from 2 fields would give me such a headache, would have taken 2 seconds with a command line app haha. Anyway I was just following syntax I had seen in other examples but I apparently understood it wrong.Code:private: System::Void bConnect_Click(System::Object^ sender, System::EventArgs^ e) { std::string un, pw, params, path; un = fUsername->Text; pw = fPassword->Text; path = "C:\\plink.exe"; params = L" -ssh "; params += un; params += L"@server.xxx.xxx.xxx"; int r = ExecuteProcess(path, params, 0); if (r != 0){ MessageBox::Show("Error executing process", "OPTIM-App", MessageBoxButtons::OK, MessageBoxIcon::Asterisk); } }
thanks
Everything I am seeing there looks like c# to me. Is this some sort of API you are using over the top? Cus seeing System:: ... etc makes me think C# or java immediately. Please elaborate, thanks.
This looks like that C++/CLI managed crap that isn't really C++ at all.
SourceOriginally Posted by Stanley B. Lippman, Microsoft
In any case, this probably belongs on the windows board
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
Umm this is the windows board? And all that code is what was generated by vc++ when I was making my form. I agree that it doesnt really look like c++ and that why I really dont understand how to make it work. I mean I see the general idea of what it is doing but syntactically I can't figure out how to make use out of it. I hate all this managed/unmanaged bs, I just want to write my damn program like I normally would for a command line and have it work when I press a button.... anyway, can anyone tell me how to get text from those fields?
Last edited by ac251404; 07-11-2006 at 08:16 AM.
Maybe some .NET topics might help, which your code is more .NET than API
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.
Yea I have been reading a lot more and I don't know if vc++ is for me. I thought it would be easier to just whip up some forms and attach the buttons to c++ code I already had to make a simple GUI but it just ain't that easy.
I have finally resolved this issue however and it had to do with the 340973460 different strings available in visual c++. I had to use String^ instead of std::string to get the info from the text boxes, then in order to pass it to my function I had to convert the String^ into a std::string via a To_string function I found from someone else with this issue.
Is there any easier damn way to make some simple GUIs? i.e. grab a few things from text boxes and do stuff when you click a button. Maybe even output some text to the window? I'm not trying to do anything to fancy here.
thanks for all the replies
-a
I would suggest perhaps using MFC, but I am sure somewhere I would get beaten by pillow wielding-freaks.
Honestly, what compiler are you using? I can't believe it would generate mixed code such as this in C++ anyway.
I just downloaded visual c++ 2005 express and installed it, so whatever compiler is used with that. I had VS 2003 but couldnt get it to install from the CDs because it wanted to take 10 hours so I said screw it. I just wanted to make an easy GUI to test some stuff out with basically and here I am more confused than when I began haha.
By the way not all that code was generated by vc++, but most of it was. I think the only things I changed were on the button.
Last edited by ac251404; 07-11-2006 at 12:17 PM.
> Umm this is the windows board?
Wasn't this originally posted in the C++ board? Maybe I wasn't paying attention...
> I had VS 2003 but couldnt get it to install from the CDs because it wanted to take 10 hours so I said screw it.
Yeah VS 2003 is by far the longest install of any program I've had in a long time.
I suppose a language like VB or C# might be easier for making GUI apps; as for C++, I'm just plain confused sometimes as to what I should be using to be prepared for the future of windows programming, although I like Win32 because it gives plenty of control (even if it leads to ugly, horrible messes of code)
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
Just my opinion....
Use C# (is becoming widely used commercially)
OR (as I'm an old f__t, resistant to change)
Install VS2003.
Use MFC (MS WIN32 wrapper) and as you get better, more comfortable with the way MFC works move into the WIN32 API.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill