Mastodon
Programmierung

How to draw lines on TRichEdit-Canvas?

[code lang=”delphi”]procedure TFormREdit.SetMaxFrame(MaxFrame:TRect);
var
OldMixMode : integer;
DC : hdc;
Pen : HPen;
begin
// Get TRichEdit Device Context (DC)
DC := GetDc(Editor.Handle);
// Save old mix mode
OldMixMode:=GetROP2(DC);
// Set XOR put
SetROP2(DC,R2_XORPEN);
// Set penstyle
Pen:=CreatePen(PS_Dot,0,RGB(0,0,255));
SelectObject(DC,Pen);
// Draw a box
MoveToEx(Dc, 0, 0, nil);
LineTo(Dc, 0, 30);
LineTo(Dc, 300, 300);
LineTo(Dc, 30, 0);
LineTo(Dc, 0, 0);
// Reset to old state
SetROP2(DC,OldMixMode); // not realy neccesary
// release memory
DeleteObject(Pen);
ReleaseDC(Editor.Handle,DC);
// save state of frame shown or not
bInputFrame:=not bInputFrame;
end;[/code]

[tags]Delphi, Components, RichEdit[/tags]

0 Kommentare zu “How to draw lines on TRichEdit-Canvas?

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.