⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reference.htm

📁 print for you as example.very nice
💻 HTM
📖 第 1 页 / 共 3 页
字号:
see CPrinter.h for definitions</font>
<br><font size=-1>Int Penflags Pen type used to draw See CPrinter.h for
definitions</font>
<p><font size=-1>Example of use:</font>
<p><tt>Void PrintStuff (CPage* ps)</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; ps->Line(5.0,0.0,5.0,8.0);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; ps->Line(0.0,4.0,10.0,4.0);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; ps->Box(4.0,3.0,6.0,5.0);</tt>
<br><tt>}</tt>
<center><a href="#toc">Back</a></center>

<hr WIDTH="100%">
<p><a NAME="CheckBox"></a><b><font size=-1>void CheckBox(LPSTR Caption,BOOL
Data,int top,int left,int FontSize,int Direction=LABEL_RIGHT,int LineSize=2,UINT
Fillflags=FILL_NONE,UINT TextFlags=TEXT_NORMAL|TEXT_NOCLIP|TEXT_SINGLELINE);</font></b>
<p><font size=-1>Draws a Checkbox on the output device. Parameters are
:</font>
<br><font size=-1>LPSTR Caption The text accompanying the checkbox</font>
<br><font size=-1>BOOL Data The true/false expression to be shown</font>
<br><font size=-1>Int top,left The starting position to print the Checkbox.
Can be doubles.If so units are inches.</font>
<br><font size=-1>Int Direction either LABLE_RIGHT or LABEL_LEFT</font>
<br><font size=-1>Int Linesize Thickness of pen used to draw the boxUINT
Fillflags If set to any value other than FILL_NONE the checkbox will use
the fill color to fill the box rather than Xing the box</font>
<br><font size=-1>UINT TextFlags Define text attributes (See CPrinter.h)</font>
<p><font size=-1>Example of use:</font>
<p><b><tt><font size=-1>Void PrintStuff (CPage* ps)</font></tt></b>
<br><b><tt><font size=-1>{</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; ps->CheckBox("A Test",TRUE,1000,1000,12,LABEL_LEFT,2,FILL_BLACK,TEXT_BOLD);</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; ps->CheckBox("A Test again",TRUE,1100,1000,6,LABEL_RIGHT,2,FILL_NONE,TEXT_BOLD);</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; ps->CheckBox("A Test",TRUE,8.0,1.0,12,LABEL_LEFT,2,FILL_BLACK,TEXT_BOLD);</font></tt></b>
<br><b><tt><font size=-1>&nbsp;&nbsp;&nbsp; ps->CheckBox("A Test again",TRUE,9.0,1.0,6,LABEL_RIGHT,2,FILL_NONE,TEXT_BOLD);</font></tt></b>
<br><b><tt><font size=-1>}</font></tt></b>
<center><a href="#toc">Back</a>
<br>
<hr WIDTH="100%">
<br><a NAME="Tables"></a><b><u><font size=-1>Tables</font></u></b></center>

