📄 vcg12.htm
字号:
<P>
<FONT COLOR="#000080"><B>Listing 12.10. The Print update handler.</B></FONT>
<BR>
<PRE>
<FONT COLOR="#000080">void CCrystalReportsDemoApp::OnUpdatePrinterReport( CCmdUI* pCmdUI )
{
pCmdUI -> Enable( m_pPrintJob != NULL );
}</FONT></PRE>
<BR>
<A NAME="E70E66"></A>
<H5 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Export...</B></FONT></CENTER></H5>
<BR>
<P>To export a report (which writes the report's output to a file), you need to set the output option to export and then call Start() to print the report, as shown in Listing 12.11. Generally, Export works much like both Print and Print Preview, because it calls a destination (ExportTo()) and then calls Start() to do the actual output.
<BR>
<P>
<FONT COLOR="#000080"><B>Listing 12.11. The Export command handler.</B></FONT>
<BR>
<PRE>
<FONT COLOR="#000080">void CCrystalReportsDemoApp::OnExportReport()
{
CRPEExportOptions exportOpt;
if( m_pPrintJob->GetExportOptions( &exportOpt ) ) {
if( !m_pPrintJob->ExportTo( &exportOpt ) ) {
AfxMessageBox( m_pPrintJob->GetErrorText() );
return;
}
if( !m_pPrintJob->Start() ) {
AfxMessageBox( m_pPrintJob->GetErrorText() );
}
}
}</FONT></PRE>
<P>The update handler disables the Export menu selection based on whether there is a currently open Crystal Reports report. The variable m_pPrintJob is non-NULL if an existing Crystal Reports report is open. Listing 12.12 shows the update handler for this menu item.
<BR>
<P>
<FONT COLOR="#000080"><B>Listing 12.12. The Export update handler.</B></FONT>
<BR>
<PRE>
<FONT COLOR="#000080">void CCrystalReportsDemoApp::OnUpdateExportReport( CCmdUI* pCmdUI )
{
pCmdUI -> Enable( m_pPrintJob != NULL );
}</FONT></PRE>
<BR>
<A NAME="E70E67"></A>
<H5 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Mail...</B></FONT></CENTER></H5>
<BR>
<P>To mail a report (which writes the report's output to a file and then uses MAPI to send the report to another user), you need to set the output option to export and then call Start() to print the report, as shown in Listing 12.13. Generally, Export works much like both Print and Print Preview, because it calls a destination (ExportTo()) and then calls Start() to do the actual output.
<BR>
<P>In reality, the only difference between Export and Mail is that the user selects Mail in the Export destination rather than writing the report to a disk file. In fact, Export and Mail can be used interchangeably with Crystal Reports.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE><B>NOTE</B>
<BR>
<BR>Nothing limits you to using the same Export/Mail model that Crystal Reports uses. You could combine these two functions or write a different handler if you wanted to. For more information, look at the CRPEExportOptions structure shown in Listing 12.13.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>
<FONT COLOR="#000080"><B>Listing 12.13. The Mail command handler.</B></FONT>
<BR>
<PRE>
<FONT COLOR="#000080">void CCrystalReportsDemoApp::OnMailReport()
{
CRPEExportOptions mailOpt;
if( m_pPrintJob->GetExportOptions( &mailOpt ) ) {
if( !m_pPrintJob->ExportTo( &mailOpt ) ) {
AfxMessageBox( m_pPrintJob->GetErrorText() );
return;
}
if( !m_pPrintJob->Start() ) {
AfxMessageBox( m_pPrintJob->GetErrorText() );
}
}
}</FONT></PRE>
<P>The update handler disables the Mail menu selection based on whether there is a currently open Crystal Reports report. The variable m_pPrintJob is non-NULL if an existing Crystal Reports report is open. Listing 12.14 shows the update handler for this menu item.
<BR>
<P>
<FONT COLOR="#000080"><B>Listing 12.14. The Mail update handler.</B></FONT>
<BR>
<PRE>
<FONT COLOR="#000080">void CCrystalReportsDemoApp::OnUpdateMailReport( CCmdUI* pCmdUI )
{
pCmdUI -> Enable( m_pPrintJob != NULL );
}</FONT></PRE>
<BR>
<A NAME="E69E192"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Generating Reports for Crystal Reports</B></FONT></CENTER></H4>
<BR>
<P>You must use the Crystal Reports report generator (CRW32.EXE) to create reports that will be printed with the Crystal Reports print engine that you are including with your application. You might find it expedient to either
<BR>
<UL>
<LI>have someone who is talented at designing reports give your application's reports a finished look
<BR>
<BR>
<LI>have the users of your application sit down with the Crystal Reports report generator and help you design the reports
<BR>
<BR>
</UL>
<P>Remember, the application is for the users, and if possible they should provide input into the report design phase.
<BR>
<BR>
<A NAME="E68E69"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Using Crystal Reports Pro</B></FONT></CENTER></H3>
<BR>
<P>Even though Visual C++ 4 comes with Crystal Reports, the version shipped with Visual C++ isn't as full-featured as some applications might require. Crystal also has a product called Crystal Reports Pro. At the time this book was written, Crystal Reports Pro 4.5 was the only 32-bit report generator available for Visual C++ programmers.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE><B>NOTE</B>
<BR>
<BR>Unlike some producers of software, Crystal maintains and sells earlier versions of its products. This can be useful when a software project is on a restricted budget: Using earlier versions of Crystal Reports can be significantly less expensive.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE><B>NOTE</B>
<BR>
<BR>Things change rapidly in the Windows programming world. Other 32-bit report generators probably will be available by the time you read this book. If Crystal Reports Pro doesn't meet your needs, check suppliers of programming tools for other competitive products.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>Table 12.1 shows the functionality that Crystal Reports Pro adds to Crystal Reports for Visual C++.
<BR>
<BR>
<P ALIGN=CENTER>
<CENTER>
<FONT COLOR="#000080"><B>Table 12.1. Crystal Reports Pro functionality not present in Crystal Reports for Visual C++.</B></FONT></CENTER>
<BR>
<CENTER><TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Functionality</I>
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Description</I>
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Adding new functions
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Crystal Reports Pro lets you add new functions to the base product. These functions can be used to perform tasks specific to your application.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Exporting reports using Crystal Reports Pro
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Using Crystal Reports Pro, your applications can export reports in a number of word processor, spreadsheet, and popular data interchange formats.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Crystal custom controls bind to Visual Basic data controls
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
New features have been added to Crystal Reports Pro that let a Crystal custom control bind directly to a Visual Basic data control. Crystal Reports Pro is bundled with TrueGrid, a bound grid control by Apex Software Corporation that lets users generate reports using the grid layout.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEDiscardSavedData
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Discards data that was previously saved with the report.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetGroupCondition
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Determines the group condition information for a selected group section in the specified report.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetLineHeight
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Gets line height and ascent information for a specified line in a selected section of the report.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetMargins
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Retrieves the page margin settings for the specified report.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetMinimumSectionHeight
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Retrieves minimum section height information for selected sections in the specified report.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetNDetailCopies
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Returns the number of copies of each Details section in the report that are to be printed.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetNLinesInSection
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Determines the number of lines in a selected section of the specified report.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetNParams
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Retrieves the number of parameters needed by a stored procedure.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetNthParam
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Gets the <I>n</I>th parameter of a stored procedure.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetPrintOptions
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Retrieves the print options specified for the report (the options that are set in the Print common dialog box) and uses them to fill in the PEPrintOptions structure.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
PEGetReportTitle
</FONT>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -