private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{
char *szVersion = GetNewVersion(); // read file , returns 1.32 (example) and yes it must be a char* in my case
textBox2->Text = ? // Is this how you set the text? If so how can i convert the char* to the input type of the text box?
}
Ty for your help, sorry for stupid questions.
Windows Form Textboxes
Im running visual studio 2003. And I have created a windows form application.
Designed it in the designer with some textboxes, some buttons, etc.
When I click my button, I want the textbox to be set to a char* thats read from my file.
My question is how can I set the textbox to that text.
It's been a while since I've used C++/CLI, but you might try:
(edit) Oh wait, you're using old-school Managed C++, otherwise your .Net type *s would be ^s.
Or something like that. MC++ is truly ghetto.
textbox2->Text = gcnew System::String(szVersion);
(edit) Oh wait, you're using old-school Managed C++, otherwise your .Net type *s would be ^s.
textbox2->Text = __gc new System::String(szVersion);
Or something like that. MC++ is truly ghetto.
What's with all the people using C++/CLI these days?
Seriously, unless you're writing a managed wrapper around a native library (e.g. like what the SlimDX guys do) there's no reason to be using C++/CLI for anything. I'd rather do GUI stuff in assembly than doing it in C++/CLI!
Seriously, unless you're writing a managed wrapper around a native library (e.g. like what the SlimDX guys do) there's no reason to be using C++/CLI for anything. I'd rather do GUI stuff in assembly than doing it in C++/CLI!
Quote:Original post by Codeka
What's with all the people using C++/CLI these days?
Seriously, unless you're writing a managed wrapper around a native library (e.g. like what the SlimDX guys do) there's no reason to be using C++/CLI for anything. I'd rather do GUI stuff in assembly than doing it in C++/CLI!
QFE. I only use C++/CLI for wrapper classes to C and only if I absolutely have to. It's way easier to use WinForms in C#. I usually rewrite C code in C# instead unless it's too much of a pain.
Hey sorry guys, I have one more question.
So I got everything working now.
But answer this, Is it possible to have another form inside? Like when you click a button on the main form, a new one will pop up. But so I can use another designer to design it?
Currently I just have a message box that pops up when I click the button, but I want to put an image in it.
So I got everything working now.
But answer this, Is it possible to have another form inside? Like when you click a button on the main form, a new one will pop up. But so I can use another designer to design it?
Currently I just have a message box that pops up when I click the button, but I want to put an image in it.
Ok screw that question, this one is more simple I think.
I inserted a picture box into my form, then in the property window I added a picture from my picture album, but when I compile. I get this error
this->pictureBox1->Image = (__try_cast<System::Drawing::Image * >(resources->GetObject(S"pictureBox1.Image")));
the error is
c:\Users\HOMEOFFICE\Documents\Visual Studio Projects\wa\Form1.h(94): error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager'
The generated code shouldnt be giving me errors should it? Or is there more to do when adding a picture.
Ps. i want to include it as a resource and dont want to rely on it being on my HD
I inserted a picture box into my form, then in the property window I added a picture from my picture album, but when I compile. I get this error
this->pictureBox1->Image = (__try_cast<System::Drawing::Image * >(resources->GetObject(S"pictureBox1.Image")));
the error is
c:\Users\HOMEOFFICE\Documents\Visual Studio Projects\wa\Form1.h(94): error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager'
The generated code shouldnt be giving me errors should it? Or is there more to do when adding a picture.
Ps. i want to include it as a resource and dont want to rely on it being on my HD
Quote:Original post by RogerThat123You shouldn't be #include'ing <windows.h> in a C++/CLI project - that's what's causing this error (windows.h has a line that #define GetObject GetObjectA).
this->pictureBox1->Image = (__try_cast<System::Drawing::Image * >(resources->GetObject(S"pictureBox1.Image")));
the error is
c:\Users\HOMEOFFICE\Documents\Visual Studio Projects\wa\Form1.h(94): error C2039: 'GetObjectA' : is not a member of 'System::Resources::ResourceManager'
Just another reason that you shouldn't be doing this sort of thing in C++/CLI...
what kind of project can i create instead then? i only have visual studio 2003, is there another project type I can make that I can use a designer for?
If you're using windows forms, then you should create a C# project.
If you really want to use C++, then use a native framework and stay away from managed code (I personally like wxWidgets, others might recommend Qt or something else).
If you really want to use C++, then use a native framework and stay away from managed code (I personally like wxWidgets, others might recommend Qt or something else).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement