一个关于MSDN中CButton:DrawItem()函数中的有关问题
一个关于MSDN中CButton::DrawItem()函数中的问题
在MSDN中Cbutton::DrawItem()函数中有如下代码:
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);
其中,if (lpDrawItemStruct->itemState & ODS_SELECTED)
uStyle |= DFCS_PUSHED;
的意思是 uStyle的状态设为DFCS_PUSHED和DFCS_BUTTONPUSH么??
DFCS_PUSHED和DFCS_BUTTONPUSH分别是什么状态详细说一下??一共两个问题谢谢了
------解决方案--------------------
DFCS_BUTTONPUSH表示要绘的是一个PUSH BUTTON
DFCS_PUSHED表示要绘这个按钮的按下状态
在MSDN中Cbutton::DrawItem()函数中有如下代码:
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);
其中,if (lpDrawItemStruct->itemState & ODS_SELECTED)
uStyle |= DFCS_PUSHED;
的意思是 uStyle的状态设为DFCS_PUSHED和DFCS_BUTTONPUSH么??
DFCS_PUSHED和DFCS_BUTTONPUSH分别是什么状态详细说一下??一共两个问题谢谢了
------解决方案--------------------
DFCS_BUTTONPUSH表示要绘的是一个PUSH BUTTON
DFCS_PUSHED表示要绘这个按钮的按下状态