How to design the report in the BCB operation database program with TPrinter

zhaozj2021-02-16  44

Report printing is essential when using Borland C Builder5. However, the report controls belled in BCB5 itself seems lack of flexibility. So, I thought of printing the report with Tprinter. With TPrinter, you must join #include for the printing paper for the chain page, it is difficult, so I need to set the number of records per page. Below is a 30-page code that I have prepared I have, I wrote it to everyone for reference.

Try {// Positioning printhead int X, y; x = 170; y = 150; printer () -> begindoc (); // Start a print job // Print header printer () -> canvas-> font- > Size = 24; printer () -> canvas-> font-> name = "black body"; printer () -> canvas-> textout (x, y, "----- clothing requested records ---- - "); printer () -> canvas-> font-> size = 10; printer () -> canvas-> font-> name =" Song "; x = 190; y = y 300; // Print form Title line print () -> canvas-> textout (x, y, "◇" trim (label12-> caption)); y = y 80; printer () -> canvas-> textout (x, y, " ┏┏━━━━━━┳┳┳━━━━━━━┳┳┳┳┳┳━━━━┳┳━━━━━━━━━━┳━━━━━━━━━━━━ ┓ "); y = y 80; printer () -> canvas-> textout (x, y," Date Product Name Name Department Director "); Printer () -> canvas-> Textout (x 1820, y," Quantity "); Printer () -> canvas-> textout (x, y," "); print () -> canvas-> textout (x 830, y," "); printer () -> canvas -> Textout (x 1742.1, y, ""); Printer () -> canvas-> textout (x 1991.2, y, ""); Printer () -> canvas-> textout (x 2491.73, Y, ""); Printer () -> canvas-> textout (x 3487.61, y, ""); Printer () -> canvas-> textout (x 4151, y, ""; adoQuery1 -> first (); // change the page record counter initializes INT i = 0; // Setting up a loop, if not the last record, loop while (! AdoQuery1-> EOF) {//// Counter plus 1 i = i 1; y = y 80; // print one record printer () -> canvas-> textout (x, y, "┣┣━━━━━━╋╋╋ ━━━━━━━╋╋╋╋╋╋━━╋╋╋╋━━━━━━━┫┫┫┫━━━━ )┫ "); y = y 80; Printer () -> canvas-> textout (x, y, "" adoquery1-> FieldByname ("Please receive the date" -> asstring); printer () -> canvas-> textout (x 830, y, "" AdoQuery1-> FieldbyName ("Name") -> Asstring); Printer () ->

Canvas-> Textout (x 1742.1, y, "" adoQuery1-> FieldByname ("quantity") -> asstring); printer () -> canvas-> textout (x 1991.2, y, "" adoQuery1 -> FieldByname ("Received") -> Asstring); Printer () -> canvas-> textout (x 2491.73, y, "" adoquery1-> fieldbyname ("department") -> asstring); Printer () -> canvas-> Textout (x 3487.61, y, "" adoquery1-> fieldbyname ("job") -> asstring); printer () -> canvas-> textout (x 4151, y, " "AdoQuery1-> next (); // Test if the page is changed, each 30 records change this page if (i% 30 == 0) {// If it is already the last record, exit the cycle IF ( AdoQuery1-> EOF) {Break;} // If not the last record else {// If this change page, print page and page number INT P = Printer () -> Pagenumber; y = y 80; printer () -> Canvas-> Textout (x, y, "┗┗━━━━━━┻┻┻━━━━━━━┻┻┻━┻┻━━━━┻┻━━ ━━━┻┻━━━━━┛┛┛ "); Printer () -> canvas-> Textout (3800, Y 200," page: " INTOSTR (P)); Printer () -> NewPage Application-> MessageBox ("Please click OK after replacement!", "Tips", MB_OK); x = 170; y = 150; printer () -> canvas-> font-> size = 24; printer () -> canvas-> font-> name = "black body"; printer () -> canvas-> textout (x, y, "----- clothing is requested to receive record -----"); printer () - > Canvas -> font-> size = 10; printer () -> canvas-> font-> name = "体"; x = 190; y = y 300; printer () -> canvas-> textout (x, y, "◇" TRIM (label12-> caption)); y = y 80; printer () -> canvas-> textout (x, y, "┏┏━━━━━━┳┳━━━━━━ ━━━━┳┳┳┳┳┳━━┳┳┳━━━━━━┓┓┓┓ "); y = y 80; Printer () -> canvas -> Textout (x, y, "

Date Product Name Department Director "); Printer () -> Canvas-> Textout (x 1820, y," quantity); printer () -> canvas-> textout (x, y, ""; print); printer ) -> canvas-> textout (x 830, y, ""); Printer () -> canvas-> textout (x 1742.1, y, ""); printer () -> canvas-> textout x 1991.2, y, ""); Printer () -> canvas-> textout (x 2491.73, y, ""); Printer () -> canvas-> Textout (x 3487.61, y, " "); Printer () -> canvas-> textout (x 4151, y," ");}} // change page End} // After printing complete, print form tail Y = Y 80; Printer () -> canvas-> Textout (x, y, "┗┗━━━━━━┻┻┻━━━━━━━┻┻┻┻┻┻━━━━┻┻━━━ ━━━━┻┻┻━━━━━┛┛ "); // Total Total INT PP = Printer () -> Pagenumber; // Print page of the Tail Tail PageTer () -> Canvas-> Textout (3800, Y 200, "page:" INTOSTR (PP)); printer () -> enddoc (); // End a print job showMessage ("Print is completed! Thank you!");} // Abnormally handled catch (...) {ShowMessage ( "Print error check printer is connected or the power is turned on and set!!");} author: Hu Guangtao E-mail / MSN: huguangtao0515@hotmail.comQQ: 621150

转载请注明原文地址:https://www.9cbs.com/read-26899.html

New Post(0)