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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ch11.htm

?? 一天之內(nèi)學會VC#. 主要介紹VC#的各種應(yīng)用和示例
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>
	
	<META NAME="GENERATOR" Content="Symantec Visual Page Mac 1.1">
	<TITLE>Teach Yourself Visual C++&#174; 5 in 24 Hours -- Hour 11 -- Device Contexts</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<H1 ALIGN="CENTER"><IMG SRC="sams.gif" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM"
BORDER="0"><BR>
<FONT COLOR="#000077">Teach Yourself Visual C++&#174; 5 in 24 Hours</FONT></H1>
<CENTER>
<P><A HREF="ch10.htm" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/ch10/ch10.htm"><IMG SRC="previous.gif" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/button/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="ch12.htm" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/ch12/ch12.htm"><IMG
SRC="next.gif" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="index-1.htm" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/index.htm"><IMG SRC="contents.gif" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/button/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> 
<HR>

</CENTER>
<H1 ALIGN="CENTER"><FONT COLOR="#000077">- Hour 11 -<BR>
Device Contexts</FONT></H1>
<P>All output in a program written for Windows must be done using a device context.
A <I>device context</I> is an important part of the Windows Graphics Device Interface,
or GDI. Device contexts are used by Windows and applications to provide device-independent
output.</P>
<P>In this hour, you will learn

<UL>
	<LI>The different type of device contexts used in Windows and the MFC classes that
	support them<BR>
	<BR>
	
	<LI>How to use device mapping modes<BR>
	<BR>
	
	<LI>How to use GDI objects in your Windows application<BR>
	<BR>
	
	<LI>How to use the different options for text output in Windows
</UL>

<P>You also will build a sample program that demonstrates how a device context is
used with text output.
<H2><FONT COLOR="#000077"><B>What Are Device Contexts?</B></FONT></H2>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>A <I>device context</I>,
often abbreviated as <I>DC</I>, is a structure that stores information needed when
a program written for Windows must display output to a device. Device contexts are
maintained by Windows. The device context stores information about the drawing surface
and its capabilities. Before using any of the GDI output functions, you must create
a device context.


<BLOCKQUOTE>
	<P>
<HR>
<B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>Deep down inside
	Windows, device contexts are actually structures that the GDI uses to track the current
	output state for a window. However, you never have access to the individual members
	of a device context; instead, all access to device contexts occurs through function
	calls. 
<HR>


</BLOCKQUOTE>

<P>The simplest reason to use device contexts is because they are required; there's
simply no other way to perform output in a Windows program without them. However,
using a device context is the first step toward using many of the GDI features that
are available under Windows. Understanding how device contexts work can also help
make your Windows programs more efficient.
<H3><FONT COLOR="#000077"><B>Types of GDI Objects</B></FONT></H3>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>Associating a GDI object
with a device context is commonly referred to as <I>selecting</I> a GDI object into
the device context.</P>
<P>A GDI object can be selected into a device context in order to provide specific
drawing capabilities for the DC. Each GDI object can be used to create a different
type of output. For example, a GDI pen object can be used to draw lines, whereas
brush objects are used to fill screen areas. The GDI objects most commonly used with
device contexts are listed in Table 11.1.
<H4><FONT COLOR="#000077">Table 11.1. Commonly used GDI objects in Windows programs.</FONT></H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT"><B>Object</B></TD>
		<TD ALIGN="LEFT"><B>Purpose</B></TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT">Pen</TD>
		<TD ALIGN="LEFT">Drawing lines</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT">Brush</TD>
		<TD ALIGN="LEFT">Filling regions</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT">Bitmap</TD>
		<TD ALIGN="LEFT">Displaying images</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT">Font</TD>
		<TD ALIGN="LEFT">Typeface characteristics</TD>
	</TR>
</TABLE>

<H3><FONT COLOR="#000077"><B>Types of Device Contexts</B></FONT></H3>
<P>Windows and the MFC class library provide the following four different basic types
of device contexts. Although you use these device contexts in different situations,
the basic rules for their use are consistent.

<UL>
	<LI>Display DCs, used to display information to a standard video terminal. These
	are the most commonly used device contexts in a Windows program.<BR>
	<BR>
	
	<LI>Printer DCs, used to display output on a printer or plotter.<BR>
	<BR>
	
	<LI>Memory DCs, sometimes called <I>compatible device contexts</I>, used to perform
	drawing operations on a bitmap.<BR>
	<BR>
	
	<LI>Information DCs, used to collect information on a device. These DCs cannot be
	used for actual output. However, they are extremely fast and have little overhead,
	and therefore are ideal for use when information is being collected.
