I am trying to change the color of the dialog box to white. As there are no standard properties available, I am trying to use draw a rectagle of the size equal to its client area. Below are the 2 ways I employed in vain.
Method I :
BOOL CMyWndDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RECT rect;
this->GetClientRect(&rect);
CPaintDC mydc(this);
CDC memdc;
CBitmap *oldbitmap = NULL, newbitmap;
memdc.CreateCompatibleDC(&mydc);
newbitmap.CreateCompatibleBitmap(&mydc, rect.right, rect.bottom);
oldbitmap = memdc.SelectObject(&newbitmap);
memdc.FillSolidRect(0,0,rect.right, rect.bottom, RGB(0, 255, 255) );
mydc.BitBlt(0,0,rect.right, rect.bottom, &memdc , 0, 0, SRCCOPY);
memdc.SelectObject(oldbitmap);
return TRUE;
}
Method II:
BOOL CMyWndDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RECT rect;
this->GetClientRect(&rect);
CClientDC mydc(this);
CPen *oldPen, newPen;
CBrush *oldBrush, newBrush;
newPen.CreatePen(PS_SOLID, 1, RGB(255, 255, 255));
newBrush.CreateSolidBrush(RGB(2555, 255, 255));
oldPen = mydc.SelectObject(&newPen);
oldBrush = mydc.SelectObject(&newBrush);
mydc.Rectangle(rect.left, rect.top, rect.right, rect.top);
mydc.SelectObject(oldPen);
mydc.SelectObject(oldBrush);
return TRUE;
}
Can anyone help what is wrong in the above code. Is there any alternative method.
Thanks in advance.
rcs1
Method I :
BOOL CMyWndDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RECT rect;
this->GetClientRect(&rect);
CPaintDC mydc(this);
CDC memdc;
CBitmap *oldbitmap = NULL, newbitmap;
memdc.CreateCompatibleDC(&mydc);
newbitmap.CreateCompatibleBitmap(&mydc, rect.right, rect.bottom);
oldbitmap = memdc.SelectObject(&newbitmap);
memdc.FillSolidRect(0,0,rect.right, rect.bottom, RGB(0, 255, 255) );
mydc.BitBlt(0,0,rect.right, rect.bottom, &memdc , 0, 0, SRCCOPY);
memdc.SelectObject(oldbitmap);
return TRUE;
}
Method II:
BOOL CMyWndDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RECT rect;
this->GetClientRect(&rect);
CClientDC mydc(this);
CPen *oldPen, newPen;
CBrush *oldBrush, newBrush;
newPen.CreatePen(PS_SOLID, 1, RGB(255, 255, 255));
newBrush.CreateSolidBrush(RGB(2555, 255, 255));
oldPen = mydc.SelectObject(&newPen);
oldBrush = mydc.SelectObject(&newBrush);
mydc.Rectangle(rect.left, rect.top, rect.right, rect.top);
mydc.SelectObject(oldPen);
mydc.SelectObject(oldBrush);
return TRUE;
}
Can anyone help what is wrong in the above code. Is there any alternative method.
Thanks in advance.
rcs1