Home > Back-end >  When rolling redraw richedit avoid the scroll bar
When rolling redraw richedit avoid the scroll bar

Time:10-03

Procedure TfrmXWBL. FormPaint (Sender: TObject);
Var
ACanvas: Tcanvas;
X1, X2, Y, t, I: Integer;
ByLineLength: BYTE;

The begin
ACanvas:=TCanvas. Create;
Y:=RichEdit1. Height;
Try

ACanvas. Handle:=GetDC (RichEdit1. Handle);
T:=2 + richedit1. DefAttributes. Height + 6.
ACanvas. Pen. Color:=clskyblue;
Acanvas. Pen. Width:=1;
For I:=0 to RichEdit1. Lines. Do the Count - 1
The begin
//RichEdit1.
With aCanvas do
The Begin
The Begin
MoveTo (RichEdit1. Left + 2, t);//Draw the line after 80 characters
LineTo (RichEdit1 Width 1, t);
The End;
end;
T:=t + richedit1. DefAttributes. Height + 5;
End
The Finally
ReleaseDC (RichEdit1. Handle, aCanvas. Handle).
ACanvas. Free;
The End;
end;


Everybody, I think each row in the richedit add a line space, too much, but when the contents of the richedit scroll the scroll bar will erase the original paint with good lines, is there any way when rolling the scroll bar, draw lines retain original, thank you!

CodePudding user response:

Changes occurred in the control must be redrawn, if not redraw problem will happen, you don't want to control it with the mouse choose words is not the same as you can see,

You want to keep this line, can only be realized in RichEdit onPaint event

CodePudding user response:

RichEdit onPaint event to achieve
The above code with you

CodePudding user response:

Response to redraw event, and in accordance with the picture you want to, can't stop re-paint, control function is not complete,

CodePudding user response:

RichEdit have full WMPaint news, if you can intercept to the news, add you redraw code,

CodePudding user response:

 interface 
USES the
Messages, Windows, Graphics, ComCtrls;

Type
TMyRichEdit=class (TRichEdit)
Procedure WMPaint (var Message: TWMPaint); The message the WM_PAINT;
end;

Implementation

{TMyRichEdit}

Procedure TMyRichEdit. WMPaint (var Message: TWMPaint);
Var
ACanvas: Tcanvas;
X1, X2, Y, t, I: Integer;
ByLineLength: BYTE;
The begin
Inherited;
ACanvas:=TCanvas. Create;
Y:=Self. Height;
Try
ACanvas. Handle:=GetDC (Self. Handle);
T:=2 + Self. DefAttributes. Height + 6.
ACanvas. Pen. Color:=clskyblue;
Acanvas. Pen. Width:=1;
For I:=0 to Self. Lines. Do the Count - 1
The begin
With ACanvas do
The Begin
The Begin
MoveTo (Self. Left + 2, t);//Draw the line after 80 characters
LineTo (Self. The Width - 1, t);
The End;
end;
T:=t + Self. DefAttributes. Height + 5;
End
The Finally
ReleaseDC (Self. Handle, ACanvas. Handle).
ACanvas. Free;
The End;
end;


Then dynamically create the control
  • Related