CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

请教:关于Dialog中SetFont()的用法,HELP……

楼主hangsome(沧浪)2004-12-02 21:39:52 在 VC/MFC / 基础类 提问

vc建立的MFC单文档项目,想通过SetFont()来改变Dialog中的字体。  
   
  先看看代码:  
  CFont   font;//成员变量,即在.h文件中声明  
   
  在OnInitDialog()中填加如下代码:  
  CDialog::OnInitDialog();  
  ……  
  font.CreateFont(30,0,0,0,FW_NORMAL,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH   |   FF_SWISS,"宋体");  
  this->SetFont();  
  ……  
  return   TRUE;  
   
  对话框显示出来的时候,Dialog上Static控件,Button控件,……   一点变化都没有。  
   
  是不是我使用SetFont()的方法有问题?还是不应该在OnInitDialog()中设置字体?  
   
  小弟苦思不得其解,特来求教。  
   
  请帮忙,谢谢!  
  问题点数:0、回复次数:5Top

1 楼Semigod()回复于 2004-12-02 22:54:42 得分 0

SetFont(&font);Top

2 楼leky2000(懒客)回复于 2004-12-02 23:00:17 得分 0

是啊,没有参数怎么set啊另外你为什么不在对话框资源文件中直接改为你的font?Top

3 楼vcleaner(我没当大哥很久了.......)回复于 2004-12-03 08:20:46 得分 0

参考:  
  修改属性页字体  
  http://support.microsoft.com/default.aspx?scid=kb;en-us;142170Top

4 楼jiangsheng(蒋晟.Net[MVP])回复于 2004-12-03 08:34:03 得分 0

http://community.csdn.net/Expert/TopicView.asp?id=3601128Top

5 楼chwk(学习ing)回复于 2004-12-03 08:45:24 得分 0

可以查看MSDN  
  Called   by   the   framework   when   a   visual   aspect   of   an   owner-drawn   button   has   changed.  
   
  virtual   void   DrawItem(  
        LPDRAWITEMSTRUCT   lpDrawItemStruct    
  );  
   
  Example  
  //   NOTE:   CMyButton   is   a   class   derived   from   CButton.   The   CMyButton  
  //   object   was   created   as   follows:  
  //  
  //   CMyButton   myButton;  
  //   myButton.Create(_T("My   button"),    
  //             WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW,    
  //             CRect(10,10,100,30),   pParentWnd,   1);  
  //  
   
  //   This   example   implements   the   DrawItem   method   for   a   CButton-derived    
  //   class   that   draws   the   button's   text   using   the   color   red.  
  void   CMyButton::DrawItem(LPDRAWITEMSTRUCT   lpDrawItemStruct)    
  {  
        UINT   uStyle   =   DFCS_BUTTONPUSH;  
   
        //   This   code   only   works   with   buttons.  
        ASSERT(lpDrawItemStruct->CtlType   ==   ODT_BUTTON);  
   
        //   If   drawing   selected,   add   the   pushed   style   to   DrawFrameControl.  
        if   (lpDrawItemStruct->itemState   &   ODS_SELECTED)  
              uStyle   |=   DFCS_PUSHED;  
   
        //   Draw   the   button   frame.  
        ::DrawFrameControl(lpDrawItemStruct->hDC,   &lpDrawItemStruct->rcItem,    
              DFC_BUTTON,   uStyle);  
   
        //   Get   the   button's   text.  
        CString   strText;  
        GetWindowText(strText);  
   
        //   Draw   the   button   text   using   the   text   color   red.  
        COLORREF   crOldColor   =   ::SetTextColor(lpDrawItemStruct->hDC,   RGB(255,0,0));  
        ::DrawText(lpDrawItemStruct->hDC,   strText,   strText.GetLength(),    
              &lpDrawItemStruct->rcItem,   DT_SINGLELINE|DT_VCENTER|DT_CENTER);  
        ::SetTextColor(lpDrawItemStruct->hDC,   crOldColor);  
  }  
   
  Top

相关问题

  • @Dialog的用法
  • HELP!! SqlAdapter.Fill 的用法
  • 请教html help workshop 的用法
  • 谁能告诉我dialog的具体用法啊
  • &*用法~~
  • help?谁知道Tab Control 控件的用法,12分的感谢!!!!
  • help?谁知道Tab Control 控件的用法,12分的感谢!!!!
  • setfocus的用法
  • icmp.dll的用法
  • Recordset的用法。

关键词

  • 字体
  • setfont
  • cmybutton
  • lpdrawitemstruct
  • dialog
  • drawitem
  • oninitdialog
  • default
  • buttons
  • font

得分解答快速导航

  • 帖主:hangsome

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo