Thanks Eugen.
Now one new issue came into picture. When i am changing Dialogbar background, then i am able to see rectangular edges of button which of grey in color.
Though we have made round edged button but rectangular edge is still there whcih you can see when you change background color of form
here is the piece of code fof changing background color:
BOOL CButtonDialogBar::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(&rect);
int r1=19,g1=40,b1=85;
int r2=60,g2=88,b2=156;
for(int i=0;i<rect.Height();i++)
{
int r,g,b;
r = r1 + (i * (r2-r1) / rect.Height());
g = g1 + (i * (g2-g1) / rect.Height());
b = b1 + (i * (b2-b1) / rect.Height());
pDC->FillSolidRect(0,i,rect.Width(),1,RGB(r,g,b));
}
return true;
}
And add this code for CMyButton:
void CRoundColoredButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC dc;
RECT rect;
dc.Attach(lpDrawItemStruct ->hDC);
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
pDC->RoundRect(0,
0,
lpDrawItemStruct->rcItem.right,
lpDrawItemStruct->rcItem.bottom,
50,
50);
CRgn cRgn1;
cRgn1.CreateRoundRectRgn(0,
0,
lpDrawItemStruct->rcItem.right,
lpDrawItemStruct->rcItem.bottom,
50,
50);
pDC->SelectClipRgn(&cRgn1);
pDC->FillSolidRect(&lpDrawItemStruct->rcItem, RGB(255, 255, 255));
CRgn cRgn2;
cRgn2.CreateRoundRectRgn(3,
3,
lpDrawItemStruct->rcItem.right-3,
lpDrawItemStruct->rcItem.bottom-3,
50,
50);
pDC->SelectClipRgn(&cRgn2);
int r2=19,g2=40,b2=85;
int r1=60,g1=88,b1=156;
rect = lpDrawItemStruct->rcItem;
for(int i=0;i<rect.bottom;i++)
{
int r,g,b;
r = r1 + (i * (r2-r1) / rect.bottom);
g = g1 + (i * (g2-g1) / rect.bottom);
b = b1 + (i * (b2-b1) / rect.bottom);
dc.FillSolidRect(0,i,rect.right,1,RGB(r,g,b));
}
CString strText;
GetWindowText(strText);
int iOldMode = pDC->SetBkMode(TRANSPARENT);
COLORREF crOldColor = pDC->SetTextColor(RGB(255,255,255));
if (lpDrawItemStruct->itemState & ODS_SELECTED) {
lpDrawItemStruct->rcItem.top += 2;
lpDrawItemStruct->rcItem.left += 2;
}
pDC->DrawText(strText, &lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
pDC->SetTextColor(crOldColor);
pDC->SetBkMode(iOldMode);
pDC->SelectClipRgn(NULL);
}
Apply above code, you will come to know what i am talking about,
How to make rounded edge button completely by cutting rectangular edge of button?