<p><font size=-1>Tables are a method of showing tabular data. They are
similar to a grid control, only printed. Many business forms are simply
a series of tables. The table metaphor has been implemented by use of three
helper classes:</font>
<p><b><font size=-1>class CPrintTable;</font></b>
<br><b><font size=-1>class COLUMNDATA;</font></b>
<br><b><font size=-1>class TABLEHEADER;</font></b>
<br><font size=-1>TABLEHEADER is a very simple class that describes a table
of data. It is described below.</font>
<p><tt><font size=-1>class TABLEHEADER{</font></tt>
<br><tt><font size=-1>public:</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; ~TABLEHEADER();</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; TABLEHEADER();</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; BOOL UseInches; // if set to true
all points passed are considered to be in inches</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; BOOL AutoSize; // if set true
will make all columns the same size</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; UINT FillFlag; // see fillflags
in CPrinter.h default FILL_NONE</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Int PointSize; // Pointsize for
header</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Int LineSize; // line size</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Int NumColumns; // number of columns
in the table</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Int NumRows; // number of rows
in the table</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; BOOL Border; // if true draw aborder
around table default TRUE</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; BOOL Vlines ; // if true separate
items with vertical lines default TRUE</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; BOOL HLines; // if true separate
items with horizontal lines default TRUE;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; BOOL HeaderOnly; // if true display
header only (virtual table)</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; BOOL NoHeader; // if true only
draw the boxes no headers</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Int HeaderLines; // number of
lines in header default 1</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; int NumPrintLines;&nbsp;&nbsp;&nbsp;
// logical number of visable print lines per cell default 1</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Double StartRow; // starting row
position ( seeUseInches above )</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Double StartCol; // stating column
position ( see UseInches above)</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Double EndCol; // ending column
position ( see UseInches)</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Double EndRow; // This is determined
by the class and is available to the end user</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; COLUMNDATA ColDesc[20]; // see
COLUMNDATA class description</font></tt>
<p><tt><font size=-1>&nbsp;&nbsp;&nbsp; CprintTable* pClsTable; // ptr
to object ownibg this header</font></tt>
<p><tt><font size=-1>};</font></tt>
<p><font size=-1>Example of use:</font>
<p><tt>TABLEHEADER* pTable=new TABLEHEADER;</tt>
<br><tt>pTable->PointSize=10;</tt>
<br><tt>pTable->UseInches=TRUE;</tt>
<br><tt>pTable->AutoSize=FALSE;</tt>
<br><tt>pTable->Border=TRUE;</tt>
<br><tt>pTable->FillFlag=FILL_NONE;</tt>
<br><tt>pTable->NumColumns=3;</tt>
<br><tt>pTable->NumRows=6;</tt>
<br><tt>pTable->StartRow=3.5;</tt>
<br><tt>pTable->StartCol=.1;</tt>
<br><tt>pTable->EndCol=8.0;</tt>
<br><tt>pTable->ColDesc[0].Init(4.0,"Coverages");</tt>
<br><tt>pTable->ColDesc[1].Init(3.0,"Limits of Liability");</tt>
<br><tt>pTable->ColDesc[2].Init(1.0,"Premium");</tt>
<br><tt>ps->Table(pTable);</tt>
<br><tt>ps->Print(pTable,0,0,8,TEXT_LEFT,"Section I - Coverage A: Dwelling");</tt>
<br><tt>ps->Print(pTable,1,0,8,TEXT_LEFT,"Section I - Coverage A: Other
Structures");</tt>
<br><tt>delete pTable;</tt>
<p><font size=-1>Class COLUMNDATA is also a very simple class. Its total
functionality is demonstrated above. It is a member of class TABLEHEADER
and is created when it is and destroyed with it. Just use it to describe
the columns width and caption. The width unit of measurement is determined
by the TABLEHEADER UseInches variable.</font>
<p><tt>class COLUMNDATA</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; public:</tt>
<br><tt>&nbsp;&nbsp;&nbsp; double Width;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; CString Text;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; COLUMNDATA() {Width=0;Text.Empty();};</tt>
<br><tt>&nbsp;&nbsp;&nbsp; Void Init(double nWidth,LPCSTR lpzText) {Width=nWidth;Text=lpzText;};</tt>
<br><tt>};</tt>
<p><font size=-1>Class CPrintTable is used internally and should not be
exposed. It actually draws and fills the table with data. It is called
and used by CPage . See the source code for details.</font>
<p><font size=-1>Tables are attached to the page by using the function
CPage::Table(pValidTableHeader). Once the TABLEHEADER has been created
and filled in pass it to the CPage class using this function. The Table
is drawn on the output device at this point. The variable LastRow is filled
in at this time and is available for use.If you are stacking tables this
variable will tell you where to start the next table. See example below.</font>
<p><font size=-1>There is an overloaded Print() function in CPage that
allows data to be inserted into the table:</font>
<center><a href="#toc">Back</a></center>

