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

📄 05o011.htm

📁 VC知识库5_chm_decompile_20040520_210715
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="../../vckbase.css">
</head>

<body>

<div align="justify">
  <table border="0" width="100%" class="font" height="57">
    <tr>
      <td width="27%" height="6" class="bigfont" bgcolor="#B8CFE7" align="center" bordercolor="#800080">
      <font color="#800080">VC知识库(五)</font>
      </td>
      <td width="73%" height="6" class="bigfont" bgcolor="#B8CFE7" align="center" bordercolor="#800080">
      <font color="#800080">www.vckbase.com</font>
      </td>
    </tr>
    <tr>
      <td width="100%" height="4" class="header" valign="top" align="center" colspan="2">
      <hr>
      </td>
    </tr>
    <tr>
      <td width="100%" height="17" class="header" valign="top" align="center" colspan="2">
<small>
<big>在同一系统中显示GB字符和BIG5字符</big></small>
      </td>
    </tr>
    <tr>
      <td width="100%" height="17" class="info" align="center" colspan="2">
      <small>闻怡洋 EMail: wyy_cq@188.net homepage: <a href="http://vchelp.zb169.net">http://vchelp.zb169.net</a></small> 
      </td>   
    </tr>   
    <tr>  
      <td width="100%" height="22" class="font" colspan="2"> 
        <hr> 
      </td>   
    </tr>  
    <tr>  
      <td width="100%" height="5" class="font" colspan="2">  
<p> 
<font size="3">
当前由于大陆和港台采用不同的内码,因此产生了两种常用的内码GB/BIG5。以前的软件都是利用内建的字库来完成两种内码的显示,而在这里我提供一种简便的方法用于在Windows程序中显示不同内码的文字。</font></p>
<p>
<font size="3">
大家可能都注意到IE,MS Office97等软件都可以根据不同内码使用不同的字体显示而不需要平台支持。他们利用的都是MS所提供的语言开发包进行开发,下面介绍这种方法:</font></p> 
<p> 
<font size="3">
首先你需要安装MS提供的GB和BIG5字体,(可在<a href="http://www.microsoft.com">MS站点</a>免费下载)。</font></p>
<p>
<font size="3">
然后需要修改你的显示代码,对于不同的模式装入不同的字体。这种技术的核心就是指定不同的字符集和字体名称,示范代码如下:<br>
</font>
<pre><font size="3">
//下面的代码将装入BIG5字体并显示
CFont font;
LOGFONT lf; //LOGFONT结构中的变量用于定义字体的各种特性
memset(&amp;lf,0,sizeof(lf));
lf.lfCharSet = CHINESEBIG5_CHARSET; //设置字符集
lf.lfHeight = 20;
strcpy(lf.lfFaceName,&quot;MingLiu&quot;); //设置字体名称 MingLiu为MS提供的BIG5字体
font.CreateFontIndirect(&amp;lf); //创建字体
CFont* pF = (CFont*)dc.SelectObject(&amp;font); //保存当前字体
dc.TextOut(0,0,_T(&quot;what you want to display&quot;));
dc.SelectObject(pF); //恢复以前的字体
</font></pre>
      <font size="3">
但是系统中安装的字体我们是不知道的,因此我们应该找出我们所需要的字体是否已经安装。Windows中的EnumFontFamiliesEx可以帮助我们。该函数的说明如下:<br>
      </font>
<pre><font size="3">
int EnumFontFamiliesEx(HDC hdc,LPLOGFONT lpLogfont,
                       FONTENUMPROC lpEnumFontFamExProc,
                       LPARAM lParam,DWORD dwFlags);
在调用该功能时需要在lpLogfont中设置相应的值,下面的代码表示列出所有BIG5字体。
HWND hW=::GetFocus();
HDC hdc=::GetDC(hW);
LOGFONT lf;
memset(&amp;lf,0,sizeof(lf));
lf.lfCharset = CHINESEBIG5_CHARSET; //如果该值为DEFAULT_CHARSET将会列出所有字体
lf.lfFaceName = &quot;&quot;;
lf.lfPitchAndFamily = 0;
EmunFontFamiliesEx(hdc,&amp;lf,myEnumFontFamExProc,0,0);
同时你还需要定义一个回调函数,在每找到一种字体时该函数都将被调用。函数原型如下:
int CALLBACK myEnumFontFamExProc(ENUMLOGFONTEX *lpelfe,NEWTEXTMETRICEX *lpntme,int FontType,LPARAM lParam)
{
	TRACE(&quot;font family name\n&quot;,lpelfe-&gt;elfLogFont.lfFaceName);
	//将该字体LOGFONT或是FaceName保存到自己的数据中
}</font></pre>
      </td>    
    </tr>   
    <tr>
      <td width="100%" height="12" class="font" colspan="2"> 
      </td>    
    </tr>
    <tr>
      <td width="100%" height="6" class="font" colspan="2"> 
      </td>    
    </tr>
    <tr>
      <td width="100%" height="8" class="font" colspan="2"> 
      </td>    
    </tr>
    <tr>   
      <td width="100%" height="17" class="font" colspan="2"></td>    
    </tr>   
  </table>    
</div>    
    
</body>    
    
</html>    

⌨️ 快捷键说明

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