|
Thanks for the feedback!
Adding more rulers shouldn't be to difficult. Add an additional CHorzRuler and CVertRuler . Create them as the existing rulers (but with the desired position, of course). Move them in OnSize . Note that the position of m_editor will have to be updated as well. Then, search for all instances of m_horzRuler , apply the same commands to the new hrizontal ruler - do the same for m_vertRuler .
|
|
|
|
|
Thank you for the answer !
But it is still some points which I don't understand
How to place ruler on a desired position ?
When I try to create vertical ruler with a height of 100, and another one below it, I got only one ruler with a height of the window, and some flickering on OnPaint event I tried to encapsulate position of the ruler in it's class, creating fields x_, y_, width_, height_, and methods to set them before placement, and I've changed some code in OnPaint event, calling for those fields, but it still has some wierd look and even more wierd feel Can you give me some example of how it should be done ?
Best regards,
P. Sujkov, XTEX Software
|
|
|
|
|
Firts of all, the rulers should only be moved in OnSize , definitely not in OnPaint ! To place two vertical rulers at the right, one 100 pixels high and above the other, you would do something like
if( m_editor.m_hWnd )
{
m_editor.MoveWindow( RULER_SIZE, RULER_SIZE, cx - RULER_SIZE, cy - RULER_SIZE );
m_horzRuler.MoveWindow( RULER_SIZE, 0, cx, RULER_SIZE );
m_vertRuler.MoveWindow( 0, RULER_SIZE, RULER_SIZE, cy );
m_myVertRuler1.MoveWindow( cx - RULER_SIZE, RULER_SIZE, cx, 100 );
m_myVertRuler2.MoveWindow( cx - RULER_SIZE, RULER_SIZE + 100, cx, cy - ( 100 + RULER_SIZE ) );
}
|
|
|
|
|
Thank you, this really helped
Now I've got three vertical rulers, and that is great !
Next step I'll try to make them zoomable - as well as parts of the report...
And try to make some labels - for each ruler...
Anyway, was pleased to work with such a good component
P. Sujkov, XTEX Software
|
|
|
|
|
Johan,
Thanks for your great project, it's very useful for me.
A small question/suggestion: when using the Report Creator and loading a report, the layout settings don't reflect the size of the just loaded report, I have to change them manually, although the size is in the first line of the report.
Henk
|
|
|
|
|
|
|
Dear Johan,
First of all thank you for the outstanding control.
I have Included all source files of the Report Generator to my project and have declared CReportGenerator m_report variable too. The program compiles successfully.
I have also created a simple template file("c:\report.rpt") using Report Creator, with only one field, named "Field".
And in my program I have next code :
...
m_report.SetReportfile(_T("c:\report.rpt"));
m_report.Add(_T("Field"),_T("Some Data"));
m_report.Print()
...
But the printer does not print the report
What am I doing wrong?
thanks in advance
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 9:36 Monday 23rd January, 2006
|
|
|
|
|
This is not so easy to answer Put a breakpoint on Print() and single step into it would be my suggestion for starters.
|
|
|
|
|
thanks for reply Johan.
I have done what you suggested.
BOOL CReportGenerator::Print()
{
1: BOOL result = FALSE;
2: CPrintDialog printer( FALSE );
3:
4: if( printer.GetDefaults() )
5: {
6: HDC hdcPrinter = printer.GetPrinterDC();
7: CDC dc;
8: dc.Attach( hdcPrinter );
9: Print( &dc );
10: dc.EndDoc();
11: }
12: return result;
}
After stepping over the 6th line in debug mode, the value of hdcPrinter is "0x8e211160 unused=???" I think this is the problem.
Or maybe I am missing somethink very simple.
I would be thankful to you, if you could write me simple steps which I need to take in order to print very simple report.
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
I think it is ok this far. An as a matter of a fact, it is easy to print - you should basically need no more than that stuff. Did you try the demo app, will it print? Have you tried stepping further down into the Print() on line 9?
|
|
|
|
|
Hi Johan, I have fixed everything finally and voted for you 5, wanted to vote more but could not
thanks for help.
PS.Instead of writing c:\\ I had written c:\ when setting the path of template file and had never paid att to it anymore that was the problem
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Giorgi Moniava wrote: I had written c:\ when setting the path
This is not an uncommon error
|
|
|
|
|
The task is to develop app for printing pictures. User selects pictures from file and I would like to automatically load these pictures into the doc with template created by ReportCreator. Is it possible to dynamically add pictures from file?
Tom
|
|
|
|
|
You can create fields at runtime and also access the field attributes, so this is indeed possible. The documentation has all the gory details.
|
|
|
|
|
Thank you for your truly excellent program.
The bitmap on a report shows up when rpt file is selected through a dialog, but when I specify the name directly it does not (everything else shows up).
rg.SetReportfile(pth+"\\Rep.rpt");
CarlH
|
|
|
|
|
Carl,
Given that the bitmap is a reference to a file rather than embedded data, this might not be so surprising - lots of stuff can go wrong. You might want to place the bitmap at the same location as the report file, and make sure that the reference in the rpt-file (it is a text file so you can read it in any editor) only contains the bmp-name - that is, not the path to it. You might also want to put a breakpoint in the image object, to see that it is trying to load from the location you expect.
It is less than satisfacory to have reports referencing external files - it makes them too brittle, but adding them into the report file was just not an option.
|
|
|
|
|
Hi Johan,
First, I'd like to thank you for this nice utility.
However, I've been experiencing the same problem with printing a bitmap. After digging in the code, I've found that the CDrawPicture::FromString method sets the filename from the title parameter of the report_picture: object. This only contain the filename without the path information, and thus only succeeds if the file is in the cwd of the application. Since I load my template file from a subdir, it was failing to display a bitmap file saved in that same directory. Moving the bitmap to the cwd fixed the problem.
I've noticed that the last param of the report_picture: object is not parsed at all and contain the whole file path. So adding
contents.GetAt( count++, filepath );
filepath.Replace( _T( "\\colon" ), _T( ":" ) );
in the CDrawPicture::FromString method (where filepath is a CString object), and setting the filename with it (result->SetFilename( filepath )) solved the problem for me.
Now, I'm not sure if you had a reason not to do it like that.
Thanks again!
Claude Vaillancourt
|
|
|
|
|
Claude,
This has indeed been the reason for much thinking on my part. It is documented that images will have to be placed in the same directory as the report files, if memory serves. The reason is that I didn't want relative paths (even lrss absolute!), due to the fragility of such. So, I would not want to generalize a solution leading to the impossibility to move the reports.
|
|
|
|
|
Hi,
I have report template with report header and report body. In report body I need place two fields which will present large text but in fact I don't how big these fields should be to hold and present whole text. The best solution will be to set these fields to a minimal size in report templete and let them to widen to fit whole text. How can I cope with this problem??
Thanks a lot
Shark
|
|
|
|
|
I would in fact rather try to make them as big as possible. It they are placed based on each other, that is, one field should be located just after the other, this might not be possible however. In this case, you'll have to create a printer CDC , create a font matching the font you'll use for printing, and then loop all the texts, calling GetTextExtent for each string.
|
|
|
|
|
Thanks,
I can try make them as big as possible but what when the text is longer than one page. In the template editor I can widen these field to fit whole page, but reported text is longer that one page.How can I make it to be continued on several pages?
Thanks a lot
shark
|
|
|
|
|
Oooo, that is not possible without some trickery. What I would do would be to create a single column grid. Then I would split the text into lines, putting each line in the grid (the the report will then print the grid on as many pages as necessary).
How to split the text then? Well, you could write a function that gets a printer CDC and then uses GetTextExtent to walk the text and split it into lines that will fit in a single cell (that is, line).
|
|
|
|
|
The article looks very promising, to begin with.
I've downloaded all files, unpacked it and started playing. Started 'ReportCreator.exe', created a very simple report with a couple of fields. Then, started 'ReportGeneratorDemo.exe', loaded the report, created and saved in the first step. The message box said that the report had being loaded and it is ready to print. Calling up the print preview - shows three empty pages ... Then I realized, that re-opening the report(s) with the 'ReportCreator.exe', also brings up a clean white sheet. Nothing to see from the stuff that was put on it in the first step. Opening the .prt file in an editor however shows the stuff that was created:
(
paper:793,1122;
report_label ,697917,0,656250,2,208333,1,093750,Label,$app_name,0,Times New Roman,120,0,0,0,0,0,0,1,3381756,2,1243436;;
)
I'm using XP, Sp2. Any known issues with that?
Regards,
|
|
|
|
|
The problem is the delimiters. If you look at the first part of the saved label:
report_label ,697917
the value is a location - and it should be 0.697917 etc., in fact, the line should read
report_label .697917,0.656250,2.208333,1.093750,Label,$app_name,0,Times New Roman,120,0,0,0,0,0,0,1,3381756,2,1243436;;
Have you perhaps incorporated the editor in an app that sets the locale, thus using the comma instead of the decimal point?
|
|
|
|
|