<hr WIDTH="100%">
<p><a NAME="Printtable"></a><b><font size=-1>virtual void Print(TABLEHEADER*
TheTable,int row,int col,int PointSize,UINT TextFlags,char* fmt,...);</font></b>
<p><font size=-1>In creating a table if the data element NumPrintLines
is greater than 1 each cell will be made large enough to contain multiple
print lines. The size will be determined from the font size used to create
the table. If you use a smaller font in printing there may be more visible
print lines than you specified. The standard Print(TABLEHEADER,...) overide
of the Print function will operate in a different manner if the value is
set to more than 1. See CTable::InsertItem for details. Word wrap and text
clipping is in affect unless overridden.</font>
<p><font size=-1>The Row and Col parameters that usually show position
indicate the table row and column in this overload. Other than that it
operates just like the CPage::Print() statement</font>
<p><font size=-1>Example of use:</font>
<p><font size=-1>ps->Table(pTable);</font>
<br><font size=-1>double lastRow=pTable->EndRow;</font>
<br><font size=-1>ps->Print(pTable,0,0,8,TEXT_LEFT,"Section I - Coverage
A: Dwelling");</font>
<br><font size=-1>ps->Print(pTable,1,0,8,TEXT_LEFT,"Section I - Coverage
A: Other Structures");</font>
<p><font size=-1>That抯 all there is to using tables. They are used a lot
in business forms and insurance applications.</font>
<p><b><font color="#000099"><font size=-1>REMEMBER IF YOU CREATE A TABLEHEADER
USING NEW THAT YOU HAVE TO DELETE IT.THE CLASS WILL NOT AUTOMATICALLY DELETE
THESE POINTERS.</font></font></b>
<center>
<p><a href="#toc">Back</a>
<br>
<hr WIDTH="100%">
<br><a NAME="Regions"></a><b><u><font size=-1>Regions</font></u></b></center>

<p><font size=-1>Regions are a lot harder to describe than to use. A Region
is a area of the page that you wish to treat as a single item. It may contain
Text or checkboxes or columns. It may have a title and a border. If the
location of the region moves then all of the data contained in the region
moves with it. Many forms have areas that contain data on specific topics.
Many times you抣l get everything finished and someone will say "Boy it
would be neat if that section was here and that one here". Regions are
the cure for that. The class CPrintRegion implements regions. It is really
a very simple class. Data is put into Regions using, of course, overloaded
versions of the <i><u>CPage::Print</u></i>() <i><u>CPage::PrintColumn</u></i>()
and <i><u>CPage::CheckBox</u></i>() functions already described. The functions
all take one extra parameter. A pointer to a CPrintRegion. You obtain a
pointer to a CPrintRegion by calling one of these two functions defines
in CPage:</font>
<center><a href="#toc">Back</a></center>

<hr WIDTH="100%">
<p><a NAME="CreateRegion"></a><b><font size=-1>virtual CPrintRegion* CPage::CreateRegion(double
ptop,double pleft,double pbottom, double pright);</font></b>
<br><b><font size=-1>virtual CPrintRegion* CPage::CreateRegion(int ptop,int
pleft,int pbottom, int pright);</font></b>
<br><b><font size=-2>&nbsp;</font><font size=-1>CPrintRegion* CreateSubRegion(CPrintRegion*
pParent,int ptop,int pleft,int pbottom, int pright);</font></b>
<br><b><font size=-1>&nbsp;CPrintRegion* CreateSubRegion(CPrintRegion*
pParent,double ptop,double pleft,double pbottom, double pright);</font></b>
<p><font size=-1>As usual if the position is passed as a double we assume
that all measurements are in inches.</font>
<br><font size=-1>The only callable functions from CPrintRegion are DrawBorder()
and DrawTitle(). See the header file in CPage.H for details. Subregions
are simply regions that are referenced to another region. A Subregion is
completly contained in the parent region and all offsets are based on the
parent region at creation. If the parent region is moved the subregion
moves with it.Usage of these functions are shown below.</font>
<p><font size=-1>Example of use:</font>
<p><tt><font size=-1>Void PrintStuff (CPage* ps)</font></tt>
<br><tt><font size=-1>{</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; double Row;</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; CPrintRegion *Region1=ps->CreateRegion(1.0,1.0,2.0,4.0);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; CPrintRegion *SubRegion1=ps->CreateSubRegion(Region1,0.0,1.0,2.0,2.0);</font></tt>
<p><tt><font size=-1>&nbsp;&nbsp;&nbsp; Region1->DrawBorder();</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; SubRegion1->DrawBorder();</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Region1->DrawTitle("The Title",8,TEXT_BOLD|TEXT_CENTER|TEXT_RECT,FILL_NONE);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; ps->CheckBox(Region1,"A Test",TRUE,.2,0.0,12,LABEL_LEFT,1,FILL_NONE,TEXT_BOLD);</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; Row=ps->Print(Region1,1.0,0.0,TEXT_NORMAL,14,"This
is a test");</font></tt>
<br><tt><font size=-1>&nbsp;&nbsp;&nbsp; ps->Print(SubRegion1,0.0,0.0,TEXT_BOLD,"In
subregion");</font></tt>
<br><tt><font size=-1>}</font></tt>
<p><b><font color="#000099"><font size=-1>DO NOT DELETE THE CPrintRegion
POINTER RETURNED TO YOU. THE CPage CLASS MAINTAINS A LIST OF THESE AND
FREES THEM WHEN THE DESTRUCTOR RUNS. DELETEING A CPrintRegion POINTER WILL
RESULT IN A PAGE FAULT WHEN THE CLASS TRIES TO ACCESS THE ITEM.</font></font></b>
<p><font size=-1>There are overrides for all the line and box drawing routines.
They work just like CPage::Line() and CPage::Box() with he exception of
the first parameter which is a pointer to a CPrintRegion. They are not
documented here but see the source code for details. They do provide some
checking for parameter validity and assure that drawing only takes place
within the region passed.. As usual all offsets are relative to the region
not the page. A offset of 0,0 refers to the first printable spot in the
region, whereever it is located. If offsets are outside the region they
are adjusted back to fit within the region.</font>
<center><a href="#toc">Back</a></center>

<hr WIDTH="100%">
<p><a NAME="RotateText"></a><b><font size=-2>void PrintRotatedText(double
Top,double Left,double Bottom,double Right,UINT flags,int PointSize,LPCSTR
Text,int angle);</font></b>
<p><font size=-1>This function allows one to print text rotated thru 360
degrees. The angle of orientation is expressed in 1/10 of a degree and
represented as an integer for 0 to 3600. Parameters are</font>
<br><font size=-1>double Top,Left,Bottom,Right. Boundries of text clipping
area. TEXT_NOCLIP should be used to rotate text thru non region areas.</font>
<br><font size=-1>UINT Flags are the standard text flags</font>
<br><font size=-1>int Point size is the font size</font>
<br><font size=-1>LPCSTR Text is , of course, the text</font>
<br><font size=-1>int angle is the rotation angle expressed in 1/10 of
a degree. Valid range is 0-3600.</font>
<br><font size=-1>Example of use:</font>
<p><tt>void PrintForm6(CPage* ps)</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; CString s;</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; double row=0.0;</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; for(int y=0; y &lt; 3600;y+=300)</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s.Format("Rotated
Text Demo:Factor %d",y);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ps->PrintRotatedText(5.5,4.0,9.0,8.0,TEXT_BOLD|TEXT_NOCLIP,16,s,y);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>}</tt>
<center><a href="#toc">Back</a></center>

<hr WIDTH="100%">
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -