继承自CWnd的子类,重写OnPaint方法,用一个单选框去控制其重画,我的想法是,当单击选中后,画出界面。当不选中后,则不画出来。现在的情况是选中后可以画出,但是不选中单选按钮,我调用了Invalidate并没有让我的界面的内容消失。void CPointLineSpan::OnPaint()
{
//不选中单选按钮......
if (m_IsEnabled == FALSE)
{
return;
}
//选中单选按钮...
画出我的界面;
}
这样子并不能实现我想要的效果,选中出来,不选中消失的结果
{
//不选中单选按钮......
if (m_IsEnabled == FALSE)
{
return;
}
//选中单选按钮...
画出我的界面;
}
这样子并不能实现我想要的效果,选中出来,不选中消失的结果
// 类似这样就可以了,测试代码
BOOL bDraw = FALSE;void CXXDlg::OnPaint()
{
CPaintDC dc(this); if(bDraw)
{
CString str(_T("Hello, World!"));
dc.DrawText(str, CRect(0, 0, 100, 100), DT_CENTER);
}
}void CXXDlg::OnButton1()
{
// TODO: Add your control notification handler code here
bDraw = TRUE;
Invalidate();
}void CXXDlg::OnButton2()
{
// TODO: Add your control notification handler code here
bDraw = FALSE;
Invalidate();
}