Jump to content


Need help visualc++ being difficult


5 replies to this topic

#1 c0mputer-fr0d

    Member

  • Members
  • PipPip
  • 30 posts

Posted 05 August 2012 - 11:08 PM

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.

#2 Stainless

    Member

  • Members
  • PipPipPipPip
  • 577 posts
  • LocationSouthampton

Posted 06 August 2012 - 09:15 AM

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

#3 c0mputer-fr0d

    Member

  • Members
  • PipPip
  • 30 posts

Posted 07 August 2012 - 05:03 PM

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

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

#4 TheNut

    Senior Member

  • Moderators
  • 1696 posts
  • LocationThornhill, ON

Posted 07 August 2012 - 06:20 PM

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.
http://www.nutty.ca - Being a nut has its advantages.

#5 Stainless

    Member

  • Members
  • PipPipPipPip
  • 577 posts
  • LocationSouthampton

Posted 08 August 2012 - 09:23 AM

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

#6 c0mputer-fr0d

    Member

  • Members
  • PipPip
  • 30 posts

Posted 10 August 2012 - 02:04 PM

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users