亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch06.htm

?? Learning language of Visual C++6
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
the right as you expect, Y coordinates increase upward rather than downward. Moreover,
the default coordinates for the window are located in the lower-right quadrant of
the Cartesian coordinate system, as shown in Figure 6.5. Figure 6.6 shows the print
preview window when the application uses the MM_LOENGLISH mapping mode. When you
print the document, the rectangle is exactly 2 inches square because a unit is now
1/100 of an inch and the rectangle is 200 units square.</P>

<P><A HREF="javascript:popUp('06uvc05.gif')"><B>FIG. 6.5</B></A><B> </B><I>The MM_LOENGLISH
mapping mode's default coordinates derive from the Cartesian coordinate system.</I></P>

<P><A HREF="javascript:popUp('06uvc06.gif')"><B>FIG. 6.6</B></A><B> </B><I>The rectangle
to be printed matches the rectangle onscreen when you use MM_LOENGLISH as your mapping
mode.</I></P>
<H2><A NAME="Heading3"></A>Printing Multiple Pages</H2>
<P>When your application's document is as simple as Print1's, adding printing and
print previewing capabilities to the application is virtually automatic. This is
because the document is only a single page and requires no pagination. No matter
what you draw in the document window (except bitmaps), MFC handles all the printing
tasks for you. Your view's OnDraw() function is used for drawing onscreen, printing
to the printer, and drawing the print preview screen. Things become more complex,
however, when you have larger documents that require pagination or some other special
handling, such as the printing of headers and footers.</P>
<P>To get an idea of the problems with which you're faced with a more complex document,
modify Print1 so that it prints lots of rectangles--so many that they can't fit on
a single page. This will give you an opportunity to deal with pagination. Just to
make things more interesting, add a member variable to the document class to hold
the number of rectangles to be drawn, and allow the users to increase or decrease
the number of rectangles by left- or right-clicking. Follow these steps:</P>

<DL>
	<DD><B>1. </B>Expand CPrint1Doc in ClassView, right-click it, and choose Add Member
	Variable from the shortcut menu. The variable type is int, the declaration is m_numRects,
	and the access should be public. This variable will hold the number of rectangles
	to display.
	<P>
	<DD><B>2. </B>Double-click the CPrint1Doc constructor and add this line to it:
</DL>



<BLOCKQUOTE>
	<PRE>m_numRects = 5;</PRE>

</BLOCKQUOTE>

<PRE></PRE>

<DL>
	<DT></DT>
	<DD>This line arranges to display five rectangles in a brand new document.
	<P>
	<DT></DT>
	<DD><B>3. </B>Use ClassWizard to catch mouse clicks (WM_LBUTTONDOWN messages) by
	adding an OnLButtonDown() function to the view class (see Figure 6.7).
	<P>
	<DT></DT>
	<DD><B>4. </B>Click the Edit Code button to edit the new OnLButtonDown() function.
	It should resemble Listing 6.1. Now the number of rectangles to be displayed increases
	each time users click the left mouse button.
</DL>

<P><A HREF="javascript:popUp('06uvc07.gif')"><B>FIG. 6.7</B></A><B> </B><I>Use ClassWizard
to add the OnLButtonDown() function.</I></P>
<P>
<H4>Listing 6.1&#160;&#160;print1View.cpp --CPrint1View::OnLButtonDown()</H4>
<PRE>void CPrint1View::OnLButtonDown(UINT nFlags, CPoint point)
{
     CPrint1Doc* pDoc = GetDocument();
     ASSERT_VALID(pDoc);
     pDoc-&gt;m_numRects++;
     Invalidate();
     CView::OnLButtonDown(nFlags, point);
</PRE>
<PRE>}
</PRE>

<DL>
	<DT></DT>
	<DD><B>5. </B>Use ClassWizard to add the OnRButtonDown() function to the view class,
	as shown in Figure 6.8.
	<P>
</DL>

<P><A HREF="javascript:popUp('06uvc08.gif')"><B>FIG. 6.8</B></A><B> </B><I>Use ClassWizard
to add the OnRButtonDown() function.</I></P>
<P>

<DL>
	<DD><B>6. </B>Click the Edit Code button to edit the new OnRButtonDown() function.
	It should resemble Listing 6.2. Now the number of rectangles to be displayed decreases
	each time users right-click.
	<P>
</DL>

<H4>Listing 6.2&#160;&#160;print1View.cpp --CPrint1View::OnRButtonDown()</H4>
<PRE>void CPrint1View::OnRButtonDown(UINT nFlags, CPoint point)
{
     CPrint1Doc* pDoc = GetDocument();
     ASSERT_VALID(pDoc);
     if (pDoc-&gt;m_numRects &gt; 0)
     {
          pDoc-&gt;m_numRects--;
          Invalidate();
     }
     CView::OnRButtonDown(nFlags, point);
</PRE>
<PRE>}
</PRE>

