[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

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;
0
pablocasta
Asked:
pablocasta
  • 2
1 Solution
 
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
 
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

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now