//.h 추가
CDC m_dcBg;
CBitmap m_bmpBg;
CBitmap *m_oldbmpBg;
//.cpp 추가
//생성자 추가
m_dcBg.m_hDC = NULL;
//소멸자 추가
DeleteObject(m_dcBg.SelectObject(&m_oldbmpBg));
DeleteDC(m_dcBg);
// CSliderCtrl 이벤트함수에 보면 NM_CUSTOMDRAW 메세지가 있다.
void ClassName::OnNMCustomdrawSlider1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMCUSTOMDRAW lpcd = (LPNMCUSTOMDRAW)pNMHDR;
CDC *pDC = CDC::FromHandle(lpcd->hdc);
switch(lpcd->dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
if (lpcd->dwItemSpec == TBCD_THUMB)
{
*pResult = CDRF_DODEFAULT;
break;
}
if (lpcd->dwItemSpec == TBCD_CHANNEL)
{
CClientDC clientDC(GetParent());
CRect crect;
CRect wrect;
GetClientRect(crect);
GetWindowRect(wrect);
GetParent()->ScreenToClient(wrect);
if (m_dcBg.m_hDC == NULL)
{
m_dcBg.CreateCompatibleDC(&clientDC);
m_bmpBg.CreateCompatibleBitmap(&clientDC, crect.Width(),
crect.Height());
m_oldbmpBg = m_dcBg.SelectObject(&m_bmpBg);
m_dcBg.BitBlt(0, 0, crect.Width(), crect.Height(), &clientDC,
wrect.left, wrect.top, SRCCOPY);
}
int iWidth = crect.Width();
int iHeight = crect.Height();
BitBlt(lpcd->hdc, 0, 0, iWidth, iHeight, m_dcBg.m_hDC, 0, 0, SRCCOPY);
*pResult = 0;
break;
}
}
}
'프로그래머의 길 > C & C++' 카테고리의 다른 글
CTime Format (0) | 2011.08.10 |
---|---|
슬라이더 컨트롤 버튼 2개 샘플 (0) | 2011.02.17 |
리스트 컨트롤 / 콤보 박스 글씨 색 바꾸기 (0) | 2010.07.07 |
윈도우 종료 (2) | 2010.01.06 |
CStringT::Tokenize. (0) | 2009.12.02 |