{"id":94,"date":"2007-05-12T13:54:37","date_gmt":"2007-05-12T11:54:37","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/how-to-draw-lines-on-trichedit-canvas\/"},"modified":"2007-05-12T13:54:39","modified_gmt":"2007-05-12T11:54:39","slug":"how-to-draw-lines-on-trichedit-canvas","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/how-to-draw-lines-on-trichedit-canvas\/","title":{"rendered":"How to draw lines on TRichEdit-Canvas?"},"content":{"rendered":"<p>[code lang=&#8221;delphi&#8221;]procedure TFormREdit.SetMaxFrame(MaxFrame:TRect);<br \/>\nvar<br \/>\n  OldMixMode : integer;<br \/>\n  DC         : hdc;<br \/>\n  Pen        : HPen;<br \/>\nbegin<br \/>\n  \/\/ Get TRichEdit Device Context (DC)<br \/>\n  DC := GetDc(Editor.Handle);<br \/>\n  \/\/ Save old mix mode<br \/>\n  OldMixMode:=GetROP2(DC);<br \/>\n  \/\/ Set XOR put<br \/>\n  SetROP2(DC,R2_XORPEN);<br \/>\n  \/\/ Set penstyle<br \/>\n  Pen:=CreatePen(PS_Dot,0,RGB(0,0,255));<br \/>\n  SelectObject(DC,Pen);<br \/>\n  \/\/ Draw a box<br \/>\n  MoveToEx(Dc, 0, 0, nil);<br \/>\n  LineTo(Dc,  0, 30);<br \/>\n  LineTo(Dc, 300, 300);<br \/>\n  LineTo(Dc, 30,  0);<br \/>\n  LineTo(Dc,  0,  0);<br \/>\n  \/\/ Reset to old state<br \/>\n  SetROP2(DC,OldMixMode); \/\/ not realy neccesary<br \/>\n  \/\/ release memory<br \/>\n  DeleteObject(Pen);<br \/>\n  ReleaseDC(Editor.Handle,DC);<br \/>\n  \/\/ save state of frame shown or not<br \/>\n  bInputFrame:=not bInputFrame;<br \/>\nend;[\/code]<\/p>\n<p>[tags]Delphi, Components, RichEdit[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[code lang=&#8221;delphi&#8221;]procedure TFormREdit.SetMaxFrame(MaxFrame:TRect); var OldMixMode : integer; DC : hdc; Pen : HPen; begin \/\/ Get TRichEdit Device Context (DC) DC := GetDc(Editor.Handle);&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[90,75,93],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-1w","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/94"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=94"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/94\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}