I have a problem in Visual C++ 6.0.
I made a project using Dialog Based, not Single Document Type.
I want to make a rectangle that its color able to change when I clicked a button.
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this); // device context for painting
[color = blue]
// Background Rectangle
dc.Rectangle(10,10,208,92);
CRect RectBackground(10,10,208,92);
It produce a black rectangle when I added red = green = blue = 0;
in class::OnInitDialog() fuction.
I think, when I add a button n change "red", "green", and "blue" values, the color of rectangle will change. But it doesn't work.
Code in my button function are:
void CGambarDlg::OnButton1()
{
red = green = blue = 255;
OnPaint();
}