Link to home
Start Free TrialLog in
Avatar of grading
grading

asked on

Print a rectangular-area on a form

I would like to print a part of a form. Can someone help me with that ?
Avatar of Thaddy
Thaddy

You can call the form's print method to print the form.
If you want to print just part of it, you can call getformimage to obtain a bitmap and manipulate that in a Timage (without stretch) to print just the part that shows in the Timage.
Avatar of grading

ASKER

Hi Thaddy.
I have already tried your suggestion Form1.Print. This command is printing the complete form, but I want to print only a part of it.
My code is like this:
Form1.Image1.Picture.Graphic := Form1.GetFormImage;
Printer.Canvas.Draw(xpos,ypos,Form1.Image1.Picture.Graphic);
Nothing is being printed. What have I forgotten ?
Do not use the graphic property, but the BITMAP property instead
Avatar of grading

ASKER

I have tried the same code with Bitmaps, but with no luck. Please send me pease of code wich you know will work.
procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.Image1.Picture.bitmap:=Form1.GetFormImage;
Printer.BeginDoc;
Printer.Canvas.Draw(10,10,Form1.Image1.Picture.bitmap);
end;

Forgot to call printer.enddoc; as the last line! please add that.
Avatar of grading

ASKER

I have a 'Printer.BeginDoc' in front and a 'Printer.EndDoc' in the end. That is not the problem.
then the code i sent should work, at leat on my lexmark 1000 and on my HP4M, i tried it. maybe a printer driver problem?
ASKER CERTIFIED SOLUTION
Avatar of Thaddy
Thaddy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial