Forum > SynEdit

(SOLVED) TSynEdit draw vertical line

(1/1)

xinyiman:
Hello guys. Sorry for the stupid question. But I want to draw a vertical line on a TSynEdit component between the seventh and eighth characters.

But this code not run correct


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- procedure TFrameEditorCobol.SynEdit1Paint(Sender: TObject; ACanvas: TCanvas);var   posizione_x : integer;   color1      : TColor;begin     color1    := ACanvas.Font.Color;      posizione_x := (SynEdit1.Gutter.Width + SynEdit1.CharWidth * 7)+1;     ACanvas.Pen.Color := clMoneyGreen;     ACanvas.Line(posizione_x, 0, posizione_x, SynEdit1.Height);      ACanvas.Font.Color := color1;end;  
In part it works. Because I draw the line as I want. But if I write other characters on the same line, when the line has to disappear because I'm too far to the right, the code doesn't work (because it keeps showing me the line when it should disappear or at least move to the right).

What am I doing wrong?

Martin_fr:
Maybe you need SynEdit.LeftChar ?

LeftChar is 1, if the editor is NOT scrolled.
If you scroll one char out then LeftChar = 2, and so on.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    posizione_x := (SynEdit1.Gutter.Width + SynEdit1.CharWidth * (8 - SynEdit1.LeftChar)+1;
and

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if SynEdit1.LeftChar > 8 then exit; // do not draw
Note, I increased your 7 to 8, because LeftChar subtracts 1.

xinyiman:
Thank you  ;D

Navigation

[0] Message Index

Go to full version