Need help visualc++ being difficult

E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Aug 05, 2012 at 23:08

I’m trying to make a file encrypter and password hasher so I need a random number generator for the file encrypt.
All Im trying to do is generate some numbers and then set the text of a textbox to those numbers but it won’t let me

private: System::Void button1_Click(System::Object\^ sender, System::EventArgs\^ e) {
int ki [65] = {0};
String \^ txtVal;
for(int c = 1;c < h + 1;c++){
ki[c] = rand() % 456 - 12;}
key->Text = Convert::ToString(ki);
}
It compiles but it doesn’t actually do anything when I press the button.
I even made ki a single integer and it still didn’t output it to the textbox.

5 Replies

Please log in or register to post a reply.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Aug 06, 2012 at 09:15

try invalidating the display, it may be that the textbox has changed but the changes have not made it to video memory.

If it’s a form application, this.Invalidate(); should do it

E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Aug 07, 2012 at 17:03

No luck
textBox1->Text = “this shit is bananas”;
this->textBox1->Invalidate();

I tried this but didn’t work. Thank you though

6837d514b487de395be51432d9cdd078
0
TheNut 179 Aug 07, 2012 at 18:20

You shouldn’t have to invalidate any standard controls. The control will do that for you whenever you set a property (unless you’re in a separate thread, which is a no-no). Is this .NET forms? You shouldn’t have any problems setting the text value of the control. My guess is that there’s something else at play here. Check to make sure you have a reference to the correct textbox you’re trying to modify. Make sure the control is enabled and doesn’t have a MaxLength set to 0 or some such.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Aug 08, 2012 at 09:23

Individual items in the gui auto invalidate, that is correct. However the windows form itself may not.

I have had hundreds of occasions when I have to call Invalidate() on the whole form before changes appear

E3465662c70bd9bebf3f75223a7a5ce4
0
c0mputer_fr0d 101 Aug 10, 2012 at 14:04

Fixed it by generating a new button click function. Thank you.