</UL>

<P>With the exception of the information device contexts, each of the different DC
types is used to create a different type of output. In addition, the MFC class library
offers several different types of display device contexts, which are covered in the
section &quot;How to Use Device Contexts.&quot;
<H3><FONT COLOR="#000077"><B>Hardware Independence</B></FONT></H3>
<P>The goal behind using device contexts is to give programs written for Windows
hardware independence. With a little care, your program can run on any display or
printer that's supported by a Windows hardware driver. Most new output devices supply
a driver if Windows doesn't currently provide automatic support. This means that
programs you write today will work with display devices that have not been developed
yet.


<BLOCKQUOTE>
	<P>
<HR>
<B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>Because of the
	way device contexts insulate a program written for Windows from the actual device
	hardware, output is often said to be &quot;written to a device context.&quot; This
	independence from hardware makes it easy to send output to a printer that looks very
	much like screen output. You will learn more about printing in detail in Hour 21,
	&quot;Printing.&quot; 
<HR>


</BLOCKQUOTE>

<P>In order to achieve true hardware independence, you must take a few precautions:

<UL>
	<LI>Don't hard-code any dimensions into your program. Larger or smaller screens or
	printers will cause hard-coded dimensions to look skewed or distorted.<BR>
	<BR>
	
	<LI>Don't assume that Windows is running on a display with a particular resolution.
	Making assumptions about video monitors, in particular, is a bad idea. It's a sure
	bet that many people don't use your screen resolution or dimensions.<BR>
	<BR>
	
	<LI>Don't assume that a certain set of colors are available or are appropriate in
	all cases. For example, don't assume the workspace background is always white. A
	large number of Windows users have laptops that simulate VGA displays. Other users
	often change the available color scheme. The selection of colors used is strictly
	up to the user.
</UL>

<P>Device contexts can help by providing much of the information you need to stay
hardware-independent.
<H2><FONT COLOR="#000077"><B>How to Use Device Contexts</B></FONT></H2>
<P>When using Developer Studio, you almost always use an MFC class to gain access
to a device context. The MFC class library offers not just one, but four different
device context classes that can help make your life easier, at least when displaying
output in a Windows program:

<UL>
	<LI><TT>CDC</TT>: The base class for all the device context classes<BR>
	<BR>
	
	<LI><TT>CPaintDC</TT>: Performs some useful housekeeping functions that are needed
	when a window responds to <TT>WM_PAINT</TT><BR>
	<BR>
	
	<LI><TT>CClientDC</TT>: Used when a device context will be used only for output to
	a window's client area<BR>
	<BR>
	
	<LI><TT>CWindowDC</TT>: Used when the entire window can be drawn on
</UL>

<P>There are more MFC device context classes, but they are used for specialized purposes
and are discussed elsewhere in this book. For example, the <TT>CPrinterDC</TT> class
is discussed in Hour 21.
<H3><FONT COLOR="#000077"><B>Wizard Support for Device Contexts</B></FONT></H3>
<P>When you create a class using ClassWizard or AppWizard, often code that uses or
creates a device context is provided automatically. For example, the <TT>OnDraw</TT>
function for a typical view class is provided in Listing 11.1.
<H4><FONT COLOR="#000077">TYPE: Listing 11.1. A typical OnDraw function.</FONT></H4>
<PRE><FONT COLOR="#0066FF"><TT>void CDisplayView::OnDraw(CDC* pDC)</TT>
<TT>{</TT>
<TT>    CDocument* pDoc = GetDocument();</TT>
<TT>    // TODO: add draw code here</TT>
<TT>}</TT>
</FONT></PRE>
<P>The device context used for the <TT>OnDraw</TT> function is created by the MFC
framework before the <TT>OnDraw</TT> function is called. Because every <TT>OnDraw</TT>
function must display some output, the device context is provided for you automatically,
without the need for you to write any code.</P>
<P>Most functions that need a device context have one provided as a parameter, just
like <TT>OnDraw</TT>. This is one of the ways MFC helps make your code easier to
write and more reliable at the same time.
<H3><FONT COLOR="#000077"><B>Selecting a GDI Object</B></FONT></H3>
<P>One of the most common mistakes made when using device contexts occurs when selecting
a GDI object into a DC. When a device context is created, it contains a set of default
GDI objects, as shown in Figure 11.1.</P>
<P><A NAME="01"></A><A HREF="01.htm" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/ch11/01.htm"><B>Figure 11.1.</B></A> <BR>
<I>A device context created with a collection of default GDI objects.</I></P>
<P>When a new GDI object--for example, a bitmap--is selected into a device context,
the default GDI bitmap is passed as a return value to the caller. This return value
must be saved so that it can be returned to the device context later. Listing 11.2
is an example of selecting a new bitmap into a DC and returning the previously selected
GDI object at the end of the function.
<H4><FONT COLOR="#000077">TYPE: Listing 11.2. Selecting and restoring a GDI object.</FONT></H4>
<PRE><FONT COLOR="#0066FF"><TT>CBitmap     bmpHello;</TT>
<TT>bmpHello.LoadBitmap( IDB_HELLO );</TT>
<TT>CBitmap* pbmpOld = dcMem.SelectObject( &amp;bmpHello );</TT>
<TT>if( pbmpOld != NULL )</TT>
<TT>{</TT>
<TT>    //</TT>
<TT>    // Use the bitmap...</TT>
<TT>    //</TT>
<TT>    dcMem.SelectObject( pbmpOld );</TT>
<TT>}</TT>
</FONT></PRE>
<P>Notice that the <TT>pbmpOld</TT> value is checked to make sure that it isn't <TT>NULL</TT>.
If the call to <TT>SelectObject</TT> fails, the original bitmap is not returned.
In that case, there's no need to return the original bitmap to the DC, because a
new one was never selected.


