我在对话框上画了 一个按纽.
双击它,它就放大,再双击就还原.然后,我想在这个按纽上画点东西,比如线条啊,背景啊.
就是要把按纽的背景色改掉,再画上一个波形图.
这个背景怎么改呢?

解决方案 »

  1.   

    http://www.vckbase.com/document/viewdoc/?id=551
      

  2.   

    // 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);
    }
    这是MSDN中的代码,很简单,应该明白吧?
      

  3.   

    m_up.SetIcon(AfxGetApp()->LoadIcon(IDI_ICON3));
    m_up是按钮,IDI_ICON3就是在资源里加的图标~~~