如题,让一个按钮变成红色或者绿色 最好有代码
解决方案 »
- 我在主对话框设置了一个定时器,怎么在子对话框中启动这个定时器?
- 本人对CSDN的一点建议,希望大家能支持一下!
- 静态分割窗口时,为什么每次都只是分在左上角!?急!!!在线等!
- CString的Format
- 8位位图的颜色表
- 关于windows目录权限,有谁知道这个函数怎么写吗
- 奇怪我的sqlserver2000 的服务器上的 sqlservr.exe 为什么占用内存从开机时候的16m过了1天左右涨到了300m
- 你好,请问有没有人会做QQ界面设计以及全部完成该聊天软件的呢?这样的人有吗?
- 谁能提供一两个下载图标的好站点???
- 我想问一下,你们在什么情况下,才真正需要自己写回调函数?
- a.exe中的0x0074b8cc处有求经处理的异常:0xc0000005
- 如何将客户区分成9块??????????
{
RECT m_rect;
m_button3.GetClientRect(&m_rect); static bool b = false;
CBrush bru(RGB(255,0,0));
CPaintDC *dc;
dc=(CPaintDC*)m_button3.GetDC();
CString str;
GetDlgItemText(IDC_BUTTON1,str);
dc->SetBkMode(TRANSPARENT); if(b==false)
{
dc->FillRect(&m_rect,&bru);
dc->DrawText(str,&m_rect,DT_CENTER | DT_SINGLELINE | DT_VCENTER );
b=true;
return;
}
}
// 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);
}