Hi
What is 'the' recommended way to print and to preview more than one chart on a page, without running into problems with strange fonts, line sizes, etc. What is the recommended example I should study?
I have read most of the questions/answers about printing, but after hours of reading and trying and frustration, I know I have to ask for help. I am using VS2005, C++, native, Teechart Pro 7.0.0.5 ActiveX.
I have dynamically created two Charts and I am able to update the charts, and view and browse large data files.
Now I want to preview and print these charts, i.e. I want to put the charts on a page, and combine the charts with other elements , such as header and footer texts.
In the Create of a Class inherited from CView I defined the two charts (Classes inherited from CTChart)
CChart * pChart = new CChart( GetDocument() );
pChart->Create(lpszClassName,"", dwStyle, CRect(0,0,50,50), this, IDC_TCHART1, pContext);
pChart->AttachControlSite(this); // ?? is this really necessary?
m_chartarray.Add( pChart );
in the OnSize function I position both Graphs in the View. Works fine, and flexible
What is THE recommended way to preview and print the charts on the same page, with the best quality output (fonts, ticks on axis, etc.). I saw the Printing example but the output of that example creates poor quality charts (background, grid, fonts etc.).
I tried using CTeePreviewPanel. I created a dialog (CPrintPrevDlg), inserted the activeX component, added a control variable (m_PrintPrev), and I tried to use the recommended? example I saw in another post on this forum.
CPrintPrevDlg PrevDlg;
CChart * pChart = m_chartarray[0];
pChart->GetPrinter().SetPrintProportional(false);
pChart->GetPrinter().SetMarginLeft(2);
pChart->GetPrinter().SetMarginTop(2);
pChart->GetPrinter().SetMarginRight(40);
pChart->GetPrinter().SetMarginBottom(40);
pChart->GetPrinter().SetDetail(100);
PrevDlg.m_PrintPrev.AddChartLink(pChart->GetChartLink());;
PrevDlg.DoModal();
But now nothing happens, I see the Preview dialog, I see the PrintPrev Canvas with the margin lines, I can drag these lines, but there is no chart or signal displayed. And I still do not know whether this approach will provide the best quality prints or that I should try another strategy.
Your help is greatly appreciated..
Printing
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi jeroen,
I've already sent you an example on how to print several charts in a preview panel.
To choose the margins of which chart you want to change in the preview panel you can use AddChart method to select the active chart to modify.
Could you please look at the example, modify it and send it to us so that we can reproduce your problem here?
You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
I've already sent you an example on how to print several charts in a preview panel.
To choose the margins of which chart you want to change in the preview panel you can use AddChart method to select the active chart to modify.
Could you please look at the example, modify it and send it to us so that we can reproduce your problem here?
You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis
Thanks for the PreviewMultiplaChartsDlg code. I want to combine the printing of several charts on one page with a header & footer text, as many others in this forum I saw. So I think I should use something like:
void CPreviewMultiplaChartsDlg::OnAfterDrawTeepreviewpanel()
{
int x = m_Preview.GetCanvas().GetWidth()/2;
int y = m_Preview.GetCanvas().GetHeight()/2;
m_Preview.GetCanvas().GetFont().SetHeight(-13); // note the - sign!
m_Preview.GetCanvas().TextOut(x,y,"HOLA");
}
If i do it like this the text IS output in preview mode, but IS NOT output on the printer (which is just a regular DeskJet type). If I debug I can see that the canvas seems to be the canvas of the preview panel not the canvas of printer (if I trace height and width of the canvas). I have also tried UpdateData calls, but without effect.
Question 1, Is this a known bug? Is there any way to output text on the printer around the charts if I use your CPreviewMultiplaChartsDlg example?
Question 2, I noticed that in preview mode, in the OnAfterDrawTeepreviewpanel call, the left, top of the canvas, is the left top of the TeePreviewPanel control (thus in the gray area, not in the printer page preview), how can I find the rectangle of the white printer page preview area?
Thanks!
Jeroen
Thanks for the PreviewMultiplaChartsDlg code. I want to combine the printing of several charts on one page with a header & footer text, as many others in this forum I saw. So I think I should use something like:
void CPreviewMultiplaChartsDlg::OnAfterDrawTeepreviewpanel()
{
int x = m_Preview.GetCanvas().GetWidth()/2;
int y = m_Preview.GetCanvas().GetHeight()/2;
m_Preview.GetCanvas().GetFont().SetHeight(-13); // note the - sign!
m_Preview.GetCanvas().TextOut(x,y,"HOLA");
}
If i do it like this the text IS output in preview mode, but IS NOT output on the printer (which is just a regular DeskJet type). If I debug I can see that the canvas seems to be the canvas of the preview panel not the canvas of printer (if I trace height and width of the canvas). I have also tried UpdateData calls, but without effect.
Question 1, Is this a known bug? Is there any way to output text on the printer around the charts if I use your CPreviewMultiplaChartsDlg example?
Question 2, I noticed that in preview mode, in the OnAfterDrawTeepreviewpanel call, the left, top of the canvas, is the left top of the TeePreviewPanel control (thus in the gray area, not in the printer page preview), how can I find the rectangle of the white printer page preview area?
Thanks!
Jeroen
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Jeroen,
Sorry for the delayed reply. Please find below the answers to your questions:
1. To be able to print as in the print preview you should add the text again in OnBefore print event, for example, something like this the code below but using TextOut (as done in the print preview) insted of an annotation tool.
2. For that you should use PaperRect, for example:
There's also an example at All Features\Welcome!\Printing\Print Preview\Custom Drawing in the features demo. You'll find the demo at TeeChart's program group.
Sorry for the delayed reply. Please find below the answers to your questions:
1. To be able to print as in the print preview you should add the text again in OnBefore print event, for example, something like this the code below but using TextOut (as done in the print preview) insted of an annotation tool.
Code: Select all
procedure TForm1.Chart1BeforePrint(Sender: TCustomTeePanel; Canvas: TCanvas;
var R: TRect);
begin
oldleft:=charttool1.Left;
oldtop:=charttool1.Top;
ChartTool1.Left:=R.Left+ChartTool1.Left;
ChartTool1.Top:=R.Top+ChartTool1.Top;
printed:=true;
end;
Code: Select all
Private Sub TeePreviewPanel1_OnAfterDraw()
If Check1.Value = 1 Then
With TeePreviewPanel1.Canvas
.Font.color = vbRed
.Font.Size = 12
.TextOut TeePreviewPanel1.PaperRect.Left + 10, _
TeePreviewPanel1.PaperRect.Top + 6, _
"Some text"
End With
End If
End Sub
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis
Thanks. I have downloaded the latest Active X to be sure I am up to date, but it seems the GetPaperRect() method is not exported, I can not use it in VS2005, as far as I can see. In one of my TeePreviewPanel.h files I see a comment that
// method 'GetPaperRect' not emitted because of invalid return type or parameter
I assume that you know that problem?
Kind regards
Jeroen
Thanks. I have downloaded the latest Active X to be sure I am up to date, but it seems the GetPaperRect() method is not exported, I can not use it in VS2005, as far as I can see. In one of my TeePreviewPanel.h files I see a comment that
// method 'GetPaperRect' not emitted because of invalid return type or parameter
I assume that you know that problem?
Kind regards
Jeroen
Hi Jeroen,
yes, you're correct, using VC++ does not allow to access to the GetPaperRect property. We can consider it as a bug or missing feature.
We'll try to add this functionality for the next TeeChart Pro v8 which will be out soon.
yes, you're correct, using VC++ does not allow to access to the GetPaperRect property. We can consider it as a bug or missing feature.
We'll try to add this functionality for the next TeeChart Pro v8 which will be out soon.
Pep Jorge
http://support.steema.com
http://support.steema.com