我将文本中的字体设置成粗体后,英文字符都能正确显示成粗体,
为什么汉字却没有变化。

解决方案 »

  1.   

    //下面代码没问题CHARFORMAT cf;
    GetDefaultCharFormat(cf);//得到默认字体格式
    cf.dwMask |= CFM_BOLD;
    cf.dwEffects |= CFE_BOLD;
    SetSel(0, -1);//选择所有文本
    SetSelectionCharFormat(cf); //设为粗体---------
      ++C++
    ---------
      

  2.   

    有了我这玩艺儿,你什么字体都能设!
    详情请看:
    Here:
    /*************************************************
      Function : void SetWordsFont(CRichEditCtrl *richEdit, 
    LPCTSTR sWord1, COLORREF clr1, 
    LPCTSTR sWord2, COLORREF clr2, 
    LPCTSTR sWord3, COLORREF clr3, 
    LPCTSTR sWord4, CFontDialog *fontDialog)
      Class : 无
      Description : 对聊天室发送消息内容,按用户定制输出到屏幕上
      Input : 9个参数
      Output : 无
      Return : 无
      Re : 只要调用SetWordsFont()这一个函数就行了,你只要把SetMsg(),Message()
       添加到你的cpp文件里就行了!所以你不必管SetMsg()和Message()!
       例如一个典型的例子:
       张三 哭着 对所有人 说: 你明天有空吗?
       某人 表情 某人 动作 内容
      
      Author : liuYou
      Date : 2003-12-18 17:35
    *************************************************/
    void SetWordsFont(CRichEditCtrl *richEdit, 
    LPCTSTR sWord1, COLORREF clr1,  //某人
    LPCTSTR sWord2, COLORREF clr2,  //表情
    LPCTSTR sWord3, COLORREF clr3,  //某人
    LPCTSTR sWord4, COLORREF clr4,  //动作
    LPCTSTR sWord5, CFontDialog *fontDialog)//内容
    {
    Message(richEdit, sWord1, clr1); //张三
    Message(richEdit, sWord2, clr2); //哭着
    Message(richEdit, sWord3, clr3); //对所有人
    Message(richEdit, sWord4, clr4); //说:
    SendMsg(richEdit, sWord5, fontDialog->GetColor(), fontDialog);//你明天有空吗?
    }void SendMsg(CRichEditCtrl *richEdit,
    LPCTSTR sWord, COLORREF clr, 
    CFontDialog *fontDialog = NULL)
    {
    CHARFORMAT cf;

    cf.cbSize = sizeof(CHARFORMAT);
    cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_COLOR;
      if (cf.dwEffects & CFE_AUTOCOLOR) cf.dwEffects -= CFE_AUTOCOLOR;
    cf.crTextColor = clr;
    // Get a color from the common color dialog.
    if(fontDialog != NULL)
    {
    memcpy(cf.szFaceName, (fontDialog->GetFaceName()), 20);
    cf.yHeight = fontDialog->GetSize();
    cf.crTextColor = fontDialog->GetColor();
    /*
    这里你可以设置更多的字体样式
    */
    }
    richEdit->SetSelectionCharFormat(cf);
    richEdit->ReplaceSel(sWord);
    }void Message(CRichEditCtrl *rich, LPCTSTR lpszMessage, COLORREF clr)
    {
    CHARFORMAT cf;
    cf.cbSize = sizeof(CHARFORMAT);
    cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
      if (cf.dwEffects & CFE_AUTOCOLOR) cf.dwEffects -= CFE_AUTOCOLOR;
    // Get a color from the common color dialog.
    cf.crTextColor = clr;
    cf.dwMask = CFM_COLOR;
    rich->SetSelectionCharFormat(cf);
    rich->ReplaceSel(lpszMessage);
     }
      

  3.   

    发的太丑了,样式不好看!
    再来一次,用FontPage做了一次!
    Here:<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>New Page 1</title>
    </head><body><p><br>
    <br>
    /*************************************************<br>
      Function :&nbsp;&nbsp;&nbsp;&nbsp; void SetWordsFont(CRichEditCtrl *richEdit,&nbsp;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord1, COLORREF clr1,&nbsp;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord2, COLORREF clr2,&nbsp;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord3, COLORREF clr3,&nbsp;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord4, CFontDialog *fontDialog)<br> 
      Class :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 无<br>
      Description :&nbsp;&nbsp; 对聊天室发送消息内容,按用户定制输出到屏幕上<br>
      Input :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9个参数<br>
      Output :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 无<br>
      Return :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 无<br>
      Re :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 只要调用SetWordsFont()这一个函数就行了,你只要把SetMsg(),Message()<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    添加到你的cpp文件里就行了!所以你不必管SetMsg()和Message()!<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    例如一个典型的例子:<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    张三 哭着 对所有人 说:&nbsp;&nbsp;&nbsp;&nbsp; 你明天有空吗?<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    某人 表情 某人&nbsp;&nbsp;&nbsp;&nbsp; 动作&nbsp;&nbsp;&nbsp; 内容<br>
    <br>
      Author :&nbsp;&nbsp;&nbsp;&nbsp; liuYou<br>
      Date :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2003-12-18 17:35<br> 
    *************************************************/<br>
    void SetWordsFont(CRichEditCtrl *richEdit,&nbsp;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord1, COLORREF clr1,  //某人<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord2, COLORREF clr2,  //表情<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord3, COLORREF clr3,  //某人<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord4, COLORREF clr4,  //动作<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord5, CFontDialog *fontDialog)//内容<br> 
    {<br>
    &nbsp;&nbsp;&nbsp; Message(richEdit, sWord1, clr1); //张三<br> 
    &nbsp;&nbsp;&nbsp; Message(richEdit, sWord2, clr2); //哭着<br> 
    &nbsp;&nbsp;&nbsp; Message(richEdit, sWord3, clr3); //对所有人<br> 
    &nbsp;&nbsp;&nbsp; Message(richEdit, sWord4, clr4); //说:<br> 
    &nbsp;&nbsp;&nbsp; SendMsg(richEdit, sWord5, fontDialog->GetColor(), fontDialog);//你明天有空吗?<br> 
    }<br>
    <br>
    void SendMsg(CRichEditCtrl *richEdit,<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    LPCTSTR sWord, COLORREF clr,&nbsp;<br>
    CFontDialog *fontDialog = NULL)<br> 
    {<br>
    &nbsp;&nbsp;&nbsp; CHARFORMAT cf;&nbsp;<br>
    <br>
    &nbsp;&nbsp;&nbsp; cf.cbSize = sizeof(CHARFORMAT);<br> 
    &nbsp;&nbsp;&nbsp; cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_COLOR;<br> 
    &nbsp;&nbsp;&nbsp; if (cf.dwEffects &amp; CFE_AUTOCOLOR) cf.dwEffects -= CFE_AUTOCOLOR;<br> 
    &nbsp;&nbsp;&nbsp; cf.crTextColor = clr;<br> 
    &nbsp;&nbsp;&nbsp; // Get a color from the common color dialog.<br> 
    &nbsp;&nbsp;&nbsp; if(fontDialog != NULL)<br> 
    &nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memcpy(cf.szFaceName, (fontDialog->GetFaceName()), 20);<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cf.yHeight = fontDialog->GetSize();<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cf.crTextColor = fontDialog->GetColor();<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*&nbsp;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这里你可以设置更多的字体样式<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; richEdit->SetSelectionCharFormat(cf);<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; richEdit->ReplaceSel(sWord);<br>
    }<br>
    <br>
    void Message(CRichEditCtrl *rich, LPCTSTR lpszMessage, COLORREF clr)<br> 
    {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CHARFORMAT cf;<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cf.cbSize = sizeof(CHARFORMAT);<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (cf.dwEffects &amp; CFE_AUTOCOLOR) cf.dwEffects -= CFE_AUTOCOLOR;<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get a color from the common color dialog.&nbsp;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cf.crTextColor = clr;<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cf.dwMask = CFM_COLOR;<br> 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rich->SetSelectionCharFormat(cf);<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rich->ReplaceSel(lpszMessage);<br>
    <br>
    <br>
    }</p></body></html>
      

  4.   

    太丑了,不行了!
    不玩了Sleep(10e999999999999999999);