Réponse acceptée !
Merci pour votre aide les gars mais j'y suis arrivé, je vous donne le code source pour que ca puiss servir à quelqu un d autre....
unit UNewRichEdit;
interface
uses Windows, Messages, RichEdit;
type TNewRichEdit = class(TCustomRichEdit) private { Déclarations privées } FOnScroll: TNotifyEvent; MARGINWIDTH : integer; protected procedure WndProc(var Msg: TMessage); override; public { Déclarations publiques } procedure CreateWnd(); override; procedure drawMarge(); published property OnScroll: TNotifyEvent read FOnScroll write FOnScroll; end;
implementation
{ TNewRichEdit }
procedure TNewRichEdit.CreateWnd; begin inherited; SendMessage(Self.Handle, EM_SETWORDBREAKPROC, 0, LPARAM(@EditWordBreak)); LongRec(Margins).Lo := 30; LongRec(Margins).Hi := 30; MARGINWIDTH := TFrmChild(Parent).Canvas.TextWidth('0000') + 6; SendMessage(Self.Handle, EM_SETMARGINS, EC_LEFTMARGIN,MARGINWIDTH); end;
procedure TNewRichEdit.drawMarge; var Rect : TRect; sTmp : String; Canvas : TCanvas; iStart : integer; iEnd : integer; iHeightOneChar : integer; iLineVisible : integer; info: TScrollInfo; iDec : integer; begin iHeightOneChar := TFrmChild(Parent).Canvas.TextHeight('0'); FillChar(info, SizeOf(info), 0); with info do begin cbsize := SizeOf(info); fmask := SIF_ALL; GetScrollInfo(Handle, SB_VERT, info); end; iDec := 0; iStart := Perform(EM_GETFIRSTVISIBLELINE,0,0) + 1;
Canvas := TCanvas.Create; Canvas.Handle := GetWindowDC(Self.Handle); Canvas.Font.Color := clWhite; Canvas.Font.Name := Self.Font.Name; Canvas.Font.Size := Self.Font.Size; Canvas.Brush.Color := clGray;
iEnd := Perform(EM_GETLINECOUNT,0,0) + 1; iLineVisible := 0; sTmp := '';
while ((iLineVisible * iHeightOneChar < ClientHeight)) do begin if (iLineVisible >= iEnd - 1) then begin sTmp := sTmp + ' ' + #13#10; end else begin sTmp := sTmp + ' ' + IntToStr(iStart + iLineVisible) + #13#10; end; inc(iLineVisible); end; Rect.Top := 0; Rect.Left := MARGINWIDTH - 3; Rect.Right := MARGINWIDTH; Rect.Bottom := ClientHeight; Windows.FillRect(Canvas.Handle, Rect, GetStockObject(GRAY_BRUSH)); Rect.Left := 0; Rect.Top := - iDec; Rect.Right := MARGINWIDTH - 3; Windows.DrawText(Canvas.Handle, PChar(sTmp), length(sTmp), Rect, DT_RIGHT); Canvas.Font.Color := clBlack; ReleaseDC(Self.Handle, Canvas.Handle); FreeAndNil(Canvas); end;
procedure TNewRichEdit.WndProc(var Msg: TMessage); begin inherited; if Msg.Msg = WM_VSCROLL then begin drawMarge; end else if Msg.Msg = WM_PAINT then begin drawMarge; end; end;
end.
Arnaud
|