<BLOCKQUOTE>
	<P>
<HR>
<B> </B><FONT COLOR="#000077"><B>CAUTION:</B></FONT><B> </B>You must restore the
	device context to its original state when you are finished with it. If you don't,
	resources that you have selected into a device context might not be properly released,
	causing your program to consume more and more GDI resources. This type of problem
	is known as a resource leak and is very difficult to track down--getting into the
	habit of always restoring the original object back into the device context is much
	better. 
<HR>


</BLOCKQUOTE>

<H2><FONT COLOR="#000077"><B>Stock Objects</B></FONT></H2>
<P>A group of commonly used GDI objects known as stock objects are maintained by
Windows. These objects are much easier to use than objects that you create yourself.
To select a stock object into a device context, use the <TT>SelectStockObject</TT>
function:</P>
<PRE><FONT COLOR="#0066FF"><TT>HPEN hOldPen = pDC-&gt;SelectStockObject(BLACK_PEN);</TT>
</FONT></PRE>
<P>Although stock objects do not need to be destroyed after they are used, attempting
to destroy a stock object is not harmful. Table 11.2 describes the 16 stock objects
available for use in your Windows programs.
<H4><FONT COLOR="#000077">Table 11.2. Windows stock objects.</FONT></H4>
<P>
<TABLE BORDER="1">

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91福利社在线观看| 精品国产91久久久久久久妲己| 欧美日韩二区三区| 久久精品水蜜桃av综合天堂| 一区二区三区在线免费视频| 亚洲婷婷在线视频| 国产激情精品久久久第一区二区| 91福利在线播放| 亚洲欧美国产77777| 蜜臀国产一区二区三区在线播放| 99久久伊人久久99| 亚洲精品一区二区三区福利| 亚洲成人在线观看视频| 不卡的av在线| 国产精品―色哟哟| 精品一区二区免费视频| 911精品国产一区二区在线| 亚洲精品乱码久久久久久黑人| 国产成人在线电影| 久久无码av三级| 麻豆视频一区二区| 欧美日韩aaaaa| 亚洲成精国产精品女| 99re8在线精品视频免费播放| 国产日韩欧美综合在线| 美国十次综合导航| 日韩精品一区国产麻豆| 日韩电影免费在线看| 欧美日韩一区二区三区视频| 一区二区在线观看视频在线观看| 成人av在线播放网址| 国产欧美精品一区二区色综合朱莉| 久久99久久99小草精品免视看| 91精品国产91热久久久做人人| 丝袜美腿亚洲一区二区图片| 欧美日韩成人激情| 免费在线观看精品| 日韩免费看的电影| 国产麻豆精品视频| 欧美激情在线观看视频免费| 捆绑调教美女网站视频一区| 欧美不卡一区二区| 国产精品一区在线| 国产精品精品国产色婷婷| 色综合久久天天综合网| av成人免费在线| 亚洲精品福利视频网站| 777亚洲妇女| 欧美成人一区二区三区片免费| 免费久久精品视频| 久久精品水蜜桃av综合天堂| 99久久免费视频.com| 亚洲成人中文在线| ww久久中文字幕| 99久久99久久免费精品蜜臀| 一二三四社区欧美黄| 欧美日韩电影在线播放| 国产一区二区在线看| 国产精品乱码一区二区三区软件 | 一区二区三区欧美激情| 欧美亚州韩日在线看免费版国语版| 视频一区二区中文字幕| 26uuu久久天堂性欧美| 成人在线视频一区| 亚洲国产成人av网| 久久美女艺术照精彩视频福利播放| 成人精品视频一区二区三区| 亚洲一区在线电影| 精品国产1区二区| 欧美在线影院一区二区| 国产中文字幕精品| 亚洲一区在线观看免费 | 精品一区二区国语对白| 国产精品久久福利| 精品久久五月天| 色国产精品一区在线观看| 亚洲国产成人porn| 中文字幕国产一区二区| 91精品久久久久久久99蜜桃| 成人免费视频国产在线观看| 三级成人在线视频| 国产精品国产三级国产普通话99| 欧美一区二区三区四区久久| 国产91精品在线观看| 日韩国产精品久久| 亚洲免费观看高清完整版在线观看 | 欧美一级黄色录像| 91小宝寻花一区二区三区| 美国一区二区三区在线播放| 夜色激情一区二区| 国产精品色噜噜| 久久久久久久一区| 欧美一区二区三区不卡| 色噜噜狠狠成人中文综合| 国产久卡久卡久卡久卡视频精品| 亚洲电影视频在线| 亚洲免费观看高清| 国产精品久久久久影院亚瑟 | 欧美另类高清zo欧美| av影院午夜一区| 国产伦精品一区二区三区免费迷 | 午夜精品久久久久| 亚洲天堂网中文字| 自拍偷拍亚洲综合| 国产精品视频观看| 激情综合网最新| 精品久久久久久久久久久久包黑料 | 欧美精品日韩综合在线| 色哟哟精品一区| 91在线视频官网| 91色porny| 91久久精品一区二区三| 99久久精品久久久久久清纯| 成人激情开心网| 大胆亚洲人体视频| 成人久久视频在线观看| 国产成人av福利| 成人午夜在线视频| 成人黄色综合网站| 99久久婷婷国产| 欧美性做爰猛烈叫床潮| 色狠狠综合天天综合综合| 日本韩国欧美一区| 欧美日韩国产影片| 久久久国际精品| 国产精品一级片在线观看| 国产在线精品一区在线观看麻豆| 狠狠v欧美v日韩v亚洲ⅴ| 国内精品伊人久久久久影院对白| 国产一区二区网址| 懂色av一区二区三区免费观看| k8久久久一区二区三区| 91丨porny丨最新| 欧美视频一区二区| 欧美一级夜夜爽| 国产片一区二区| 亚洲精品免费在线观看| 三级亚洲高清视频| 国产一区不卡在线| 91农村精品一区二区在线| 欧美日韩精品专区| 337p粉嫩大胆噜噜噜噜噜91av | 国产精品亚洲第一区在线暖暖韩国| 国产精品系列在线观看| 91麻豆福利精品推荐| 欧美精品粉嫩高潮一区二区| 欧美成人三级在线| 中文字幕一区二区三区不卡在线| 亚洲一区二区成人在线观看| 日本欧美一区二区| 成人h动漫精品一区二区| 欧美日韩一本到| 欧美激情一区二区三区全黄| 亚洲伦在线观看| 国产在线精品不卡| 91久久精品网| 国产日韩精品一区二区浪潮av| 亚洲第一搞黄网站| 成人性生交大片免费看中文| 欧美日韩国产中文| 国产精品女主播av| 麻豆精品在线观看| 欧美综合一区二区三区| 久久久蜜臀国产一区二区| 怡红院av一区二区三区| 国产成人午夜99999| 欧美综合在线视频| 国产精品久久久久aaaa| 国内精品在线播放| 91精品国产乱| 亚瑟在线精品视频| 91首页免费视频| 久久久一区二区三区捆绑**| 亚洲国产视频a| 91麻豆swag| 国产精品久久久久影院亚瑟| 国产一区美女在线| 欧美一区在线视频| 亚洲444eee在线观看| yourporn久久国产精品| 久久先锋资源网| 精品一区二区三区在线观看 | 中文字幕中文字幕一区二区| 经典一区二区三区| 这里是久久伊人| 亚洲成精国产精品女| 色婷婷精品大在线视频| 国产精品不卡在线观看| 日本伊人色综合网| 欧美人体做爰大胆视频| 亚洲精选在线视频| 一道本成人在线| 亚洲色图视频免费播放| 99综合影院在线| 最新国产成人在线观看| 成人一区二区在线观看| 中文字幕不卡三区| 成人一区二区三区中文字幕| 亚洲国产高清aⅴ视频| 国产成人在线观看|