(C++)Displaying a char array in a CLI form

Posted by Die4Ever, 01-11-2008, 05:15 PM
It's my first time using Windows Forms, and I'm trying to display text in a textbox through code from a char array. I've tried converting the char array into a wchar_t array and then using that to initialize a CLI String and then using the append function in the textBox class to append the CLI string. It compiles, but I don't see the text when I run the program. Is there something else I have to do like lock and unlock the textbox or something?

Posted by Steve_Arm, 01-11-2008, 05:30 PM
Where does the string come from? A command line exe that you execute from the forms?

Posted by Die4Ever, 01-11-2008, 05:32 PM
Well it's like an IM program, so the char array I use is the buffer for the IM packet. But I can get the char to a wchar_t, and I think I can convert that into the CLI String, it compiles, I just can't see it.

Posted by Steve_Arm, 01-11-2008, 05:39 PM
If you are going between managed and unmanaged code you should use Marshalling. Really though post some lines.

Posted by Die4Ever, 01-11-2008, 05:41 PM
The code generated by the windows form is too much to post here, but it's just describing the window. Here's the code I'm trying to do And here's the vShowText() function Last edited by Die4Ever; 01-11-2008 at 05:51 PM. Reason: forgot the declaration of TempW

Posted by Die4Ever, 01-11-2008, 05:45 PM
oh btw, that's summarized, I do have another window with a message proc

Posted by Steve_Arm, 01-11-2008, 06:45 PM
Work on this: char* tstr = "Test, work on this"; String^ str = System::Runtime::InteropServices::Marshal:: PtrToStringAnsi((IntPtr) (char *) tstr); frm->textBox1->AppendText(str); remove the space :: P

Posted by Die4Ever, 01-11-2008, 06:53 PM
that didn't work either, it compiled, but I just didn't see the text show up

Posted by Steve_Arm, 01-11-2008, 07:03 PM
It works for me on a CLR Windows Form Application.

Posted by Steve_Arm, 01-11-2008, 07:06 PM
Change command order vShowText(PForm,"Test, this better work"); Application::Run(PForm);

Posted by Die4Ever, 01-11-2008, 07:07 PM
I'm using Visual studio 2008, not sure if that makes a difference can you send me the whole project? maybe it's a project setting die4ever2001@yahoo.com

Posted by Die4Ever, 01-11-2008, 07:08 PM
oh, well I need to be able to update the text after the window is open, cause it's a chat program

Posted by Steve_Arm, 01-11-2008, 07:10 PM
Well... frm->textBox1->Update();

Posted by Die4Ever, 01-11-2008, 07:12 PM
that doesn't fix it I also tried suspending the layout and the resuming it like the code to initialize it, but that didn't work

Posted by Steve_Arm, 01-11-2008, 07:17 PM
I've sent you the project.

Posted by Die4Ever, 01-11-2008, 09:58 PM
That doesn't append the text after you open the window, if you take out the AppendText() function call before you open the window and just use the one after it opens, it doesn't show the text

Was this answer helpful?

 Print this Article

Also Read

Configuring pureFTPd on a VPS

Posted by eta aquarii, 03-27-2008, 02:32 PMHi, I'm trying to install and configure pureFTPD on...

Darn I am missing one simple step with this PHP array please help

Posted by lexington, 02-10-2011, 09:48 AMHello, I have been up all night so my brain must be...

Looking for a Shell Script! :)

Posted by dwscenter, 01-14-2008, 01:25 AMFirst off I want to apologize if I posted this in the...

img centering in IE

Posted by bambinou, 03-05-2010, 12:17 PMHi, I am having a very stupid problem but just...

Genius-hosting??

Posted by Luminance, 09-03-2002, 06:13 PMHello guys, Is there any other company comparable to...