|
Thank you very much! I will try to do it. if has any question ,I will trouble you again
Thank you again!
|
|
|
|
|
|
Thank you for your great job.as you said this project only support BMP files,so i try to add CxImage into this project。but it can‘t to work,the image is not shown. so i need you help,how i can change it to support more type image files.
T hank you!
|
|
|
|
|
Hi Johan,
excellent work.
the .rpt extension your using is the same as the one crystal reports uses. if CRW is installed on the system, your reports get associated with CRW, and CRW attempts to open them.
thanks
Peter
|
|
|
|
|
Crystals will just have to change, then
Joking aside, you might have noticed that I'm not registering any extension myself, and the report generator have no preference regarding the extension, so you can just save the templates with whatever extension you like.
If anyone has a good suggestion for a non-used extension, I'm all ears!
|
|
|
|
|
Hi,
You do a great work with the report generator but I have some suggestions :
- It would be great if you could create a cell oriented grid, that is a grid with labels as cells to configure the layout of each cell.
- It would be great too if you could make the grid object "dynamic", that is with a non fixed height so the grid can be print on several pages and objects below the grid would be moved to the next page.
Sorry for my english, I am french. I hope you understood me.
Thanks.
|
|
|
|
|
Your English is just fine, which you can't say about my French OTOH, your Swedish is probably rotten
Cell-oriented grid - I'm actually moving in that direction just now, with the addition of the cell-based markers [%bold%] and [%italic%]. But I have a problem with this, and dynamic row heights as well, that is the calculation of page sizes. This will of course be far more complicated if each row takes different height. Sooner or later, I will have to add it, though, as it would be needed for - for example - such mundane tasks as creating a details cell for an invoice.
So, both your suggestions are noted, and will be implemented when time allows.
|
|
|
|
|
Thanks for the nice code... Using the "Report Creator" program, when I double click on one of the columns in the properties box of a grid object and select OK without doing anything the column width changes.
Please note that I'm using the centimeter metic system.
Please advise
~~~~~~~~~~~~~~~
CDRom
|
|
|
|
|
As the coordinates are internally stored in inches, this is - to some degree - unavoidable. That, is you display the grid, the internal coordinates will be converted to centimeters. When you press ok, all information will be gathered, and converted back to inches. If you now open the dialog again, they will have changed.
If they do this each time, that is, they don't fix on a final value, then this is an error - I'll look into it. Eventually, I might build in a mechanism that check each field - if it is modified or not - and only updates the changed ones.
|
|
|
|
|
Hi
thanks for your program, and i find some bugs.
1) In ReportBoxProperties.cpp,ReportEllipseProperties.cpp,etc. SetValue()method maybe lost this line
m_borderThickness = obj->GetBorderThickness();
2) When i use reportgeneratordemo.exe to preview my report, i find drawbox and drawellipse will use default pen and brush, i means that CPen and CBrush will take no effect even if i set the box width too thick. Then i try to solve it, in CDrawBox::Draw(),i changed like this:
{
const CBorderLine* line = GetBorder();
CPen pen;
CPen* pOldPen = NULL;
CBrush brush;
CBrush* pOldBrush = NULL;
if( line->GetVisible() )
{
int thickness = CUnitConversion::InchesToPixels( line->GetThickness() );
pen.CreatePen( line->GetStyle(),
thickness,
line->GetColor() );
pOldPen = dc->SelectObject(&pen);
}
else
dc->SelectStockObject( NULL_PEN );
if( GetFill() )
{
brush.CreateSolidBrush( GetFillColor() );
pOldBrush = dc->SelectObject( &brush );
}
else
dc->SelectStockObject( NULL_BRUSH );
CDoubleRect rect = GetPosition();
CUnitConversion::InchesToPixels( rect );
CRect r( ( int ) rect.left, ( int ) rect.top, ( int ) rect.right, ( int ) rect.bottom );
CUnitConversion::AdjustPixelsToPaper( dc, r );
dc->Rectangle( r );
if( pOldPen ) dc->SelectObject(pOldPen);
if( pOldBrush ) dc->SelectObject(pOldBrush);
}
Is it right? anywise i'm very thanks
|
|
|
|
|
Thanks for your feedback!
I'll go through the codebase of all articles during easter, and I'll look into this as well. I assume there will be an update of the article - or rather code - quite soon.
|
|
|
|
|
Hy!
Your article is brilliant!
Also I am not a good MFC programmer like you, so I have a small easy question about using your code.
I made extensions for AutoCAD. This dll run within AutoCAD, and I want to show PrintPreview, from a dialog button.
I mean, Doc/View print/preview works with the AutoCAD drawing, but in my program you can also print/preview some report about drwaing.
What should I insert in my handler (for example) OnReport() to show the report preview to the user, after it, if he/she want, can print out.
My question in short form:
How can I use CReportGenerator, to preview a report without using Doc/View?
Waiting for your answer,
Zoltan
|
|
|
|
|
Thanks for the kind words!
To create a print preview from scratch, the way you would need to do, is not trivial. Basically, you would have to create a CDC mimicking the CDC of a printer. This includes getting dimensions from the CDC and setting the coordinate system to emulate that of the printer. You would have to do this in a specially created CWnd .
A little help can be found in the report creator, in which you can zoom the window, this is for all practical purposes the same as a print preview. I use a zoom factor with all drawing, however, and you would best run in an anisotropic mapping mode. You'll want to check the following CDC -members:
SetMapMode (to set up the mapping between logical and physical coordinates)
SetWindowExtents (to set up the mapping between logical and physical coordinates)
SetViewportExtents (to set up the mapping between logical and physical coordinates)
GetDeviceCaps (to get the resolution and number of printable pixels for the paper)
(you'll have to excuse any spelling- or other errors in the names, I'm writing from memory ) I realize that I'm not making much sense here, but this is really another fullblown article...
You can also take a look at the MFC print preview source code, and there might be other articles of interest here on CodeProject.
|
|
|
|
|
Hy,
Thanks for your help.
I found here an article:
Printing without the Document/View framework
By Chris Maunder
which made, what I need, Print/Preview without MFC Doc/View framework.
THX again,
Zoltan
|
|
|
|
|
Thank you so much for posting this wonderful article. Definitely deserve 5 stars. I'm playing with this Report Generator and want to know how to print to some non-standard size continuous paper like mailing and shipping labels and get the page length (when ejected) correct. Would you mind showing us how?
|
|
|
|
|
Now, I'm not 100% sure I get your question - you will not have a page length on a continous roll ???
If you have a roll of labels, and want to know the height of each label, it's of course easiest to look at the package If you need to know the height of the label expressed as addressable pixels, you call GetDeviceCaps for the printer CDC , and just hope that the paper size is set correctly. I feel I'm just being silly here, could you elaborate on the question?
|
|
|
|
|
Sorry for not making my question clear. Let me try again.
In ReportCreator, I create a label that is 2 inch in height and 4 inch in width. When I print with ReportGenerator to an impact printer (Epson FX-86e), the printer eject or form feed to the top of next page after finish printing a label. How to control so the printer advance to the top of next label.
Thanks again.
|
|
|
|
|
As you can see from the source code, the report generator uses the GDI print commands to handle pages, that is, the sequence to print is
StartDoc
StartPage
EndPage
EndDoc
This is true also for the underlying MFC framework (if you use the print preview mechanism as outlined in the demo).
EndPage in this case will send a form feed to the printer, and what happens will depend on the printer settings. What I would try in your case was setting up the printer to have a custom page size - in the printer settings - corresponding to the height of the labels.
This can be accomplished in code as well, using the DEVMODE structure. First the definition of the structure: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_8nle.asp[^]. You might want to experiment with, for example, ResetDC[^] to set your own values into this structure.
|
|
|
|
|
Great work! I come from China, welcome you to come my contury.
|
|
|
|
|
Thanks! A bit far away, but heartwarming anyway
|
|
|
|
|
May be, I don't understand how to perform a page jump or how to create more than one page with the Creator programm. Could you help me ?
Rabiby
|
|
|
|
|
The editor creates single page templates only, so you'll have to create one template for each page. But beware, the report generator is also geared towards single page templates (but of course not print-outs). You can load several templates, by for example having several instances of the generator, or load it with a new template for each page, but you'll not get the print preview this way.
I might updtae the generator to work with several templates (I would at least want to have a separate first and last page), but I will not update the template editor for this - it will still be one page, one template.
|
|
|
|
|
Hi, Thanks for the Nice Artical.
You need to convert the HBITMAP for PriterDC before sending it to
printer.
|
|
|
|
|
Hm, don't I do this already? Be how it will with that, I'm currently changing machines here, and will test and double test as soon as I'm comfortably set up again!
|
|
|
|
|
I think I found the problem in CReportEntityPicture::SetFilename(), in the following statement:
m_bitmap = ( HBITMAP ) ::LoadImage( NULL, m_filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTCOLOR );
I replaced the flag LR_DEFAULTCOLOR in parameter 6 above with LR_CREATEDIBSECTION to the following and it works!
m_bitmap = ( HBITMAP ) ::LoadImage( NULL, m_filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION );
Thanks for this great article!
|
|
|
|
|