Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print text to a bitmap

Status
Not open for further replies.

kes103

Programmer
Jun 28, 2003
26
US
I'm looking for the method(s) and example(s) for printing text to a bitmap.
Thanks in advance!
 
I think that the easiest way to do that is by using the canvas.

I don't rembember the exactly order of the properties, but is something like this

Code:
Image1->Picture->Bitmap->Canvas->TextOut(x_Pos, y_Pos, "Any text");






--- LastCyborg ---
 
Thank you for your reply, LastCyborg.
I tried your suggestion, but I get an error message that Image1 is not defined. If I use
Code:
Canvas->TextOut(x_Pos, y_Pos, "Any text");
it prints to the current form.
I suppose that what I really want to do is to print to a new form. How do I use an onClick event in one form to print to another form?
 
So, I guess you want to access another form from the main form. It is very simple just on an event handler of the main form make a reference to the other form, lie this

OnClick (Params)
{
Form2-> Canvas->TextOut(x_Pos, y_Pos, "Any text");
}

just remember to include "Unit2.h" in the header section


--- LastCyborg ---
 
Well, yes, that works for now, but I think I would much rather use a bitmap as sort of a print preview type thing. I'm still a little confused on how that is done though.
If someone could help me with I would be pleased.
 
Also, when I print or draw to the new form or to a bitmap and then use the scroll bar or resize the form the graphics disappear. How can I prevent this from happening?
 
you put a TImage object on the form
load the TImage with a bitmap or
use the raw TImage object's canvas

I am doing a print class for my printing and
I was thinking of using a TImage canvas as
a sort of print preview also. although now that
I think about it I could just use the forms canvas.

what ever you textout too, it must be a canvas object
so why not keep it simple and go to the form's canvas
and not clutter up the issue.

I think thats what I'll do.

thanks
tomcruz.net
 
The main problem is that when I either grab the form and shrink it or use the scroll bars to scroll past the text and image, it is all erased. The same thing happens if I click the minimize button. I don't want the user to be able to erase everything that easily. If I use TRichEdit Text I have a problem error "control does not have a parent" when I try to line-> text to the form. On the mainform the only problem with TRichEdit is that the user can write over or delete the text.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top