RichEdit: Insertion char sur selection
Bonjour,
Mon but est de simuler le CTRL+SHIFT+I/U de Delphi dans mon TRichEdit :)
Voila mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| if (Shift = [ssAlt]) and (Key = 73) then
begin
length := RichEdit1.SelLength;
RichEdit1.SelLength := 0;
start := RichEdit1.SelStart;
i := RichEdit1.SelLength;
last := RichEdit1.CaretPos.Y;
RichEdit1.SelText := ' ';
while ( i <> length+start ) do
begin
if ( last = RichEdit1.CaretPos.Y ) then
begin
RichEdit1.SelStart := RichEdit1.SelStart+1;
end
else
begin
RichEdit1.SelText := ' ';
end;
RichEdit1.Refresh;
i := i+1;
end;
end; |
Bon pour le moment j'ai mis sur Alt+I, sa c'est un autre problème j'y viendrais à la fin lol
Donc mon problème, je fais une boucle et j'augmente ma position petit à petit pour en gros détecter la nouvelle ligne et donc insérer le double espace ....
Le problème est qu'au bout de la ligne, le SelStart n'augmente plus ... donc le CaretPos non plus :calim2:
Je m'y prend mal à quel moment ?
Merci