Ignore:
Timestamp:
May 7, 2015, 12:34:29 PM (9 years ago)
Author:
healthsevak
Message:

Updating the working copy to CPRS version 28

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Chart/fRptBox.pas

    r830 r1679  
    2020    procedure cmdCloseClick(Sender: TObject);
    2121    procedure FormClose(Sender: TObject; var Action: TCloseAction);
     22    procedure FormResize(Sender: TObject);
    2223  end;
    2324
     
    3536function CreateReportBox(ReportText: TStrings; ReportTitle: string; AllowPrint: boolean): TfrmReportBox;
    3637var
    37   i, AWidth, MaxWidth, AHeight: Integer;
     38  i, AWidth, MinWidth, MaxWidth, AHeight: Integer;
    3839  Rect: TRect;
    39   // %$@# buttons!
    4040  BtnArray: array of TButton;
    4141  BtnRight: array of integer;
     
    5050    begin
    5151      k := 0;
     52      MinWidth := 0;
    5253      with pnlButton do for j := 0 to ControlCount - 1 do
    5354        if Controls[j] is TButton then
     
    7576      ClientWidth := MaxWidth;
    7677      ClientHeight := AHeight;
    77       Rect := BoundsRect;
    78       ForceInsideWorkArea(Rect);
    79       BoundsRect := Rect;
    8078      ResizeAnchoredFormToFont(Result);
    81 
    8279      memReport.Align := alClient; //CQ6661
    83 
    8480      //CQ6889 - force Print & Close buttons to bottom right of form regardless of selected font size
    8581      cmdClose.Left := (pnlButton.Left+pnlButton.Width)-cmdClose.Width;
    8682      cmdPrint.Left := (cmdClose.Left-cmdPrint.Width)-1;
    8783      //end CQ6889
    88 
    8984      SetLength(BtnLeft, k);
    9085      for j := 0 to k - 1 do
    9186      begin
    9287        BtnLeft[j] := pnlButton.Width - BtnArray[j].Width - BtnRight[j];
     88        MinWidth := MinWidth + BtnArray[j].Width;
    9389      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;
    9697      QuickCopy(ReportText, memReport);
    9798      for i := 1 to Length(ReportTitle) do if ReportTitle[i] = #9 then ReportTitle[i] := ' ';
    9899      Caption := ReportTitle;
    99100      memReport.SelStart := 0;
     101      Rect := BoundsRect;
     102      ForceInsideWorkArea(Rect);
     103      BoundsRect := Rect;
    100104    end;
    101105  except
     
    110114 
    111115begin
     116  Screen.Cursor := crHourglass;  //wat cq 18425 added hourglass and disabled mnuFileOpen
     117  fFrame.frmFrame.mnuFileOpen.Enabled := False;
    112118  frmReportBox := CreateReportBox(ReportText, ReportTitle, AllowPrint);
    113119  try
     
    115121  finally
    116122    frmReportBox.Release;
     123    Screen.Cursor := crDefault;
     124    fFrame.frmFrame.mnuFileOpen.Enabled := True;
    117125  end;
    118126end;
     
    134142//  RemoteQuery: string;    //for Remote site printing
    135143  dlgPrintReport: TPrintDialog;
    136 
     144    BM: TBitmap;
    137145const
    138146  PAGE_BREAK = '**PAGE BREAK**';
     
    141149//  RemoteSiteID := '';
    142150//  RemoteQuery := '';
     151 BM := TBitmap.Create;
     152  try
    143153  dlgPrintReport := TPrintDialog.Create(Form);
    144154  try
     
    153163        LastLine := 0;
    154164        ThisPage := 0;
     165        BM.Canvas.Font := memPrintReport.Font;
    155166        with memPrintReport do
    156167          begin
     
    158169              with Lines do
    159170                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
    162179                    if i < StringText.Count then
    163                       Add(StringText[LastLine + i])
     180                     // Add(IntToStr(i) + ') ' + StringText[LastLine + i])
     181                     Add(StringText[LastLine + i])
    164182                    else
    165183                      Break;
     184                  end;
     185
    166186                  LastLine := LastLine + i;
    167187                  Add(' ');
     
    175195                      Add('Page ' + IntToStr(ThisPage));
    176196                      Add(PAGE_BREAK);
     197                      MaxLines := 60 - AHeader.Count;
    177198                    end;
    178199                end;
    179200              until LastLine >= StringText.Count - 1;
    180             PrintWindowsReport(memPrintReport, PAGE_BREAK, Title, ErrMsg);
     201            PrintWindowsReport(memPrintReport, PAGE_BREAK, Title, ErrMsg, True);
    181202          end;
    182203      finally
     
    189210    dlgPrintReport.Free;
    190211  end;
     212  finally
     213    BM.free;
     214  end;
    191215end;
    192216
     
    213237end;
    214238
     239
     240procedure TfrmReportBox.FormResize(Sender: TObject);
     241begin
     242  inherited;
     243  self.memReport.Refresh;
     244end;
     245
    215246end.
Note: See TracChangeset for help on using the changeset viewer.