Changeset 1679 for cprs/trunk/CPRS-Chart/fRptBox.pas
- Timestamp:
- May 7, 2015, 12:34:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Chart/fRptBox.pas
r830 r1679 20 20 procedure cmdCloseClick(Sender: TObject); 21 21 procedure FormClose(Sender: TObject; var Action: TCloseAction); 22 procedure FormResize(Sender: TObject); 22 23 end; 23 24 … … 35 36 function CreateReportBox(ReportText: TStrings; ReportTitle: string; AllowPrint: boolean): TfrmReportBox; 36 37 var 37 i, AWidth, M axWidth, AHeight: Integer;38 i, AWidth, MinWidth, MaxWidth, AHeight: Integer; 38 39 Rect: TRect; 39 // %$@# buttons!40 40 BtnArray: array of TButton; 41 41 BtnRight: array of integer; … … 50 50 begin 51 51 k := 0; 52 MinWidth := 0; 52 53 with pnlButton do for j := 0 to ControlCount - 1 do 53 54 if Controls[j] is TButton then … … 75 76 ClientWidth := MaxWidth; 76 77 ClientHeight := AHeight; 77 Rect := BoundsRect;78 ForceInsideWorkArea(Rect);79 BoundsRect := Rect;80 78 ResizeAnchoredFormToFont(Result); 81 82 79 memReport.Align := alClient; //CQ6661 83 84 80 //CQ6889 - force Print & Close buttons to bottom right of form regardless of selected font size 85 81 cmdClose.Left := (pnlButton.Left+pnlButton.Width)-cmdClose.Width; 86 82 cmdPrint.Left := (cmdClose.Left-cmdPrint.Width)-1; 87 83 //end CQ6889 88 89 84 SetLength(BtnLeft, k); 90 85 for j := 0 to k - 1 do 91 86 begin 92 87 BtnLeft[j] := pnlButton.Width - BtnArray[j].Width - BtnRight[j]; 88 MinWidth := MinWidth + BtnArray[j].Width; 93 89 end; 94 //cmdClose.Left := pnlButton.Width - cmdClose.Width - cmdCloseRightMargin; 95 //cmdPrint.Left := pnlButton.Width - cmdPrint.Width - cmdPrintRightMargin; 90 Width := width + (GetSystemMetrics(SM_CXVSCROLL) *2); 91 Constraints.MinWidth := MinWidth + (MinWidth div 2) + (GetSystemMetrics(SM_CXVSCROLL) *2); 92 if (mainFontSize = 8) then Constraints.MinHeight := 285 93 else if (mainFontSize = 10) then Constraints.MinHeight := 325 94 else if (mainFontSize = 12) then Constraints.MinHeight := 390 95 else if mainFontSize = 14 then Constraints.MinHeight := 460 96 else Constraints.MinHeight := 575; 96 97 QuickCopy(ReportText, memReport); 97 98 for i := 1 to Length(ReportTitle) do if ReportTitle[i] = #9 then ReportTitle[i] := ' '; 98 99 Caption := ReportTitle; 99 100 memReport.SelStart := 0; 101 Rect := BoundsRect; 102 ForceInsideWorkArea(Rect); 103 BoundsRect := Rect; 100 104 end; 101 105 except … … 110 114 111 115 begin 116 Screen.Cursor := crHourglass; //wat cq 18425 added hourglass and disabled mnuFileOpen 117 fFrame.frmFrame.mnuFileOpen.Enabled := False; 112 118 frmReportBox := CreateReportBox(ReportText, ReportTitle, AllowPrint); 113 119 try … … 115 121 finally 116 122 frmReportBox.Release; 123 Screen.Cursor := crDefault; 124 fFrame.frmFrame.mnuFileOpen.Enabled := True; 117 125 end; 118 126 end; … … 134 142 // RemoteQuery: string; //for Remote site printing 135 143 dlgPrintReport: TPrintDialog; 136 144 BM: TBitmap; 137 145 const 138 146 PAGE_BREAK = '**PAGE BREAK**'; … … 141 149 // RemoteSiteID := ''; 142 150 // RemoteQuery := ''; 151 BM := TBitmap.Create; 152 try 143 153 dlgPrintReport := TPrintDialog.Create(Form); 144 154 try … … 153 163 LastLine := 0; 154 164 ThisPage := 0; 165 BM.Canvas.Font := memPrintReport.Font; 155 166 with memPrintReport do 156 167 begin … … 158 169 with Lines do 159 170 begin 160 AddStrings(AHeader); 161 for i := 0 to MaxLines do 171 for i := 0 to MaxLines do begin 172 if BM.Canvas.TextWidth(StringText[LastLine + i]) > Width then begin 173 MaxLines := Maxlines - (BM.Canvas.TextWidth(StringText[LastLine + i]) div Width); 174 end; 175 if i >= MaxLines then begin 176 break; 177 end; 178 162 179 if i < StringText.Count then 163 Add(StringText[LastLine + i]) 180 // Add(IntToStr(i) + ') ' + StringText[LastLine + i]) 181 Add(StringText[LastLine + i]) 164 182 else 165 183 Break; 184 end; 185 166 186 LastLine := LastLine + i; 167 187 Add(' '); … … 175 195 Add('Page ' + IntToStr(ThisPage)); 176 196 Add(PAGE_BREAK); 197 MaxLines := 60 - AHeader.Count; 177 198 end; 178 199 end; 179 200 until LastLine >= StringText.Count - 1; 180 PrintWindowsReport(memPrintReport, PAGE_BREAK, Title, ErrMsg );201 PrintWindowsReport(memPrintReport, PAGE_BREAK, Title, ErrMsg, True); 181 202 end; 182 203 finally … … 189 210 dlgPrintReport.Free; 190 211 end; 212 finally 213 BM.free; 214 end; 191 215 end; 192 216 … … 213 237 end; 214 238 239 240 procedure TfrmReportBox.FormResize(Sender: TObject); 241 begin 242 inherited; 243 self.memReport.Refresh; 244 end; 245 215 246 end.
Note:
See TracChangeset
for help on using the changeset viewer.