如题,是在View中用Create创建的一个按扭
解决方案 »
- 用MFC可以做USB驱动吗?
- StaticText内类似LED站牌的文字滚动? 求方法
- 树型数据如何保存,并在网络中传送
- vc6的ide有没有办法设置的与vs05一样好用啊?例外有没有什么常用插件,能够提升开发速度?
- 用什么方法改 输入法顺序?改完之后不用重起就能直接看效果?(通过程序实现)~~~我找不到方法啊!)
- vc中打印JPG图片的问题?
- run time error出现的原因
- 初学者问题,望高手指点!UP有分!
- %%%%%%%%% VC必看,很简单的一个问题!!!
- mfc程序,在程序中如何处理才能使其安装后能自启动?
- 求源码: 现求VC的进销存源码, 或者数据库表也行, 越简单越好
- 庆祝升5角,散分!
或者在VIEW类中,响应WM_CTLCOLOR消息,设置BUTTON的背景颜色。
// 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);
}