problem with reappearing exceptions

thwein
thwein used Ask the Experts™
on
I wrote a program with Borland Delphi where you can
change the edit field data with upDown elements.

Following problem:
If I click on the down arrow and then the edit field value
is out of range I get an exception as wanted.
Then the old value appears again in the edit field. all OK.
Then I do this again.
Now when I click somewhere on that half of the screen that is under the upDown element, another DownClick Event is performed and I get the Exception again.
Why is the second DownClick performed?
How can I avoid this?

Following some source code.

Thanks for helping.


procedure TMainDlg._FBNumberOfPulsesExit(Sender: TObject);
begin
  try
// if value is out of range an EPulseNumberError is thrown
    FFullBridge.PulseNumber := StrI(_FBNumberOfPulses.Text);
    _FBNumberOfPulses.Text := IStr(FFullBridge.PulseNumber);
    AktChart(Sender);
  except on E: EPulseNumberError do
    begin
      ModalError('Error: ' + E.Message + ' Please correct.');
  //set back to old value  
  _FBNumberOfPulses.Text := IStr(FFullBridge.PulseNumber);
      _FBNumberOfPulses.SetFocus;
    end;
  end; {try}
end;

procedure TMainDlg._FBNumberOfPulsesUpDownClick(Sender: TObject;
  Button: TUDBtnType);
begin
  case Button of
    btNext: _FBNumberOfPulses.Text := FStr(StrF(_FBNumberOfPulses.Text) +
                                      _FBNumberOfPulsesUpDown.Increment);
    btPrev: _FBNumberOfPulses.Text := FStr(StrF(_FBNumberOfPulses.Text) -
                                      _FBNumberOfPulsesUpDown.Increment);
  end;
  _FBNumberOfPulsesExit(Sender);
end;

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Listening...

I'll try to find out also. I think it is a bug from the SpinButton. I was using them in one of the program and got the exact same problem, and sometimes, I got the DownClick more than once when clicking beside the spin... Very anoying, as I didn't want to lose time with this I just changed the component but... weird!

As to say, I don't think you're doing something wrong!
Oh, and by the way it shows in Delphi 6&7. Just out of interest, on what component are your TUpDown placed down?

Author

Commented:
The TUpDown is placed on a TGroupBox on a TNotebook - TTabSheet -  TPageControl - TMainDlg.

Which component do you use instead of it?
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

I had placed it on a TPaintBox but now I use simple TBitBtn or TSpeedButton as I changed my GUI a bit...

thwein:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Author

Commented:
Thanks for help. Sorry for being so slow.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial