Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Simple question !!!

Hi, Only what I want to do is simply print the content of a edit box object via a click event from a button. Any source would be greatly appriciated


edit box name:
edt_output

button name:
btn_print

Thank you for your time and efforts

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hi, Only what I want to do is simply print the content of a edit box object via a click event from a button. Any source would be greatly appriciated
    :
    :
    : edit box name:
    : edt_output
    :
    : button name:
    : btn_print
    :
    : Thank you for your time and efforts
    :
    You need to include the Printers unit in the uses list. Then you can use AssignPrn() to assign a textfile variable to the printer and write to that variable (like you would to a normal textfile) to print the text. Remember to call CloseFile() on the file variable.
  • simwizsimwiz Posts: 4Member
    SO i have to basicallt write to a text file and print that file no way of using the print dialog object ?
  • zibadianzibadian Posts: 6,349Member
    : SO i have to basicallt write to a text file and print that file no way of using the print dialog object ?
    :
    You can use the print dialog box, but that's only necessary if you are going to use the TPrinter object. If you use the TPrinter, you gain much more control over the output of the document, since you will be drawing it onto the TPrinter.Canvas.
    Because you want to print a single edit, you won't need the dialog to select pages, collate the print job, etc.
  • simwizsimwiz Posts: 4Member
    So is there any code to print off the edit box content. basically by clicking a button which will do the above ??? I thought of using a print dialog and then put some code inside it to assign it to the editbox.text !


  • zibadianzibadian Posts: 6,349Member
    : So is there any code to print off the edit box content. basically by clicking a button which will do the above ??? I thought of using a print dialog and then put some code inside it to assign it to the editbox.text !
    :
    :
    :
    Here is some code, if you want to use the PrintDialog box:
    [code]
    procedure TForm1.Button1Click(Sender: TObject);
    var
    i: integer;
    begin
    if PrintDialog1.Execute then
    with Printer do
    begin
    Copies := PrintDialog1.Copies;
    BeginDoc;
    Canvas.Font := Edit1.Font;
    Canvas.TextOut(10, 10, Edit1.Text);
    EndDoc;
    end;
    end;
    [/code]
    This code is untested and only uses the number of copies, but otherwise it will show the text as it is in the edit (including its font).
  • simwizsimwiz Posts: 4Member
    Thanks for the help !!!! Il get back to you and see if it works

    cheers - Merry XMAS
Sign In or Register to comment.