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

📄 reference.htm

📁 print for you as example.very nice
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Generator" content="Microsoft Word 97">
   <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win95; I) [Netscape]">
   <title>Printer library documentation</title>
<STYLE TYPE="text/css">
<!--
    .normal         {font: 13px Verdana}
    BODY            {font: 13px Verdana}
    .header         {font: 18px Verdana; font-weight: bold}
    .subheader      {font: 15px Verdana; color: #3333FF; font-weight: bold}
    .subheader2     {font: 15px Verdana; color: #400000; font-weight: bold; font-style: italic}
    LI              {font: 13px Verdana}
    B               {font: 14px Verdana; font-weight: bold}
    A               {font-weight: bold; text-decoration: none}
-->
</STYLE>
</head>
<body link="#0000FF" vlink="#0000FF" bgcolor="80FFFF">
&nbsp;
<center>
<h1>
<b><font color="#000099">CPage Class Reference</font></b></h1></center>

<hr WIDTH="100%">
<br>In order to use the printing functions in your project you need to
include the files:
<br><b><font color="#000099">CPage.cpp</font></b>
<br><b><font color="#000099">CPage.h</font></b>
<br><b><font color="#000099">CPrinter.cpp</font></b>
<br><b><font color="#000099">CPrinter.h</font></b>
<br><b><font color="#000099">Dib.cpp</font></b>
<br><b><font color="#000099">Dib.h</font></b>
<br>In any file where reference to the printing functions is needed include
the header file:
<br><b><font color="#000099">CPage.h</font></b>
<br>That抯 all that is needed to incorporate the printing functions.
<br>If you find this library useful let me know.
<p><font size=-1><a href="mailto::kdtexas@onramp.net">kdtexas@onramp.net</a></font>
<p>
<hr WIDTH="100%">
<center>
<h1>
<a NAME="toc"></a>Table of Contents</h1></center>

<menu>
<li>
<a href="#CPrinter">CPrinter Class</a></li>

<li>
<a href="#prttype">Prttype Structure Definition</a></li>

<li>
<a href="#cpage">CPage Class Definition</a></li>
</menu>

<center>
<h1>
Functions</h1></center>

<center><font color="#000099"><font size=-1>Not all functions are located
here. Consult the demo program or CPage.h for a complete list</font></font></center>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#SetUserFunction">SetUserFunction</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#SetPrinterMode">SetPrinterMode</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#GetPrinterName">GetPrinterName</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#CpageConstruct">
CPage Constructor</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#Print">Print</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#PrintColumn">PrintColumn</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#SetLineSpacing">SetLineSpacing</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#SetFont">SetFont</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#SetFontSize">SetFontSize</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#SetColor">SetColor</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#SetRightmargin">SetRightMargin</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#SetBottomMargin">SetBottomMargin</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#GetDisplayContext">GetDisplayContext</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#PrintBitMap">PrintBitmap</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#GetNextLogCol">GetNextLogicalColumn</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#Line">Line</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#Line">Box</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#CheckBox">
CheckBox</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#Tables">Tables</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#RotateText">Rotated
Text</a>
<br>&nbsp;
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<font size=-1><a href="#Printtable">Print(TABLEHEADER* )</a></font>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#Regions">Regions</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#CreateRegion">Create</a>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<a href="#Regions">SubRegions</a>
<p>
<hr WIDTH="100%">
<center>
<h1>
<a NAME="CPrinter"></a><b><font size=-1>Printer Class Documentation</font></b></h1></center>
<font size=-1>Class definitions located in CPrinter.h</font>
<p><font size=-1>Functions in CPrinter.cpp: This is a low-level printer
function class. All calls from the higher-level functions will eventually
get here to one of the printer primitives. To add functionality to the
high level class(s) it is best to let the high level classes handle all
formatting etc and call simple primitive output functions. This will make
porting to a different output device or operating system a little easier.
Below is the class definition of the low-level class CPrinter.</font>
<p><tt>class CPrinter{</tt>
<br><tt>public:</tt>
<br><tt>&nbsp;&nbsp;&nbsp; CPrinter();</tt>
<br><tt>&nbsp;&nbsp;&nbsp; virtual ~CPrinter();</tt>
<br><tt>&nbsp;&nbsp;&nbsp; virtual int GetPrintInfo(PRTTYPE *ps,double
LineSpacing);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; virtual int PrintText(PRTTYPE *ps,double LineSpacing);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; virtual void DrawLine(PRTTYPE *ps,int LineSize);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; virtual void DrawRect(PRTTYPE *ps,int LineSize);</tt>
<br><tt>};</tt>
<p><font size=-1>int GetPrintInfo: This function will set internal variables
without actually printing the output string. It is mainly used internally.</font>
<p><font size=-1>int PrintText: The workhorse. Just about every call gets
routed here eventually. This function creates a font each time it is called
and calculates print parameters and changes internal variables. If the
class is to slow this is where it can be sped up considerably. The return
value is the next logical print line. It is calculated using the current
map mode, font size, and spacing factor.</font>
<p><font size=-1>void DrawLine: Line drawing primitive. Very basic.</font>
<p><font size=-1>void DrawRect: Rectangle drawing function. Very basic.</font>
<p><font size=-1>The class user should call none of these functions. Use
the higher level calls. However, if minimal print functionality is all
that is needed this can be a standalone library and does have quite a bit
of functionality</font>
<center>
<p><a href="#toc">Back</a>
<p>
<hr WIDTH="100%">
<p><a NAME="prttype"></a><b><u><font size=-1>PRTTYPE structure definition</font></u></b></center>

<p><font size=-1>The PRTTYPE structure is used to hold information about
the current print page and the current output string. It also retains information
across printer calls that can be used in determining future output selections.
It is defined below:</font>
<p><tt>typedef struct tagPrinter{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; CDC *pDC;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; RECT rc;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; int PointSize;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; CString Text;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; UINT uTextFlags;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; UINT uFillFlags;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; UINT uPenFlags;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; CString FontName;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; UINT n_maxWidth; // max width of formatting
rect</tt>
<br><tt>&nbsp;&nbsp;&nbsp; UINT n_maxLength; // ditto len</tt>
<br><tt>&nbsp;&nbsp;&nbsp; UINT n_minNextLine; // next posiible legible
line</tt>
<br><tt>&nbsp;&nbsp;&nbsp; int m_NextCharPos; // pos in line of next char</tt>
<br><tt>&nbsp;&nbsp;&nbsp; int m_MinDisplacement;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; RECT LastPrintArea; // printing rect last used</tt>
<br><tt>&nbsp;&nbsp;&nbsp; TEXTMETRIC* tm;</tt>
<br><tt>}PRTTYPE;</tt>
<p><font size=-1>This structure is a member of the Cpage class and is maintained
internally. It is initialized in the Cpage constructor using information
passed. The TEXTMETRIC field ,LastPrintArea, and m_NextCharPos are calculated
and changed by each call to PrintText(). The print behavior is modified
by changing the uTextFlags and uPenFlags variable ( see definitions in
CPrinter.h ) .The current output string is contained in the variable Text
( isn抰 that remarkable ). The parameters are set using information passed
to the various output routines.</font>
<center><a href="#toc">Back</a>
<p>
<hr WIDTH="100%"><a NAME="cpage"></a><b><u><font size=-1>CPage Class Definitions</font></u></b></center>

<p><font size=-1>CPage contains most of the class functionality. CPage.H
and CPage.Cpp contain the class headers and class definition.</font>
<p><font size=-1>All of the print routines have a new override added that
takes a user supplied integer indentifier and passes it to a user suppled
function that will return the text to be printed. This function must be
in the form of: <b>LPCSTR (*PF_REMOTE)(int)</b> which is defined in CPage.h.
This function is set by a call to CPage::SetUserFunction(UserFunctionAddress).
If this function is not called all the output routines called form the
functions calling the user defined function will do no output and those
that return a value will return 0. All of the Print and PrintColumn functions,
including those that print to regions, have this over ride. The demo program
has been updated to show these functions in a working example. These functions
are included to make it easier to design a data independant form and to
facilitate using the library as a portion of a report generator, form generator,
etc. See <b>PrintForm5(CPage* ps)</b> located in PrintForm1.cpp. A sample
user defined function is shown below:</font>
<p><tt>LPCSTR MyFunction(int ID)</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; static CString S;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; switch(ID)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID_1:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return "Called From User Function ID 1";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID_2:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return "Called From User Function ID 2";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID_3:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return "Called From User Function ID 3";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID_4:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return "Called From User Function ID 4";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID_5:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return "Called From User Function ID 5";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID_6:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
S.Format("%.2f",120.90);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return S;</tt>
<br><tt>}</tt>
<p><tt>&nbsp;&nbsp;&nbsp; return "*****unknown ID Passed*****";</tt>
<p><b><tt>}</tt></b>
<p><font size=-1>This is a very simple version of a user function but demonstrates
how it is used. In real life it would be more complex and probably call
other functions, do calculations, and other data manipulation tasks. Just
as long as it returns a pointer to a output string all is well. The string
is used immediatly and need not be persistant. Static buffers can be re-used
between calls. However if CStrings or other variables are used as buffers
be certain that they are either static or created on the heap and not destroyed
until after use. Variables set on the stack frame will not be accessable
to the output routines because they will go out of scope on he user function
return. In order to set the call up you will call:</font>
<center><a href="#toc">Back</a></center>

