求救!急!
//////////////////////////////////////////////////////////
我想做一个漂亮的按钮,就是把图片贴在上面
/////////////////////////////////////////////////////////
有谁知道绘制Button::DrawItem()的源代码吗?
能告诉我一下,有代码的话,贴上更好!谢谢!
问题点数:0、回复次数:3Top
1 楼krh2001(边城浪子)回复于 2005-06-04 18:12:53 得分 0
MSDN 里就有
Example
// 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);
}
Top
2 楼yangzhi_family(lante)回复于 2005-06-04 18:44:02 得分 0
我想问一下,我写了一个按钮类,调试时候我在DrawItem设置了断点,为什么程序进不了断点?Top
3 楼ayanamiwww(咩~咩『抵制日货』)回复于 2005-06-04 21:14:56 得分 0
www.vckbase.com上面好像就有现成的代码,
CXPButton,CMyButton好像,自己找一下,很多的Top