<DL>
	<DT></DT>
	<DD><B>7. </B>Rewrite the view's OnDraw() to draw many rectangles (refer to Listing
	6.3). Print1 now draws the selected number of rectangles one below the other, which
	may cause the document to span multiple pages. It also displays the number of rectangles
	that have been added to the document.
	<P>
</DL>

<H4>Listing 6.3&#160;&#160;print1View.cpp --CPrint1View::OnDraw()</H4>
<PRE>void CPrint1View::OnDraw(CDC* pDC)
{
    CPrint1Doc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
    pDC-&gt;SetMapMode(MM_LOENGLISH);
    char s[10];
    wsprintf(s, &quot;%d&quot;, pDoc-&gt;m_numRects);
    pDC-&gt;TextOut(300, -100, s);
    for (int x=0; x&lt;pDoc-&gt;m_numRects; ++x)
    {
        pDC-&gt;Rectangle(20, -(20+x*200),
            200, -(200+x*200));
    }
</PRE>
<PRE>}
</PRE>
<P>When you run the application now, you see the window shown in Figure 6.9. The
window not only displays the rectangles but also displays the rectangle count so
that you can see how many rectangles you've requested. When you choose File, Print
Preview, you see the print preview window. Click the Two Page button to see the window
shown in Figure 6.10. The five rectangles display properly on the first page, with
the second page blank.</P>
<P><A HREF="javascript:popUp('06uvc09.gif')"><B>FIG. 6.9</B></A><B> </B><I>Print1
now displays multiple rectangles.</I></P>
<P><A HREF="javascript:popUp('06uvc10.gif')"><B>FIG. 6.10</B></A><B> </B><I>Five
rectangles are previewed properly; they will print on a single page.</I></P>
<P>Now, go back to the application's main window and click inside it three times
to add three more rectangles. Right-click to remove one. (The rectangle count displayed
in the window should be seven.) After you add the rectangles, choose File, Print
Preview again to see the two-page print preview window. Figure 6.11 shows what you
see. The program hasn't a clue how to print or preview the additional page. The sixth
rectangle runs off the bottom of the first page, but nothing appears on the second
page.</P>
<P>The first step is to tell MFC how many pages to print (or preview) by calling
the SetMaxPage() function in the view class's OnBeginPrinting() function. AppWizard
gives you a skeleton OnBeginPrinting() that does nothing. Modify it so that it resembles
Listing 6.4.</P>
<P><A HREF="javascript:popUp('06uvc11.gif')"><B>FIG. 6.11</B></A><B> </B><I>Seven
rectangles do not yet appear correctly on multiple pages.</I></P>
<P>
<H4>Listing 6.4&#160;&#160;print1View.cpp --CPrint1View::OnBeginPrinting()</H4>
<PRE>void CPrint1View::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
    CPrint1Doc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
     int pageHeight = pDC-&gt;GetDeviceCaps(VERTRES);
     int logPixelsY = pDC-&gt;GetDeviceCaps(LOGPIXELSY);
     int rectHeight = (int)(2.2 * logPixelsY);
     int numPages = pDoc-&gt;m_numRects * rectHeight / pageHeight + 1;
     pInfo-&gt;SetMaxPage(numPages);
