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

📄 ch06.htm

📁 VC使用大全。里面集合了VC使用的各种使用技巧。非常有用。
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<pre><font color="#008000">void CPaint1View::OnLButtonDown(UINT nFlags, CPoint point) </font></pre>

<pre><font color="#008000">{</font></pre>

<pre><font color="#008000">     if (m_Display == Fonts)</font></pre>

<pre><font color="#008000">          m_Display = Pens;</font></pre>

<pre><font color="#008000">     else if (m_Display == Pens)</font></pre>

<pre><font color="#008000">          m_Display = Brushes;</font></pre>

<pre><font color="#008000">     else</font></pre>

<pre><font color="#008000">          m_Display = Fonts;</font></pre>

<pre><font color="#008000">     Invalidate();</font></pre>

<pre><font color="#008000">     </font></pre>

<pre><font color="#008000">     CView::OnLButtonDown(nFlags, point);</font></pre>

<pre><font color="#008000">}</font></pre>

<P>As you can see, depending on its current value, <font color="#008000">m_display</font> gets set to the next display type in the series. Of course, just changing the value of <font color="#008000">m_display</font> doesn't accomplish much. The program 
still needs to redraw the contents of its window. The call to <font color="#008000">Invalidate()</font> tells Windows that all of the window needs to be repainted. This causes Windows to generate a <font color="#008000">WM_PAINT</font> message for the 
window, which means that eventually OnDraw() will be called, and the view will be redrawn as a font, pen, or brush demonstration.</P>

<P><B>Using Fonts</B></P>

<P>Changing the font used in a view is a technique you will want to use in a variety of situations. It&#146;s not as simple as you might think, because you can never be sure that any given font is actually installed on the user&#146;s machine. You set up 
a structure that holds information about the font you want, and attempt to create it, then work with the font you actually got, which might not be quite the font you asked for.</P>

<P>A Windows font is described in the <font color="#008000">LOGFONT</font> structure, which is outlined in Table 6.1. The <font color="#008000">LOGFONT</font> structure uses 14 fields to hold a complete description of the font. Many of the fields can be 
set to 0 or the default values, depending on the program's needs.</P>

<P><I>Table 6.1&#151;</I>LOGFONT<I> Fields and Their Descriptions</I></P>

<TABLE BORDER>

<TR>

<TD>

<P><B>Field</B></P>

<TD>

<P><B>Description</B></P>

<TR>

<TD>

<pre><font color="#008000">lfHeight</font></pre>

<TD>

<P>Height of font in logical units.</P>

<TR>

<TD>

<pre><font color="#008000">lfWidth</font></pre>

<TD>

<P>Width of font in logical units.</P>

<TR>

<TD>

<pre><font color="#008000">lfEscapement</font></pre>

<TD>

<P>Angle at which to draw the text.</P>

<TR>

<TD>

<pre><font color="#008000">lfOrientation</font></pre>

<TD>

<P>Character tilt in tenths of a degree.</P>

<TR>

<TD>

<pre><font color="#008000">lfWeight</font></pre>

<TD>

<P>Font weight: </P>

<TR>

<TD>

<pre><font color="#008000">lfItalic</font></pre>

<TD>

<P>A nonzero value indicates italics.</P>

<TR>

<TD>

<pre><font color="#008000">lfUnderline</font></pre>

<TD>

<P>A nonzero value indicates an underlined font.</P>

<TR>

<TD>

<pre><font color="#008000">lfStrikeOut</font></pre>

<TD>

<P>A nonzero value indicates a strikethrough font.</P>

<TR>

<TD>

<pre><font color="#008000">lfCharSet</font></pre>

<TD>

<P>Font character set.</P>

<TR>

<TD>

<pre><font color="#008000">lfOutPrecision</font></pre>

<TD>

<P>How to match requested font to actual font.</P>

<TR>

<TD>

<pre><font color="#008000">lfClipPrecision</font></pre>

<TD>

<P>How to clip characters that run over clip area.</P>

<TR>

<TD>

<pre><font color="#008000">lfQuality</font></pre>

<TD>

<P>Print quality of the font.</P>

<TR>

<TD>

<pre><font color="#008000">lfPitchAndFamily</font></pre>

<TD>

<P>Pitch and font family.</P>

<TR>

<TD>

<pre><font color="#008000">lfFaceName</font></pre>

<TD>

<P>Typeface name.</P></TABLE>

<P>Some of the terms in Table 6.1 need a little explanation. The first is <I>logical units</I>. How high is a font that has a height of 8 logical units, for example? The meaning of a logical unit depends on the <I>mapping mode</I> you are using, as shown 
in Table 6.2. The default mapping mode is MM_TEXT, which means that one logical unit is equal to one pixel. Mapping modes are discussed in more detail in <A HREF="index07.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index07.htm" target="text">Chapter 7</A>, &quot;Printing and Print Preview.&quot;</P>

<P><I>Table 7.2&#151;Mapping Modes</I></P>

<TABLE BORDER>

<TR>

<TD>

<P><B>Mode</B></P>

<TD>

<P><B>Unit</B></P>

<TR>

<TD>

<P>MM_HIENGLISH</P>

<TD>

<P>0.001 inch</P>

<TR>

<TD>

<P>MM_HIMETRIC</P>

<TD>

<P>0.01 millimeter</P>

<TR>

<TD>

<P>MM_ISOTROPIC</P>

<TD>

<P>arbitrary</P>

<TR>

<TD>

<P>MM_LOENGLISH</P>

<TD>

<P>0.01 inch</P>

<TR>

<TD>

<P>MM_LOMETRIC</P>

⌨️ 快捷键说明

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