Board index » delphi » Rich edit with transparent output?

Rich edit with transparent output?


2005-04-13 10:57:18 PM
delphi259
Hello World,
I desperately need to be able to render Rich Text with a transparent font
background on a printer.
This particular printer doesn't support bitblt() so I can not work with
temporary
bitmaps, I really need to tell the richedit control not to paint the font
background colour.
Any clues?
--
Arthur Hoornweg
(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.)
 
 

Re:Rich edit with transparent output?

Arthur Hoornweg escreveu:
Quote
Hello World,

I desperately need to be able to render Rich Text with a transparent font
background on a printer.

This particular printer doesn't support bitblt() so I can not work with
temporary
bitmaps, I really need to tell the richedit control not to paint the font
background colour.


Any clues?
Look for the richedit EM_FORMATRANGE message on win32 api help file, its a
message used to perform rich text drawing to arbitrary devices, there is a
chance that since you provide the DC, you can specify which mode the background
is drawn by setting (or not setting any) brush. I never done that myself, but
google may give you some more pointers about that.
Solerman
 

Re:Rich edit with transparent output?

In article <XXXX@XXXXX.COM>, Arthur Hoornweg writes:
Quote
I desperately need to be able to render Rich Text with a transparent font
background on a printer.

This particular printer doesn't support bitblt() so I can not work with
temporary bitmaps,
Oh come on, certainly the printer (driver) supports StretchDIBits, which is
the preferred way to print bitmaps anyway.
Quote
I really need to tell the richedit control not to paint the font
background colour.
With richedit version 1 this used to work:
procedure TForm1.Button2Click(Sender: TObject);
var
imagecanvas: TCanvas;
fmt: TFormatRange;
begin
imagecanvas := image1.canvas;
with fmt do begin
hdc:= imagecanvas.handle;
hdcTarget:= hdc;
rc:= Rect( 0, 0,
imagecanvas.cliprect.right * 1440 div pixelsperinch,
imagecanvas.cliprect.bottom * 1440 div pixelsperinch
);
rcPage:= rc;
chrg.cpMin := 0;
chrg.cpMax := richedit1.GetTextLen;
end;
SetBkMode( imagecanvas.Handle, TRANSPARENT );
richedit1.perform( EM_FORMATRANGE, 1, integer( @fmt ));
richedit1.perform( EM_FORMATRANGE, 0, 0 );
image1.refresh;
end;
Unfortunately it seems to no longer work with richedits version 2 and up,
including the V1 compatibility wrapper provided on Xp and WinMe. That
version introduced individual character background colors and so the
control ignores the DCs background mode.
Peter Below (TeamB)
Use the newsgroup archives :
www.mers.com/searchsite.html
www.tamaracka.com/search.htm
groups.google.com
www.prolix.be
 

Re:Rich edit with transparent output?

Peter Below (TeamB) schreef:
Quote
Unfortunately it seems to no longer work with richedits version 2 and up,
including the V1 compatibility wrapper provided on Xp and WinMe. That
version introduced individual character background colors and so the
control ignores the DCs background mode.
I've tried just about everything (setting background mode of the hdc to
transparent, setting its brush to a hollow brush etc).
I have an idea that might work but its *extremely* tedious:
- create a compatible metafile dc
- render the richtext output into it
- store the metafile in a stream
- patch all setbkmode() and all createbrushindirect() opcodes.....
- render the metafile stream to the printer...
but it is like using a cannon to kill a fly.
OTOH, I *know* that a richedit supports transparent font backgrounds,
because I can create a Word document consisting of a picture with text
in front of it, and save/restore it in RTF format !
--
Arthur Hoornweg
(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.)
 

Re:Rich edit with transparent output?

Quote
but it is like using a cannon to kill a fly.

I actually use a canon to print on the fly.
:)
Jacques
 

Re:Rich edit with transparent output?

Quote
I actually use a canon to print on the fly.
:)

Jacques

Text ? Images ? Both ? How many words fit on a fly when printing with a
cannon ball <g>?
regards,
Michael
 

Re:Rich edit with transparent output?

Quote
I desperately need to be able to render Rich Text with a transparent font
background on a printer.
I believe you have to parse the contents of the RichEdit, then output.
Joe
--
Delphi, graphics, and printing specialist available - $35/hr
www.code4sale.com/codeit/index.htm
Joe Hecht Associates
121 Louise Drive
Crestview, FL 32536
"Arthur Hoornweg" <XXXX@XXXXX.COM>writes news:XXXX@XXXXX.COM...
 

Re:Rich edit with transparent output?

In article <XXXX@XXXXX.COM>, Arthur Hoornweg writes:
Quote
I have an idea that might work but its *extremely* tedious:

- create a compatible metafile dc
- render the richtext output into it
- store the metafile in a stream
- patch all setbkmode() and all createbrushindirect() opcodes.....
- render the metafile stream to the printer...

but it is like using a cannon to kill a fly.


OTOH, I *know* that a richedit supports transparent font backgrounds,
because I can create a Word document consisting of a picture with text
in front of it, and save/restore it in RTF format !
Ah, but can you print that with Wordpad or even display it correctly? The
rich edit control only supports a subset of the full RTF specs, so it is a
bit unfair to expect the poor thing to be able to do all MS Word can do...
Peter Below (TeamB)
Use the newsgroup archives :
www.mers.com/searchsite.html
www.tamaracka.com/search.htm
groups.google.com
www.prolix.be
 

Re:Rich edit with transparent output?

Try
SetWindowLong(MyRichEdit.Handle, GWL_EXSTYLE,
GetWindowLong(MyRichEdit.Handle, GWL_EXSTYLE) or WS_EX_TRANSPARENT);
Regards.
Greg
"Arthur Hoornweg" <XXXX@XXXXX.COM>writes
Quote
Hello World,

I desperately need to be able to render Rich Text with a transparent font
background on a printer.

This particular printer doesn't support bitblt() so I can not work with
temporary
bitmaps, I really need to tell the richedit control not to paint the font
background colour.


Any clues?






--
Arthur Hoornweg

(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.)
 

Re:Rich edit with transparent output?

Greg Bullock schreef:
Quote
Try

SetWindowLong(MyRichEdit.Handle, GWL_EXSTYLE,
GetWindowLong(MyRichEdit.Handle, GWL_EXSTYLE) or WS_EX_TRANSPARENT);

Regards.
Greg
Thanks, this looks like it works (at least on a tbitmap).
I haven't tested it on a printer yet (am currently in bed with the flu).
But I fail to comprehend why making the screen Hwnd transparent
would have any effect on the output, must be my feverish condition...
--
Arthur Hoornweg
(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.)
 

Re:Rich edit with transparent output?

Arthur,
Quote
But I fail to comprehend why making the screen Hwnd transparent
would have any effect on the output, must be my feverish condition...
The Hwnd is for the RichEdit control, not for the screen. You're using the
RichEdit to render the (formatted) text on any Canvas (or device context) --
screen, bitmap, printer, or whatever. When you set it to transparent, you
tell it to render the text with a transparent background.
Hope this cures the fever. :-)
Regards.
Greg