| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2853 人关注过本帖
标题:CButton类中的DrawItem()函数实现什么功能呀??
只看楼主 加入收藏
yel_bit
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2009-8-29
收藏
 问题点数:0 回复次数:1 
CButton类中的DrawItem()函数实现什么功能呀??
RT,刚学vc++6,看不明白什么意思,求助一下高手!
搜索更多相关主题的帖子: 函数 DrawItem CButton 
2009-09-15 16:22
沼泽
Rank: 4
等 级:业余侠客
威 望:8
帖 子:291
专家分:228
注 册:2008-9-15
收藏
得分:0 
CButton::DrawItem
Called by the framework when a visual aspect of an owner-drawn button has changed.
 
 当Button具有自绘风格(BS_OWNERDRAW )后,在button样式改变的时候,这个函数就会被调用。通常用来制作个性化的Button

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);
}


[ 本帖最后由 沼泽 于 2009-9-16 09:45 编辑 ]
2009-09-16 09:40
快速回复:CButton类中的DrawItem()函数实现什么功能呀??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013361 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved