怎么改变RADIO的颜色??

huanghf 2003-01-05 10:50:38
我把单选按钮改为Push-like的形式。
我想在在选择与不选择中改变它的颜色,应该怎么写它的代码呀?
多谢了各位大侠。
...全文
178 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoniu111 2003-01-05
  • 打赏
  • 举报
回复
我给你画
wangweicai 2003-01-05
  • 打赏
  • 举报
回复
如果自己用API开发的话,WM_CTLCOLORBTN消息
wangweicai 2003-01-05
  • 打赏
  • 举报
回复
WM_CTLCOLOR消息
omale 2003-01-05
  • 打赏
  • 举报
回复
自己画。
tigerfox 2003-01-05
  • 打赏
  • 举报
回复
只能自己实现自画

www.codeproject.com/button
zhdleo 2003-01-05
  • 打赏
  • 举报
回复
你可以试下这个:DrawItem()
因为它是CButton::DrawItem ,
你的RADIO也是继承CButton类的,
你重载下DrawItem()。

下面是MSDN上的关于DrawItem的例子。
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);
}


jishiping 2003-01-05
  • 打赏
  • 举报
回复
必须使按钮为自画式的,才可以改变颜色。既然是自画式的,按钮就需要程序画了。
wyljery 2003-01-05
  • 打赏
  • 举报
回复
onctlcolor事件处理看看
Rigel 2003-01-05
  • 打赏
  • 举报
回复
派生自己的类

2,586

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