Monday, 4 March 2013

OnButton1() method.


·  The last step is to add code to the void CColourChangerDlg::OnButton1() method. In
this code, we construct and destruct a new device context (pDC) to draw to and declare
a new object of the CBrush class to paint the colours defined in the RGB macro and
determined by the n_red, n_green and n_blue variables declared earlier. Again add the
code in bold.
void CColourChangerDlg::OnButton1()
{
CClientDC* pDC = new CClientDC(this);
CBrush backBrush;
if(backBrush.CreateSolidBrush(RGB(n_red,n_green,n_blue)))
{
CBrush* pOlderBrush = pDC->SelectObject (&backBrush);
pDC-> Ellipse(50,70, 140,130);
pDC-> SelectObject(pOlderBrush);
}
delete pDC;
// TODO: Add your control notification handler code here
}

No comments:

Post a Comment