Spin Edit problem

I’m working on a little word processor, and right now I’m doing the indent paragraph part. I’ve made a Form very similar to the one Word uses when you go to Format-Paragraph. The thing is I would like to put in the text property of the Spinedit eg. ‘1.5 (cm)’ and to change each time I press the arrow buttons.
Seems easy, but try it yourself …
The bug/big problem here is that I don’t know why when I put the code in the Onchange event it reads it a thousand times. Try the following, and tell me if I’m wrong, but I saw what Delphi does by doing F7 each time, and it was like if the procedure looped lots of times.

Put a SpinEdit in a form, add the following procedure and declare it, and then link the procedure with the SpinEdit’s OnChange event.

procedure TfrmParrafo.seIzquierdaChange(Sender: TObject);
begin
  indentacion := indentacion + 0.1;
  seIzquierda.Text := FloattoStr(indentacion) + ' (cm)';
end;
pablocastaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

karooCommented:
hi pablocasta,

you are changing the text of the spin edit in the OnChange event handler - this will in turn call the Onchange event again...

You cannot change the text of the spin edit in the Onchange event.

hope this helps
Ben
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
edeyCommented:
Actually, you can.  You just have to do something like this:


var
   tmp : TNotifyEvent;
begin
   tmp := seIzquierda.onChange;
   seIzquierda.onChange := nil;
   indentacion := indentacion + 0.1;
   seIzquierda.Text := FloattoStr(indentacion) + ' (cm)';
   seIzquierda.onChange := tmp;
end;

GL
Mike
0
pablocastaAuthor Commented:
wow, this helped and a lot i should say
I'm goin' to try what Mike wrote.
0
pablocastaAuthor Commented:
Tell me stupid, but i would have never thought that Ben ... I'm really amazed, you know, I got to the point of quiting staring at the monitor hours without knowing the problem was so ... so ... EASY!
However, I used Mike's code, but a '1,1 (cm) is not an integer value' error occurs, so I decided to associate an updown control with an Edit box.
Now everything works fine ...

This is for both. Thanks for all your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.