|
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!
|
|
|
|
|
And I who even made a report with a bitmap and tested it... Thanks for the help! The correction will go into the codebase at the soonest possible time.
|
|
|
|
|
I'd just to say you that your codes are simply genious.
I noticed that in spite of my many years of experience, I'm still a beginner compared to you.
Thank'a a lot for sharing a such of work.
Rabiby
|
|
|
|
|
Let's not create an inflation in words I'm certainly no genius, and I also have a few years of experience. But big thanks for the kind words!
|
|
|
|
|
My god, I noticed this project yesterday, the functionality style is familiar, especially the handling of text file, like your UML Editor etc, but I did not notice that author's name. I revisit this project today and notice that it IS your project, wow, you genius crazy! You REALLY type FAST
Excellent coding!
btw:
1.any idea of data-binding? I mean it can automatically accept a data source and bind data to corresponding fields, I know it is hard
2.Editor binary file download?
Regards,
unruledboy@hotmail.com
|
|
|
|
|
Yes, it's me again By the end of 2005, I will have written half of the articles on CodeProject. Then it will be a fulltime job just to maintain the code
Unruled Boy wrote:
1.any idea of data-binding?
I want to avoid tying the code to any specific type of data source, but I'll try to make the data feed more flexible. Perhaps also example code on how to pulg this together with a database - but my last efforts in this direction using MFC was with CRecordSet s...
Unruled Boy wrote:
2.Editor binary file download?
Elaborate on this, you just lost me
|
|
|
|
|
Hey, WOW is an obvious response to the effort & result you pulled here!!!
still, i think you made a bad choice of creating a propietary format of template files. had you choosen xml file, the sky was the limit.
this is a much needed package, and conforming with common protocols would have promoted this package a great deal, for instance I think that it would have been a lot easier to create a better template designer (A.K.A ReportCreator ) in C# - Winforms and save it to xml.
nevertheless,
striking and much needed!
great job, really.
DaberElay.
|
|
|
|
|