Board index » cppbuilder » Printer problems with Brush Hatch Styles

Printer problems with Brush Hatch Styles


2005-05-18 10:43:07 PM
cppbuilder50
Hi everyone
I have also posted this question on the nativeapi and vcl newsgroups as it
seems to span all these areas.
My application draws rectangles and other polygons which can be filled using
the various standard hatch styles such as diagonal lines, cross, vertical
lines etc. To set the hatch colours and styles, I use the
Canvas->Brush->Color and Canvas->Brush->Style properties. All is fine when
displayed on the monitor, but when printing, most printers draw the space
between the hatch lines in black, I want the spaces left white or
transparent.
I thought this problem may be solved by playing with the background
colour/style by using the Windows GDI functions SetBkColor() and
SetBkStyle(), but nothing I do has any result.
Can anyone help me get the printing right.
Regards
Peter
 
 

Re:Printer problems with Brush Hatch Styles

What method do you use to print your canvas ?
 

Re:Printer problems with Brush Hatch Styles

Paolo,
Thank you for your response. I use the Printer Canvas to draw on, using the
Canvas methods (eg Canvas->Rectangle() or Canvas->Polygon() etc. Is this
what you are asking?
Peter
"PaoloItaly" < XXXX@XXXXX.COM >wrote in message
Quote
What method do you use to print your canvas ?


 

{smallsort}

Re:Printer problems with Brush Hatch Styles

Try using metafiles:
TCanvas *c = new TCanvas;
TPrinter *prn = Printer();
int width = ::GetDeviceCaps(prn->Handle, HORZSIZE);
int height = ::GetDeviceCaps(prn->Handle, VERTSIZE);
prn->BeginDoc();
TRect r(0, 0, width, height);
c->Handle = ::Crea{*word*249}hMetaFile(prn->Handle, NULL, &r, NULL);
/*
Here use the canvas to draw on
*/
HENHMETAFILE enh = ::CloseEnhMetaFile(c->Handle);
::PlayEnhMetaFile(prn->Handle, enh, &r);
::Dele{*word*249}hMetaFile(enh);
prn->EndDoc();
delete c;
I think this will work and much faster than draw directly on printer canvas
Ciao
 

Re:Printer problems with Brush Hatch Styles

Thanks for the advice. I shall try this method.
You answer however reminds me of another problem I have. I wrote an
application that saves charts in the form of metafiles (both standard and
enhanced metafiles) and found that most graphics applications cannot open
them. Instead I get an "out of memory" message, even though they are not
large files. This is the case with packages such as C{*word*203}Draw and Paint
Shop Pro. Strangely though, there is no problem importing these metafiles
into Word or Excel. Are you aware of any problems with Builder created
metafiles. I use Builder 5.
Thanks
Peter
"PaoloItaly" < XXXX@XXXXX.COM >wrote in message
Quote
Try using metafiles:
TCanvas *c = new TCanvas;
TPrinter *prn = Printer();
int width = ::GetDeviceCaps(prn->Handle, HORZSIZE);
int height = ::GetDeviceCaps(prn->Handle, VERTSIZE);
prn->BeginDoc();
TRect r(0, 0, width, height);
c->Handle = ::Crea{*word*249}hMetaFile(prn->Handle, NULL, &r, NULL);
/*
Here use the canvas to draw on
*/
HENHMETAFILE enh = ::CloseEnhMetaFile(c->Handle);
::PlayEnhMetaFile(prn->Handle, enh, &r);
::Dele{*word*249}hMetaFile(enh);
prn->EndDoc();
delete c;

I think this will work and much faster than draw directly on printer
canvas

Ciao


 

Re:Printer problems with Brush Hatch Styles

The problem about "out of memory" i think depends by the dimensions in pixel
of
your metafile canvas, not caused by the dimension of the source file.
If you have only a line in your file, but the line is 0, 0, 10000, 10000 the
amount of memory needed
to reproduce the line as a bitmap will be
10000*10000*8/24/32
depending of the number of colors used.
 

Re:Printer problems with Brush Hatch Styles

I thought it was the size of the metafiles as-well, so I created some very
small metafiles and still got the "out of memory" message.
"PaoloItaly" < XXXX@XXXXX.COM >wrote in message
Quote
The problem about "out of memory" i think depends by the dimensions in
pixel
of
your metafile canvas, not caused by the dimension of the source file.
If you have only a line in your file, but the line is 0, 0, 10000, 10000
the
amount of memory needed
to reproduce the line as a bitmap will be
10000*10000*8/24/32
depending of the number of colors used.