之前关于EVC下图形编程画二维曲线问题已经有了进展,现在刚画出简单的二维曲线,就是随机折线那样的,主要通过两个随机数nRandomX = rand() % 10;nRandomY = rand() % 10;
主要代码如下:
BOOL CDraw2DGraphDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
CRect rect;
rect.left = 10;
rect.top = 10;
rect.right = 220;
rect.bottom = 160;
//创建曲线控件实例
m_2DGraph.Create(_T(""),_T(""),WS_VISIBLE|WS_CHILD,rect,this,0,NULL);
m_pointCount = 0;
//启动添加点计时器
SetTimer(1,400,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
//定时给曲线添加点
void CDraw2DGraphDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
int nRandomY, nRandomX;
//产生一个1~10的随机数
nRandomX = rand() % 10;
nRandomY = rand() % 10;
//如果曲线点数大于10个点,则删除第一个点
if(m_pointCount > 10)
{
m_2DGraph.DeleteFirstPoint();
m_pointCount--;
}
//给曲线添加点
m_2DGraph.AppendPoint(nRandomX, nRandomY);
m_pointCount++;
CDialog::OnTimer(nIDEvent);
}
可我的目标是画滚动正弦曲线,不知道应该用什么函数怎么画,知道正弦是sin,但怎么用完全不了解,请大家帮忙想想喔,给我思路和一些代码,不胜感激感谢!(*^__^*)