{"id":93,"date":"2007-05-12T13:54:10","date_gmt":"2007-05-12T11:54:10","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/richedit-on-a-transparent-background\/"},"modified":"2007-05-12T13:54:11","modified_gmt":"2007-05-12T11:54:11","slug":"richedit-on-a-transparent-background","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/richedit-on-a-transparent-background\/","title":{"rendered":"Richedit on a transparent background"},"content":{"rendered":"<p><em>><br \/>\n> I would like to have a Richedit box with a transparent background.<br \/>\n><br \/>\n> To be more precise, I would like to be able to display the contents of a<br \/>\n> ..RTF file on the screen with a background graphic showing through.<br \/>\n><br \/>\n> Does anyone know how to make this happen. Presumably, it is not just a<br \/>\n> matter of putting something in the background colour property (because<br \/>\n> I&#8217;ve looked and there is not &#8220;transparent&#8221;). However, I have seen other<br \/>\n> products which do have the ability to display an .RTF file on top of a<br \/>\n> graphic.<br \/>\n<\/em><br \/>\nVon: Peter Below <\n100113.1101@compuserve.com \n \n><br \/>\nBetreff: Re: Richedit on a transparent background<br \/>\nDatum: Dienstag, 5. Januar 1999 15:27 <\/p>\n<p>The rich edit control itself cannot be made transparent without a lot of<br \/>\nproblems. But you can get it to render its text onto any kind of canvas,<br \/>\ne.g. a bitmap.canvas or a TImage canvas.<\/p>\n<p>[code lang=&#8221;delphi&#8221;]procedure TForm1.Button2Click(Sender: TObject);<br \/>\nvar<br \/>\n  imagecanvas: TCanvas;<br \/>\n  fmt: TFormatRange;<br \/>\nbegin<br \/>\n  imagecanvas := image1.canvas;<br \/>\n  with fmt do begin<br \/>\n    hdc:= imagecanvas.handle;<br \/>\n    hdcTarget:= hdc;<br \/>\n    \/\/ rect needs to be specified in twips (1\/1440 inch) as unit<br \/>\n    rc:=  Rect( 0, 0,<br \/>\n                imagecanvas.cliprect.right * 1440 div pixelsperinch,<br \/>\n                imagecanvas.cliprect.bottom * 1440 div pixelsperinch<br \/>\n                );<br \/>\n    rcPage:= rc;<br \/>\n    chrg.cpMin := 0;<br \/>\n    chrg.cpMax := richedit1.GetTextLen;<br \/>\n  end;<br \/>\n  SetBkMode( imagecanvas.Handle, TRANSPARENT );<br \/>\n  richedit1.perform( EM_FORMATRANGE, 1, integer( @fmt ));<br \/>\n  \/\/ next call frees some cached data<br \/>\n  richedit1.perform( EM_FORMATRANGE, 0, 0 );<br \/>\n  image1.refresh;<br \/>\n  \/\/ refresh is necessary since the control only refreshes automatically<br \/>\n  \/\/ if a canvas method is used to change its content.<\/p>\n<p>end;<br \/>\n[\/code]<br \/>\nThis assumes TImage contains a bitmap image. Add the richedit unit to your<br \/>\nUses clause (the one after the Implementation keyword).<\/p>\n<p>Peter Below (TeamB)<br \/>\n100113.1101@compuserve.com <\/p>\n<p>)<br \/>\nNo e-mail responses, please, unless explicitely requested!<\/p>\n<p>[tags]Delphi, Components, RichEdit[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>> > I would like to have a Richedit box with a transparent background. > > To be more precise, I would like&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-1v","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/93"}],"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=93"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/93\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}