Some problems in printing (TAOGOU) The following Quickrpt version is 3.6
About automatic folding requirements: Automatic folding solution to exceeding the length: Depending on the Delphi's judgment function, it controls more than the length of the text. In fact, itself has the function of judging and intercepting the Chinese characters, but only takes the first line. So there is no ability to fold. Source code: file qrctrls; function formatlines; subfunction addword
Procedure addword (aword: string); {$ IFDEF VER100} var s: string; {$ ENDIF} Begin While AlineWidth> Width Do // Character length exceeds the specified length begin if newline = '' dam {$ IFDEF VER100} // version control seems to be only {$ IFDEF VER36} and this. If syslocale.fareast the begin while true do beg, ife (aword [1] in leadbytes) and (length (aword)> 1) THEN S: = Copy (AWORD, 1, 2) ELSE S: = Copy (AWORD, 1, 1);
IF alinewidth: = newline s; delete (AWORD, 1, Length (s)); end else break; end; end else While AlineWidth (Newline Copy (AWORD, 1, 1 If you don't want, of course you can join yourself to join the control begin newline: = Newline Copy (AWORD, 1, 2); Delete (AWORD, 1, 2); ELSE BEGIN NEWLINE: = Newline Copy (AWORD, 1, 1); Delete (AWORD, 1, 1); end; end; {$ ENDIF} // TAOGOU AWORD: = ''; // The assignment of this sentence will result in unable to go back; flushline; // will intercept the specified Length Characters Add to String List {if ALineWIDTH (AWORD)> Width Then Begin if newline = '' TEN BEGIN if width = 0 Then AWord: = 'Else While ALINEWIDTH (AWORD)> Width Do {$ IFDEF VER100} {IF bytetype (AWORD, Length (AWORD)) = Mbtrailbyte Then Delete (AWORD, LENGTH (AWORD) -1, 2) Else} // {$ ENDIF} {Begin Delete (AWORD, LENGTH (AWORD), 1); END End; newline: = AWORD; flushline; aword: = '; end;} if not wordwrap the begin AWord: ='; linefinished: = true; End; end; newline: = newline aword; end; page number variable control caused by automatic folding Demand: After the text is folded, it has a high high-speed change in format, and the number of lines is not easy to control. The preview effect is unbearable. Workaround: Do not allow high automatic changes to Detail, high-processed number of lines, high-processes. Example: If you do not fold the fixed format of the 5 lines, you can't get 5 lines because of the fold, the program automatically increases, in the case of the set, the situation is very bad. Therefore, forced fixed lines, if the folding exceeds the fixed height, the exceril is not printed. Source: file qrctrls; master function PRINTTTOCANVAS; subunies canprint Find the following line TQRCustomBand (PARENT) .Expandband (LineHeight, Afexpanded, Hasexpanded); this line is based on the number of lines of your CAPTION, so shields the following line in the main function. Controlbottom: = ATOP AHEIGHT 1; modified to controlbottom: = ATOP TQRCUSTomb (PARENT) .Size.Length 1; tqrcustomband (parent) .size.Length is the current Detail's rising line and finding this loop while (fcurrentline <= fformattedLines.count - inc (FCurrentLine);; end; 1) and CanPrint then begin PrintLine (FCurrentLine) - 1) and CanPrint do (FCurrentLine <= FFormattedLines.Count if modified to while (FCurrentLine <= FFormattedLines.Count - 1) and CanPrint do // taogou if (FCurrentLine <= FFormattedLines.Count - 1) and CanPrint then begin if Y lineHeight Demand: Control excess line, example: page print line number is 5 lines, the current print record number is 12, the format is unsained, then only 2 lines of data in the last page, from the third line to the foot is a blank. Here you need to print the last page 3 lines in the last page. Solution: Loop N times Detail line print method, and block the record Source code: file quickrpt; master function tqrController.execute HasPrintedLines: = 0; // this function to add a local variable recording the number of lines that have been printed while MoreData do begin inc (HasPrintedLines); // add 1 Application.ProcessMessages; if ParentReport.QRPrinter.Cancelled then Exit; if ParentReport.PreparingDesignTime and (ParentReport.FPageCount> 1) then Exit; inc (FDetailNumber); PrintGroupHeaders; PrintBeforeControllers; ParentReport.PrintBand (FDetail); PrintAfterControllers; if DSOK then begin DataSet.Next; MoreData: = not FDataSet.Eof; if (FDataSet.Eof) THEN / ADD BEGIN Begin if fdetail <> nil dam 将 全 全 t t:::: = 0 to fdetail.controlcount-1 do begin if fdetail.controls [J] is tqrdbtext the tqrdbtext (fdetail .Controls [j]). Enabled: = false; if fdetail.controls [j] is tqrlabel daml dam (fdetail.controls [j]). Caption: = '; For J: = 1 to fpagemaxlines * PARENTREPORT.PAGENUMBER-HASPRINTEDLINES DO / / FPAGEMAXLINES page Maximum print line, external passed variable //parentReport.pagenumber total print pages, because only the last page is controlled, // Therefore, the current number of printing sheets has been determined, may be taken directly begin Application.ProcessMessages; // begin 1 if ParentReport.QRPrinter.Cancelled then Exit; PrintGroupHeaders; PrintBeforeControllers; if assigned (FDetail) then FDetail.MakeSpace; NotifyClients (qrMasterDataAdvance); ParentReport .Printband (fdetail); PrintAfterControllers; // end 1 // From Begin 1 to the function of direct Copy from version 2.0 (there should be a better solution, // is just lazy, :)) In fact, this paragraph is used in 2.0 there is no problem in DI end; // Add end endend else begin MoreData: = false; if assigned (FOnNeedDataEvent) and not (csDesigning in ComponentState) then OnNeedData (SelfCheck, MoreData); end; if checkGroups then begin if DSOK then DataSet. Prior; PrintGroupFooters; if DSOK then DataSet.Next; end; if ParentReport is TQuickRep and DSOK and (TQuickRep (ParentReport) .DataSet = DataSet) and (RecCount <> 0) then ParentReport.QRPrinter.Progress: = (Longint (DetailNumber) * 100) DIV Recount; end; Note: The first time to write such a stuff and everyone, it feels a bit of a strong heart. the reason? Too obvious, 1, don't know how to define 2, don't know how to write annotations 3, my writing is very lazy 4. I don't know if MM is thinking about me? ? ? :) OK, this stuff is east to here, comrades, good things take it out and share it.