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

求救!急!

楼主yangzhi_family(lante)2005-06-04 18:04:06 在 VC/MFC / 基础类 提问

//////////////////////////////////////////////////////////  
  我想做一个漂亮的按钮,就是把图片贴在上面  
  /////////////////////////////////////////////////////////  
  有谁知道绘制Button::DrawItem()的源代码吗?  
  能告诉我一下,有代码的话,贴上更好!谢谢! 问题点数:0、回复次数:3Top

1 楼krh2001(边城浪子)回复于 2005-06-04 18:12:53 得分 0

MSDN   里就有  
  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

2 楼yangzhi_family(lante)回复于 2005-06-04 18:44:02 得分 0

我想问一下,我写了一个按钮类,调试时候我在DrawItem设置了断点,为什么程序进不了断点?Top

3 楼ayanamiwww(咩~咩『抵制日货』)回复于 2005-06-04 21:14:56 得分 0

www.vckbase.com上面好像就有现成的代码,  
  CXPButton,CMyButton好像,自己找一下,很多的Top

相关问题

  • 急!!!!
  • 急!!!!!!!!!
  • 急~~~
  • 急........................................
  • 急!!!!!!!!!!!!!!!!!!!!!!!!
  • 急!!!
  • ==========急============
  • 急
  • 急!!!
  • 急

关键词

  • cmybutton
  • lpdrawitemstruct
  • ustyle
  • dfc
  • drawitem
  • button
  • draw

得分解答快速导航

  • 帖主:yangzhi_family

相关链接

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

广告也精彩

反馈

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