读书人

怎么输出半径可以由按钮改变得圆环?

发布时间: 2012-01-18 00:23:26 作者: rapoo

如何输出半径可以由按钮改变得圆环???
我在OnPaint中写了个画圆的程序,在ONButton中响应画圆得程序,并实现了半径得增加,调试时已经可以看见画出半径变化的圆了,但一运行就不响应了,对话框上什么都没有。
那位高人知道什么原因么??给个解救办法吧。

[解决办法]
void CExDlg::OnButton1()
{
r += 10;
Invalidate();
}

void CExDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// 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

dc.Ellipse(200-r, 200-r, 300+r, 300+r);

CDialog::OnPaint();
}
}

[解决办法]
void CTest1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
i=i+20;
Invalidate();
}

读书人网 >VC/MFC

热点推荐