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

📄 vcc58.htm

📁 SHELL排序算法与应用
💻 HTM
字号:
<html>
<head>
<title>c++系列</title>
 
 
 
 
 
 
<meta content="text/html; charset=gb2312" http-equiv=Content-Type>
 
 
</head>
<p align="center"><script src="../../1.js"></script></a>

<body bgcolor="#ffffff" leftmargin="5" topmargin="1" marginheight="5" marginwidth="5">
<div align=center> 
  <table border=0 cellpadding=0 cellspacing=0 width=680 align="center">
    <tbody> 
    <tr> 
      <td width=200 height="59"> 
         
    </tr>
    </tbody> 
  </table>
  <table border=1 bordercolordark=#ffffff bordercolorlight=#ffffff cellpadding=0 
cellspacing=0 width=685 align="center" height="70">
    <tbody> 
    <tr> 
      <td bgcolor=#ffffff height=2> 
        <div align=center class=H1> 和GUI有关的各种对象</font></div>
      </td>
    </tr>
    <tr valign=top> 
      <td class=H1 height=51> 
        <p align="left">在Windows中有各种GUI对象(不要和C++对象混淆),当你在进行绘图就需要利用这些对象。而各种对象都拥有各种属性,下面分别讲述各种GUI对象和拥有的属性。</p>
        <p class="unnamed1">字体对象CFont用于输出文字时选用不同风格和大小的字体。可选择的风格包括:是否为斜体,是否为粗体,字体名称,是否有下划线等。<font 
            color=red>颜色和背景色不属于字体的属性。</font>关于如何创建和使用字体在2.2 在窗口中输出文字中会详细讲解。</p>
        <p class="unnamed1">刷子CBrush对象决定填充区域时所采用的颜色或模板。对于一个固定色的刷子来讲它的属性为颜色,是否采用网格和网格的类型如水平的,垂直的,交叉的等。你也可以利用8*8的位图来创建一个自定义模板的刷子,在使用这种刷子填充时系统会利用位图逐步填充区域。关于如何创建和使用刷子在2.3 
          使用刷子,笔进行绘图中会详细讲解。</p>
        <p class="unnamed1">画笔CPen对象在画点和画线时有用。它的属性包括颜色,宽度,线的风格,如虚线,实线,点划线等。关于如何创建和使用画笔在2.3 
          使用刷子,笔进行绘图中会详细讲解。</p>
        <p class="unnamed1">位图CBitmap对象可以包含一幅图像,可以保存在资源中。关于如何使用位图在2.4 在窗口中绘制设备相关位图,图标,设备无关位图中会详细讲解。</p>
        <p class="unnamed1">还有一种特殊的GUI对象是多边形,利用多边形可以很好的限制作图区域或是改变窗口外型。关于如何创建和使用多边形在2.6 
          多边形和剪贴区域中会详细讲解。</p>
        <p class="unnamed1">在Windows中使用GUI对象必须遵守一定的规则。首先需要创建一个合法的对象,不同的对象创建方法不同。然后需要将该GUI对象选入DC中,同时保存DC中原来的GUI对象。<font 
            color=red>如果选入一个非法的对象将会引起异常</font>。在使用完后应该恢复原来的对象,这一点特别重要,<font 
            color=red>如果保存一个临时对象在DC中,而在临时对象被销毁后可能引起异常。</font>有一点必须注意,<font 
            color=red>每一个对象在重新创建前必须销毁</font>,下面的代码演示了这一种安全的使用方法: 
        <pre class="unnamed1">OnDraw(CDC* pDC)
{
	CPen pen1,pen2;
	pen1.CreatePen(PS_SOLID,2,RGB(128,128,128));//创建对象
	pen2.CreatePen(PS_SOLID,2,RGB(128,128,0));//创建对象
	CPen* pPenOld=(CPen*)pDC-&gt;SelectObject(&amp;pen1);//选择对象进DC
	drawWithPen1...
	(CPen*)pDC-&gt;SelectObject(&amp;pen2);//选择对象进DC
	drawWithPen2...
	pen1.DeleteObject();//再次创建前先销毁
	pen1.CreatePen(PS_SOLID,2,RGB(0,0,0));//再次创建对象
	(CPen*)pDC-&gt;SelectObject(&amp;pen1);//选择对象进DC
	drawWithPen1...
	pDC-&gt;SelectObject(pOldPen);//恢复
}
</pre>
        <p></p>
        <p class="unnamed1">此外系统中还拥有一些库存GUI对象,你可以利用CDC::SelectStockObject(SelectStockObject( 
          int nIndex )选入这些对象,它们包括一些固定颜色的刷子,画笔和一些基本字体。 
        <ul>
          <li class="unnamed1"><b>BLACK_BRUSH</b>&nbsp;&nbsp;&nbsp;Black brush.<br>
            <br>
          <li class="unnamed1"><b>DKGRAY_BRUSH</b>&nbsp;&nbsp;&nbsp;Dark gray 
            brush.<br>
            <br>
          <li class="unnamed1"><b>GRAY_BRUSH</b>&nbsp;&nbsp;&nbsp;Gray brush.<br>
            <br>
          <li class="unnamed1"><b>HOLLOW_BRUSH</b>&nbsp;&nbsp;&nbsp;Hollow brush.<br>
            <br>
          <li class="unnamed1"><b>LTGRAY_BRUSH</b>&nbsp;&nbsp;&nbsp;Light gray 
            brush.<br>
            <br>
          <li class="unnamed1"><b>NULL_BRUSH</b>&nbsp;&nbsp;&nbsp;Null brush.<br>
            <br>
          <li class="unnamed1"><b>WHITE_BRUSH</b>&nbsp;&nbsp;&nbsp;White brush.<br>
            <br>
          <li class="unnamed1"><b>BLACK_PEN</b>&nbsp;&nbsp;&nbsp;Black pen.<br>
            <br>
          <li class="unnamed1"><b>NULL_PEN</b>&nbsp;&nbsp;&nbsp;Null pen.<br>
            <br>
          <li class="unnamed1"><b>WHITE_PEN</b>&nbsp;&nbsp;&nbsp;White pen.<br>
            <br>
          <li class="unnamed1"><b>ANSI_FIXED_FONT</b>&nbsp;&nbsp;&nbsp;ANSI fixed 
            system font.<br>
            <br>
          <li class="unnamed1"><b>ANSI_VAR_FONT</b>&nbsp;&nbsp;&nbsp;ANSI variable 
            system font.<br>
            <br>
          <li class="unnamed1"><b>DEVICE_DEFAULT_FONT</b>&nbsp;&nbsp;&nbsp;Device-dependent 
            font.<br>
            <br>
          <li class="unnamed1"><b>OEM_FIXED_FONT</b>&nbsp;&nbsp;&nbsp;OEM-dependent 
            fixed font.<br>
            <br>
          <li class="unnamed1"><b>SYSTEM_FONT</b>&nbsp;&nbsp;&nbsp;The system 
            font. By default, Windows uses the system font to draw menus, dialog-box 
            controls, and other text. In Windows versions 3.0 and later, the system 
            font is proportional width; earlier versions of Windows use a fixed-width 
            system font.<br>
            <br>
          <li class="unnamed1"><b>SYSTEM_FIXED_FONT</b>&nbsp;&nbsp;&nbsp;The fixed-width 
            system font used in Windows prior to version 3.0. This object is available 
            for compatibility with earlier versions of Windows.<br>
            <br>
          <li class="unnamed1"><b>DEFAULT_PALETTE</b>&nbsp;&nbsp;&nbsp;Default 
            color palette. This palette consists of the 20 static colors in the 
            system palette. </li>
        </ul>
        <span class="unnamed1">这些对象留在DC中是安全的,所以你可以利用选入库存对象来作为恢复DC中GUI对象。 </span> 
        <p></p>
        <p class="unnamed1">大家可能都注意到了绘图时都需要一个DC对象,DC(Device Context设备环境)对象是一个抽象的作图环境,可能是对应屏幕,也可能是对应打印机或其它。这个环境是设备无关的,所以你在对不同的设备输出时只需要使用不同的设备环境就行了,而作图方式可以完全不变。这也就是Windows耀眼的一点设备无关性。如同你将对一幅画使用照相机或复印机将会产生不同的输出,而不需要对画进行任何调整。DC的使用会穿插在本章中进行介绍。</p>
            <div align="left"> </div>
         
      </td>
    </tr>
    </tbody> 
  </table>
</div>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>

⌨️ 快捷键说明

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