如何改变按钮的颜色? 我想改变按钮的颜色!不知道如何做?请大侠帮忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以在按钮上边放图片。或者设置按钮的Owner Draw属性。然后:void COwnerDrawDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { char btnText[16]; HBRUSH hBrush ; GetDlgItemText(lpDrawItemStruct->CtlID,btnText,16); hBrush=CreateSolidBrush(RGB(213,192,228)); hBrush=(HBRUSH) SelectObject (lpDrawItemStruct->hDC,hBrush); SetBkColor(lpDrawItemStruct->hDC,RGB(213,192,228)); SetTextColor(lpDrawItemStruct->hDC,RGB(0,0,255)); Rectangle(lpDrawItemStruct->hDC,lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.right,lpDrawItemStruct->rcItem.bottom); DrawText(lpDrawItemStruct->hDC,btnText,-1,&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_CENTER|DT_VCENTER); DeleteObject(SelectObject(lpDrawItemStruct->hDC,hBrush)); if (lpDrawItemStruct->itemState & ODS_SELECTED) InvertRect (lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem);} 唯一的办法,从CButton派生一个,自己画. 方法有两种:1:自己画2:处理WM_CTLCOLOR 求助,怎样在MFC中使用Lua中的print函数? 大家进来帮帮啊~~~真的不知道哪错了。。都一天了 如何在多个视图之间传递参数 关于LoadLibrary和GetProcAddress的问题 请教,如何动态创建多个CheckBox 线程同步怎么样解决? 在VC里#include<graphics.h>说没这么文件 在Console Application建立的工程文件使用winsocket2的外部调用错误? 请问是否有GBK(或Unicode)转UTF8的例子?(GOOGLE了一天没找到可用的) 进行DMA时如何保证Cache和内存内容的一致性? 奇怪的问题!!有关打印的简单问题 高分求助
然后:void COwnerDrawDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
char btnText[16];
HBRUSH hBrush ;
GetDlgItemText(lpDrawItemStruct->CtlID,btnText,16);
hBrush=CreateSolidBrush(RGB(213,192,228));
hBrush=(HBRUSH) SelectObject (lpDrawItemStruct->hDC,hBrush);
SetBkColor(lpDrawItemStruct->hDC,RGB(213,192,228));
SetTextColor(lpDrawItemStruct->hDC,RGB(0,0,255));
Rectangle(lpDrawItemStruct->hDC,lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.right,lpDrawItemStruct->rcItem.bottom); DrawText(lpDrawItemStruct->hDC,btnText,-1,&lpDrawItemStruct->rcItem,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
DeleteObject(SelectObject(lpDrawItemStruct->hDC,hBrush));
if (lpDrawItemStruct->itemState & ODS_SELECTED)
InvertRect (lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem);
}
1:自己画
2:处理WM_CTLCOLOR