|
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?
|
|
|
|
|
Now that you brought that up, I think I know what's the reason for the failure: the local for the double format. Since I've run your binaries and did not changed anything on the file that had being created, I'm sure that this is the reason. I've had the very same problem a while ago in our company where a report (created by a application written in cpp) that contained some double number could not be imported into Excel at a customer. I turned out that to be the problem I've described above, the delimiter in the doubles where wrong.
Regards
|
|
|
|
|
What is embarassing is that me, being Swedish, actually uses the decimal comma rather than the point
|
|
|
|
|
|
When clicking on an object (label or field) in the DiagramEditor the object may move slightly. I assume this is because the code catches the left button down and the small inadvertent mouse move before it sees the left button up.
Most similar apps do not have the same problem. It would be nice if the DiagramEditor could discern between single clicks and true click and drag events.
Anyone have a work around for this?
|
|
|
|
|
Your analysis is indeed true. This might - for example - be fixed by not starting to register mouse movement until a certain (small) time has elapsed, or perhaps by discarding movements under a given amount of pixels. It is slightly difficult, however, to find a good general solution - note that the underlying vector editor is a general class.
|
|
|
|
|
Hi Again,and have good time
dear johan
as i read your docs about R.G. you had used inch for internal measurments.but i notice this is only when you archive them.
the problem arises when CUnitConversion is not yet initialized and s_resolution is zero or something else other than load time.
you can reproduce this by adding
BOOL CReportCreatorApp::InitInstance()<br />
{<br />
......<br />
ParseCommandLine(cmdInfo);<br />
<br />
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;<br />
if (!ProcessShellCommand(cmdInfo))<br />
return FALSE;<br />
......<br />
}
and try to load a saved report.
this may be simplly solved by initializing CUnitConversion but i think this valuable code must be independent of Application and it is better CDiagramEntityContainer be aware of resulotion used for it's objects and have correction methods for resolution changs.
REGARDS Peiman
|
|
|
|
|
Thanks for the suggestion! Another idea that comes to mind is to let CUnitConversion self-initialize. I'm getting slightly desperate when it comes to updating the article, though
|
|
|
|
|
Hello there,
I see some questions on the forum regarding this subject, I have solved it for myself through the following function. If you call this function like this
int PreviousOrientation = SetDefaultPrinterOrientation(DMORIENT_LANDSCAPE);
It will switch printing to Landscape, and you can use the returned value to set it back to whatever it was set before the call, by passing that value and calling it again.
Hope someone can find this useful
Cheers
Alex
#include "winspool.h"
int SetDefaultPrinterOrientation(short dmOrientation)
{
HANDLE hPrinter = NULL;
DWORD dwNeeded = 0;
PRINTER_INFO_2 *pi2 = NULL;
DEVMODE *pDevMode = NULL;
PRINTER_DEFAULTS pd;
BOOL bFlag;
LONG lFlag;
LPTSTR pPrinterName = NULL;
DWORD size;
GetDefaultPrinter(NULL, &size);
TCHAR* buffer = new TCHAR[size];
if(GetDefaultPrinter(buffer, &size))
pPrinterName = buffer;
else
{
if(buffer != NULL)
delete buffer;
return 0;
}
// Open printer handle (on Windows NT, you need full-access because you
// will eventually use SetPrinter)...
ZeroMemory(&pd, sizeof(pd));
pd.DesiredAccess = PRINTER_ALL_ACCESS;
bFlag = OpenPrinter(pPrinterName, &hPrinter, &pd);
if (!bFlag || (hPrinter == NULL))
{
if(buffer != NULL)
delete buffer;
return 0;
}
// The first GetPrinter tells you how big the buffer should be in
// order to hold all of PRINTER_INFO_2. Note that this should fail with
// ERROR_INSUFFICIENT_BUFFER. If GetPrinter fails for any other reason
// or dwNeeded isn't set for some reason, then there is a problem...
SetLastError(0);
bFlag = GetPrinter(hPrinter, 2, 0, 0, &dwNeeded);
if ((!bFlag) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER) || (dwNeeded == 0))
{
ClosePrinter(hPrinter);
if(buffer != NULL)
delete buffer;
return 0;
}
// Allocate enough space for PRINTER_INFO_2...
pi2 = (PRINTER_INFO_2 *)GlobalAlloc(GPTR, dwNeeded);
if (pi2 == NULL)
{
ClosePrinter(hPrinter);
if(buffer != NULL)
delete buffer;
return 0;
}
// The second GetPrinter fills in all the current settings, so all you
// need to do is modify what you're interested in...
bFlag = GetPrinter(hPrinter, 2, (LPBYTE)pi2, dwNeeded, &dwNeeded);
if (!bFlag)
{
GlobalFree(pi2);
ClosePrinter(hPrinter);
if(buffer != NULL)
delete buffer;
return 0;
}
// If GetPrinter didn't fill in the DEVMODE, try to get it by calling DocumentProperties...
if (pi2->pDevMode == NULL)
{
dwNeeded = DocumentProperties(NULL, hPrinter,pPrinterName,NULL, NULL, 0);
if (dwNeeded <= 0)
{
GlobalFree(pi2);
ClosePrinter(hPrinter);
if(buffer != NULL)
delete buffer;
return 0;
}
pDevMode = (DEVMODE *)GlobalAlloc(GPTR, dwNeeded);
if (pDevMode == NULL)
{
GlobalFree(pi2);
ClosePrinter(hPrinter);
if(buffer != NULL)
delete buffer;
return 0;
}
lFlag = DocumentProperties(NULL, hPrinter,pPrinterName, pDevMode, NULL,DM_OUT_BUFFER);
if (lFlag != IDOK || pDevMode == NULL)
{
GlobalFree(pDevMode);
GlobalFree(pi2);
ClosePrinter(hPrinter);
if(buffer != NULL)
delete buffer;
return 0;
}
pi2->pDevMode = pDevMode;
}
// Driver is reporting that it doesn't support this change...
if (!(pi2->pDevMode->dmFields & DM_ORIENTATION))
{
GlobalFree(pi2);
ClosePrinter(hPrinter);
if (pDevMode)
GlobalFree(pDevMode);
if(buffer != NULL)
delete buffer;
return 0;
}
// Specify exactly what we are attempting to change...
pi2->pDevMode->dmFields = DM_ORIENTATION;
// Make note of the current Orientation setting
// If the functions works, return it to the calling program
// So that, the application can set it back to whatever
// it used to be before the call
int OriginalOrientation = pi2->pDevMode->dmOrientation;
// Now, change it to whatever was requested by the calling application
pi2->pDevMode->dmOrientation = dmOrientation;
// Do not attempt to set security descriptor...
pi2->pSecurityDescriptor = NULL;
// Make sure the driver-dependent part of devmode is updated...
lFlag = DocumentProperties(NULL, hPrinter, pPrinterName, pi2->pDevMode, pi2->pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER);
if (lFlag != IDOK)
{
GlobalFree(pi2);
ClosePrinter(hPrinter);
if (pDevMode)
GlobalFree(pDevMode);
if(buffer != NULL)
delete buffer;
return 0;
}
// Update printer information...
bFlag = SetPrinter(hPrinter, 2, (LPBYTE)pi2, 0);
if (!bFlag) // The driver doesn't support, or it is unable to make the change...
{
GlobalFree(pi2);
ClosePrinter(hPrinter);
if (pDevMode)
GlobalFree(pDevMode);
if(buffer != NULL)
delete buffer;
return 0;
}
// Tell other apps that there was a change...
SendMessageTimeout(HWND_BROADCAST, WM_DEVMODECHANGE, 0L,(LPARAM)(LPCSTR)pPrinterName, SMTO_NORMAL, 1000, NULL);
// Clean up...
if (pi2)
GlobalFree(pi2);
if (hPrinter)
ClosePrinter(hPrinter);
if (pDevMode)
GlobalFree(pDevMode);
if(buffer != NULL)
delete buffer;
return OriginalOrientation;
}
|
|
|
|
|
Thanks for this useful addition. Personally, I think the above should be made a mini-article of its own.
|
|
|
|
|
Hi Johan
Thanks for your feedback, I just uploaded something to the site, including one extra function to set up paper type / size
Cheers
Alex
|
|
|
|
|
Hi Again
if Ruler measurment is Pixel
the above Method makes HorzRuler & VertRuler to fall in endless loop because of negative segment and application crashs !
the quick workaround could be this that makes Rulers stable if
m_zoomMin is not less than 0.5
<br />
SetZoom( max(min( zoomx, zoomy ),m_zoomMin) );<br />
<big>OR BETTER SOLUTION</big><br />
void CReportEditor::SetZoom( double zoom )<br />
{ <br />
int z = static_cast< int >( zoom * 100.0 );<br />
CDiagramEditor::SetZoom( zoom );<br />
GetParent()->SendMessage( UWM_ZOOM, z );<br />
}<br />
<big>change to</big><br />
void CReportEditor::SetZoom( double zoom )<br />
{ <br />
CDiagramEditor::SetZoom( zoom );<br />
int z = static_cast< int >( CDiagramEditor::GetZoom() * 100.0 );<br />
GetParent()->SendMessage( UWM_ZOOM, z );<br />
}<br />
but i think u should also revise the DrawScale loop of Rulers.
REGARDS PEIMAN
i really love this code
|
|
|
|
|
Thanks a lot for the feedback!
The latter method would indeed be prefered - but I'll also do something to the UWM_ZOOM -handler.
|
|
|
|
|
Hi Dear Johan thanks for ur Nice Work .
BTW
The thickness for those items are not handled while zoom is changed and they were displayed with fixed thickness.
REGARDS PEIMAN
|
|
|
|
|
Thanks for the feedback!
If the thickness is not changed, and you've set an explicit width, it's a bug, I must admit.
|
|
|
|
|
Hi
just because of topic relation .
setting the value of thickness in thier respective property dialogs had been omitted except for Line.:->
REGARDS Peiman
|
|
|
|
|
How can me makes the images as the Reports background?
crystalice
|
|
|
|
|
I might be missing something here? The answer would seem to be "put an image field in the report and the other fields above it" - as this seems a bit simple, perhaps I'm misunderstanding you?
|
|
|
|
|
Hi there!
I have a template with a couple of fields at the top (combined page head/report head), below that a indefinite amount of data, and below that a couple of fields which sums the data in the grid (side foot/report foot). How do I get the size/height/number of rows of the grid to be minimal? I do not want the fields under the grid at the bottom of the page - they shold "follow" the last row of the grid.
* When I make three templates (one for the head, one for the data and one for the foot), it will be page brekings between the templates which I don't want.
* When I put all the three templates in one template, I will not get the sum exactly under the last row in the grid.
How do I solve the problem? All solutions and hints are very appreciated!
Johan - mycket bra verktyg förövrigt!
/Felix
|
|
|
|
|
Felix,
This is not supported functionality supported, but indeed already suggested. Given that I have a todo-list long as an arm and a leg, I have no idea when I'll get time to go through it, though
The functionality you need is not trivial to add, although it will sooner or later be implemented. In wait for that, you might perhaps try to arrange the grid in such a way that you can reuse cells for the sums? With gridlines turned of, perhaps using separators, you might get an acceptable layout anyway?
|
|
|
|
|
Oh...!
Of course... Almost embarrassing that I didn't figured out that solution by my self.
Thanks alot for the answer, and good luck with the huuuuuuuuge todo-list!
/Felix
|
|
|
|
|
Helo Johan,
It is possible to print to a fax using the fax printer driver, local o server?.
I am making tests and the result is negative at the moment.
Thanks in anticipation.
Tomas
-- modified at 6:33 Friday 28th October, 2005
|
|
|
|
|
My experience of fax servers is not exactly fresh, I would rather call the positively ancient
I the olden days, far, far back, some faxes emulated printers - you'd just have to select them as any other printer, and then print away. Some special treatment was necessary for adding the phone number, but the heavily calcinated brain I call my own remembers no details. This is a typical question for your fax server software. You might, of course, not have any documentation relating to development for the unit, but the manufacturer homepage might have info on how to do it.
|
|
|
|
|
First of all, congratulations for this good work.
I am trying to use this class in an MFC-MDI application.
I want to use the class ReportGenerator in some views derived from CListView.
I have created a member m_reportGenerator in each class where I need to print a report.
In each view there is a button to print. This button call a function that generate the report and when the report is generated I use m_reportGenerator.Print() and the report is printed in the default printer. This work perfect without problems.
Now I would like to do PrintPreview but not exist the function m_reportGenerator.PrintPreview().
Three questions:
1 - How can I do PrintPreview in each view where I need?.
2 - How can I set the LANDSCAPE or PORTRAIT mode for each report?.
3 - Wich is the correct way to print in special paper, for example labels in folders or in continuous paper?.
Any example or link will be appreciated.
Thanks in anticipation.
Tomas.
|
|
|
|
|
Thanks for your feedback, appreciated!
For print previews, you use Print as well. The demo application contains an example on how to do this - here, the print preview previews not the normal view, but the report instead.
Changing orientation is something you do in the printer driver. And example from MSDN is here:http://support.microsoft.com/default.aspx?scid=kb;en-us;214617[^]
Special paper is the same - you tell the driver that you want to use it. The report templae will - of course - have to match the paper size.
|
|
|
|
|