Index: cprs/trunk/CPRS-Chart/fRptBox.pas
===================================================================
--- cprs/trunk/CPRS-Chart/fRptBox.pas	(revision 830)
+++ cprs/trunk/CPRS-Chart/fRptBox.pas	(revision 1679)
@@ -20,4 +20,5 @@
     procedure cmdCloseClick(Sender: TObject);
     procedure FormClose(Sender: TObject; var Action: TCloseAction);
+    procedure FormResize(Sender: TObject);
   end;
 
@@ -35,7 +36,6 @@
 function CreateReportBox(ReportText: TStrings; ReportTitle: string; AllowPrint: boolean): TfrmReportBox;
 var
-  i, AWidth, MaxWidth, AHeight: Integer;
+  i, AWidth, MinWidth, MaxWidth, AHeight: Integer;
   Rect: TRect;
-  // %$@# buttons!
   BtnArray: array of TButton;
   BtnRight: array of integer;
@@ -50,4 +50,5 @@
     begin
       k := 0;
+      MinWidth := 0;
       with pnlButton do for j := 0 to ControlCount - 1 do
         if Controls[j] is TButton then
@@ -75,27 +76,30 @@
       ClientWidth := MaxWidth;
       ClientHeight := AHeight;
-      Rect := BoundsRect;
-      ForceInsideWorkArea(Rect);
-      BoundsRect := Rect;
       ResizeAnchoredFormToFont(Result);
-
       memReport.Align := alClient; //CQ6661
-
       //CQ6889 - force Print & Close buttons to bottom right of form regardless of selected font size
       cmdClose.Left := (pnlButton.Left+pnlButton.Width)-cmdClose.Width;
       cmdPrint.Left := (cmdClose.Left-cmdPrint.Width)-1;
       //end CQ6889
-
       SetLength(BtnLeft, k);
       for j := 0 to k - 1 do
       begin
         BtnLeft[j] := pnlButton.Width - BtnArray[j].Width - BtnRight[j];
+        MinWidth := MinWidth + BtnArray[j].Width;
       end;
-      //cmdClose.Left := pnlButton.Width - cmdClose.Width - cmdCloseRightMargin;
-      //cmdPrint.Left := pnlButton.Width - cmdPrint.Width - cmdPrintRightMargin;
+      Width := width + (GetSystemMetrics(SM_CXVSCROLL) *2);
+      Constraints.MinWidth := MinWidth + (MinWidth div 2) + (GetSystemMetrics(SM_CXVSCROLL) *2);
+      if (mainFontSize = 8) then Constraints.MinHeight := 285
+      else if (mainFontSize = 10) then Constraints.MinHeight := 325
+      else if (mainFontSize = 12) then Constraints.MinHeight := 390
+      else if mainFontSize = 14 then Constraints.MinHeight := 460
+      else Constraints.MinHeight := 575;
       QuickCopy(ReportText, memReport);
       for i := 1 to Length(ReportTitle) do if ReportTitle[i] = #9 then ReportTitle[i] := ' ';
       Caption := ReportTitle;
       memReport.SelStart := 0;
+      Rect := BoundsRect;
+      ForceInsideWorkArea(Rect);
+      BoundsRect := Rect;
     end;
   except
@@ -110,4 +114,6 @@
   
 begin
+  Screen.Cursor := crHourglass;  //wat cq 18425 added hourglass and disabled mnuFileOpen
+  fFrame.frmFrame.mnuFileOpen.Enabled := False;
   frmReportBox := CreateReportBox(ReportText, ReportTitle, AllowPrint);
   try
@@ -115,4 +121,6 @@
   finally
     frmReportBox.Release;
+    Screen.Cursor := crDefault;
+    fFrame.frmFrame.mnuFileOpen.Enabled := True;
   end;
 end;
@@ -134,5 +142,5 @@
 //  RemoteQuery: string;    //for Remote site printing
   dlgPrintReport: TPrintDialog;
-
+    BM: TBitmap;
 const
   PAGE_BREAK = '**PAGE BREAK**';
@@ -141,4 +149,6 @@
 //  RemoteSiteID := '';
 //  RemoteQuery := '';
+ BM := TBitmap.Create;
+  try
   dlgPrintReport := TPrintDialog.Create(Form);
   try
@@ -153,4 +163,5 @@
         LastLine := 0;
         ThisPage := 0;
+        BM.Canvas.Font := memPrintReport.Font;
         with memPrintReport do
           begin
@@ -158,10 +169,19 @@
               with Lines do
                 begin
-                  AddStrings(AHeader);
-                  for i := 0 to MaxLines do
+                 for i := 0 to MaxLines do begin
+                   if BM.Canvas.TextWidth(StringText[LastLine + i]) > Width then begin
+                     MaxLines := Maxlines - (BM.Canvas.TextWidth(StringText[LastLine + i]) div Width);
+                   end;
+                   if i >= MaxLines then begin
+                     break;
+                   end;
+
                     if i < StringText.Count then
-                      Add(StringText[LastLine + i])
+                     // Add(IntToStr(i) + ') ' + StringText[LastLine + i])
+                     Add(StringText[LastLine + i])
                     else
                       Break;
+                  end;
+
                   LastLine := LastLine + i;
                   Add(' ');
@@ -175,8 +195,9 @@
                       Add('Page ' + IntToStr(ThisPage));
                       Add(PAGE_BREAK);
+                      MaxLines := 60 - AHeader.Count;
                     end;
                 end;
               until LastLine >= StringText.Count - 1;
-            PrintWindowsReport(memPrintReport, PAGE_BREAK, Title, ErrMsg);
+            PrintWindowsReport(memPrintReport, PAGE_BREAK, Title, ErrMsg, True);
           end;
       finally
@@ -189,4 +210,7 @@
     dlgPrintReport.Free;
   end;
+  finally
+    BM.free;
+  end;
 end;
 
@@ -213,3 +237,10 @@
 end;
 
+
+procedure TfrmReportBox.FormResize(Sender: TObject);
+begin
+  inherited;
+  self.memReport.Refresh;
+end;
+
 end.
