Re: RadioButton - Making a choice and continuing

Posted by webmaster Guido on February 28, 2006

In Reply to Re: RadioButton - Making a choice and continuing posted by Lionel on February 27, 2006

: Thanks for the help,
: I tried the above and if the user does not make a selection and you execute the application, the message comes up saying 'You forgot to check your selection' which is good and is doing what it should but then the application hangs up and will not let you make a selection or continue. ---- At this point the user has no choice but to shut down and start over. I thought that using two RadioButtons and two Edit Boxes would be a good and simple way to make a selection but its not working out the way I expected.

Mmmm, seems I was only giving the user a few microseconds to click a radiobutton ;-)

But this time :-p I actually tested the code with a small test program:

procedure TForm1.Button1Click(Sender: TObject);
  StartTickCount: DWORD;
  // ...
  while (not RadioButton1.Checked) and
        (not RadioButton2.Checked) do begin
    ShowMessage('You forgot to check your selection');
    // As long as no radiobutton is checked,
    // repeat the message every 5000 milliseconds
    StartTickCount := GetTickCount;
    while (not RadioButton1.Checked) and
          (not RadioButton2.Checked) and
          (GetTickCount < StartTickCount + 5000) do
  // if RadioButton1.Checked ...
  // and so on...

Related Articles and Replies