<hr SIZE=3 WIDTH="100%">
<p><a NAME="SetUserFunction"></a><b><font size=-1>CPage::SetUserFunction(MyFunction);</font></b>
<p><font size=-1>This can be called more than once thereby replacing the
active function making it possible to have several output functions for
the same page. The effect of this technique is a lot like subclassing the
CPage object but without the overhead. The user defined function should
be prototyped as&nbsp; <b>typedef LPCSTR (*PF_REMOTE)(int).</b> An example
is :</font>
<p><tt>LPCSTR MyFunction(int ID)</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; switch(ID)</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID_1:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
S="Called From User Function ID 1";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return S;</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ID_2:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return "Called From User Function ID 2";</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return "";</tt>
<br><tt>}</tt>
<p><font size=-1>There is a special over ride of the Print function:</font>
<p><b><font size=-1>virtual double Print(double row,double col,UINT TextFlags,int
PointSize,int ID);</font></b>
<p><font size=-1>This function works in conjunction with the SeUserFunction
in that the user defined function is called to supply the prit text. See
the demo program for details.</font>
<p><font size=-1>Example:</font>
<p><tt>void PrintStuff(CPage* ps)</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; ps->SetUserFunction(MyFunction);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; double row=ps->Print(0.0,0.0,TEXT_NORMAL|TEXT_CENTER,24,"User
Demo");</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; row=ps->Print(row,0.0,TEXT_BOLD|TEXT_ITALIC|TEXT_CENTER,24,ID_1);</tt>
<br><tt>}</tt>
<p><a NAME="SetPrinterMode"></a><b><font size=-1>static void SetPrinterMode(CDC*
pDC,int Mode=DMORIENT_PORTRAIT);</font></b>

⌨️ 快捷键说明

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