</PRE>
<PRE>}
</PRE>
<P>OnBeginPrinting() takes two parameters: a pointer to the printer device context
and a pointer to a CPrintInfo object. Because the default version of OnBeginPrinting()
doesn't refer to these two pointers, the parameter names are commented out to avoid
compilation warnings, like this:</P>
<P>
<PRE>void CPrint1View::OnBeginPrinting(CDC* /*pDC*/ , CPrintInfo* /*pInfo*/)
</PRE>
<P>However, to set the page count, you need to access both the CDC and CPrintInfo
objects, so your first task is to uncomment the function's parameters.</P>
<P>Now you need to get some information about the device context (which, in this
case, is a printer device context). Specifically, you need to know the page height
(in single dots) and the number of dots per inch. You obtain the page height with
a call to GetDeviceCaps(), which gives you information about the capabilities of
the device context. You ask for the vertical resolution (the number of printable
dots from the top of the page to the bottom) by passing the constant VERTRES as the
argument. Passing HORZRES gives you the horizontal resolution. There are 29 constants
you can pass to GetDeviceCaps(), such as NUMFONTS for the number of fonts that are
supported and DRIVERVERSION for the driver version number. For a complete list, consult
the online Visual C++ documentation.</P>
<P>Print1 uses the MM_LOENGLISH mapping mode for the device context, which means
that the printer output uses units of 1/100 of an inch. To know how many rectangles
will fit on a page, you have to know the height of a rectangle in dots so that you
can divide dots per page by dots per rectangle to get rectangles per page. (You can
see now why your application must know all about your document to calculate the page
count.) You know that each rectangle is 2 inches high with 20/100 of an inch of space
between each rectangle. The total distance from the start of one rectangle to the
start of the next, then, is 2.2 inches. The call to GetDeviceCaps() with an argument
of LOGPIXELSY gives the dots per inch of this printer; multiplying by 2.2 gives the
dots per rectangle.</P>
<P>You now have all the information to calculate the number of pages needed to fit
the requested number of rectangles. You pass that number to SetMaxPage(), and the
new OnBeginPrinting() function is complete.</P>
<P>Again, build and run the program. Increase the number of rectangles to seven by
clicking twice in the main window. Now choose File, Print Preview and look at the
two-page print preview window (see Figure 6.12). Whoops! You obviously still have
a problem somewhere. Although the application is previewing two pages, as it should
with seven rectangles, it's printing exactly the same thing on both pages. Obviously,
page two should take up where page one left off, rather than redisplay the same data
from the beginning. There's still some work to do.</P>
<P><A HREF="javascript:popUp('06uvc12.gif')"><B>FIG. 6.12</B></A><B> </B><I>The Print1
application still doesn't display multiple pages correctly.</I></P>
<P>
<H2><A NAME="Heading4"></A>Setting the Origin</H2>
<P>To get the second and subsequent pages to print properly, you have to change where
MFC believes the top of the page to be. Currently, MFC just draws the pages exactly
as you told it to do in CPrint1View::OnDraw(), which displays all seven rectangles
from the top of the page to the bottom. To tell MFC where the new top of the page
should be, you first need to override the view class's OnPrepareDC() function.</P>
<P>Bring up ClassWizard and choose the Message Maps tab. Ensure that CPrintView is
selected in the Class Name box, as shown in Figure 6.13. Click CPrintView in the
Object IDs box and OnPrepareDC in the Messages box, and then click Add Function.
Click the Edit Code button to edit the newly added function. Add the code shown in
Listing 6.5.</P>
<P><A HREF="javascript:popUp('06uvc13.gif')"><B>FIG. 6.13</B></A><B> </B><I>Use ClassWizard
to override the OnPrepareDC() function.</I></P>
<P>
<H4>Listing 6.5&#160;&#160;print1View.cpp --CPrint1View::OnPrepareDC()</H4>
<PRE>void CPrint1View::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
</PRE>
<PRE>{    if (pDC-&gt;IsPrinting())
    {
        int pageHeight = pDC-&gt;GetDeviceCaps(VERTRES);
        int originY = pageHeight * (pInfo-&gt;m_nCurPage - 1);
        pDC-&gt;SetViewportOrg(0, -originY);
    }
    CView::OnPrepareDC(pDC, pInfo);
</PRE>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品一二三四| 亚洲.国产.中文慕字在线| 天堂成人免费av电影一区| 国产精品影视网| 欧美一区二区三区视频在线 | 91精品国产色综合久久| 中文字幕乱码一区二区免费| 男人的j进女人的j一区| 欧美日韩国产高清一区二区| 国产精品久久免费看| 国产精品一二三四五| 日韩女优视频免费观看| 日韩国产欧美在线播放| 在线视频国内自拍亚洲视频| 最新欧美精品一区二区三区| 国产一区在线观看视频| 日韩一区二区三区视频在线| 亚洲成人av在线电影| 欧美亚洲免费在线一区| 最新不卡av在线| 99麻豆久久久国产精品免费 | 一区二区三区日韩精品| av一本久道久久综合久久鬼色| 久久女同互慰一区二区三区| 麻豆精品精品国产自在97香蕉| 91精品国产欧美一区二区| 亚洲一区二区三区国产| 在线视频观看一区| 亚洲二区视频在线| 欧美日韩国产不卡| 水野朝阳av一区二区三区| 欧美久久久久免费| 男女男精品视频| 精品国产乱码久久久久久夜甘婷婷| 日日夜夜精品视频天天综合网| 欧美日韩不卡在线| 喷白浆一区二区| 2024国产精品| 成人免费观看男女羞羞视频| 一区在线观看视频| 在线日韩av片| 日本成人在线电影网| 日韩一级二级三级精品视频| 国产在线视视频有精品| 日韩欧美不卡在线观看视频| 国产乱色国产精品免费视频| 国产精品视频一区二区三区不卡| 91在线视频在线| 亚洲成人一区二区| 日韩欧美激情一区| 成人性生交大片免费看中文| 日韩理论电影院| 91精品国产色综合久久久蜜香臀| 国产在线观看一区二区| 国产精品久久久久影院老司| 欧美亚洲高清一区| 紧缚奴在线一区二区三区| 日本一区二区免费在线| 在线免费亚洲电影| 久久精品国产99国产精品| 日本一区二区成人在线| 欧美日韩国产综合视频在线观看| 精品一区二区综合| 国产精品久久久久久亚洲伦| 欧美喷水一区二区| 成人高清在线视频| 秋霞国产午夜精品免费视频| 国产精品久线观看视频| 91精品中文字幕一区二区三区| 国产成人精品综合在线观看| 亚洲成人av中文| 国产精品美女久久久久久久久| 91精品国产欧美日韩| 成人精品在线视频观看| 日韩精品一二三| 亚洲日本乱码在线观看| 欧美精品一区二区在线观看| 欧美午夜电影网| 成人av在线看| 久久精品国产澳门| 五月天网站亚洲| 1000部国产精品成人观看| 日韩精品一区国产麻豆| 欧美影片第一页| 91在线观看污| 成人小视频免费观看| 激情综合色综合久久| 亚洲成av人片www| 亚洲欧美另类小说视频| 久久久久久久久久美女| 欧美日韩国产a| 欧美曰成人黄网| av色综合久久天堂av综合| 激情欧美日韩一区二区| 午夜精品免费在线| 一区二区三国产精华液| 亚洲欧美另类小说| 国产精品美女久久久久久| 久久久亚洲高清| 精品福利一区二区三区| 91精品麻豆日日躁夜夜躁| 欧美网站大全在线观看| 色欧美片视频在线观看在线视频| 成人av在线资源网站| 成人污视频在线观看| 国产99精品在线观看| 国产不卡视频一区| 国产精品系列在线播放| 国产91在线观看丝袜| 成人在线视频一区| 不卡视频一二三四| 91麻豆国产福利在线观看| 97精品久久久午夜一区二区三区 | 美腿丝袜一区二区三区| 亚洲国产精品天堂| 午夜久久久影院| 日本美女视频一区二区| 麻豆精品精品国产自在97香蕉| 美女一区二区在线观看| 久久精品国产一区二区三 | 中文字幕国产精品一区二区| 国产清纯白嫩初高生在线观看91| 亚洲国产精品成人久久综合一区| 亚洲激情综合网| 亚洲高清免费观看高清完整版在线观看| 亚洲人成伊人成综合网小说| 一区二区在线观看视频| 午夜免费欧美电影| 紧缚奴在线一区二区三区| 粗大黑人巨茎大战欧美成人| 99久久精品免费看国产免费软件| 色综合天天性综合| 欧美日韩国产一二三| 在线不卡一区二区| 亚洲精品在线免费观看视频| 国产精品久久久久精k8| 亚洲a一区二区| 国产麻豆视频一区二区| 91久久一区二区| 在线播放中文字幕一区| 国产午夜精品久久久久久免费视| 亚洲欧美色综合| 欧美96一区二区免费视频| 国产69精品久久久久毛片 | 日韩av一区二区在线影视| 国产精品自拍av| 91行情网站电视在线观看高清版| 7777精品伊人久久久大香线蕉 | 国产精品不卡视频| 婷婷综合久久一区二区三区| 99久久久久久| 精品国产sm最大网站免费看| 综合中文字幕亚洲| 久久超级碰视频| 色欧美乱欧美15图片| 精品久久久网站| 一区二区在线观看免费| 韩国午夜理伦三级不卡影院| 在线观看亚洲精品| 国产夜色精品一区二区av| 亚洲成人你懂的| 成人黄色av电影| 日韩欧美国产一区二区在线播放| 成人免费一区二区三区视频| 国产一区久久久| 欧美高清视频在线高清观看mv色露露十八 | 欧美精品一区二区三区久久久| 国产精品无遮挡| 国模无码大尺度一区二区三区| 在线一区二区三区| 亚洲国产精品高清| 国产自产视频一区二区三区| 3d成人动漫网站| 亚洲电影激情视频网站| 成人黄色a**站在线观看| 亚洲精品一区二区在线观看| 五月天丁香久久| 欧美艳星brazzers| 亚洲视频综合在线| 99久久久国产精品| 国产精品久久久久久亚洲毛片 | 91精品在线免费观看| 亚洲一区二区三区在线看| 91一区二区在线| 成人免费小视频| 99re66热这里只有精品3直播| 国产女人水真多18毛片18精品视频| 美女在线观看视频一区二区| 在线不卡中文字幕播放| 偷拍亚洲欧洲综合| 欧美三级日韩在线| 亚洲成人动漫在线免费观看| 色成人在线视频| 亚洲另类在线制服丝袜| 在线精品视频一区二区| 亚洲福利视频三区| 欧美日本韩国一区二区三区视频| 天堂在线亚洲视频| 日韩精品影音先锋| 国产精品亚洲а∨天堂免在线|