MFC菜单设置

1.打开菜单界面:
这里写图片描述

2.设置点击的处理程序:
这里写图片描述

3.编辑代码:

注意这里不要写画图的代码什么的,这里控制改变某个变量,让OnDraw函数取处理不同的情况!以下是我生成随机线段的代码,这个可以自己根据情况写代码。
最后一行通知画图函数是必须的。

void CTestView::OnCreateLine()
{
    //Debug
    //lines.push_back(Line(Point(500, 200), Point(100, 400)));

    int n = 10;
    srand(unsigned(time(NULL)));
    for (int i = 0; i < n; i++)
    {
        double x = rand() % WindowWidth+1;
        double y = rand() % WindowHeight+1;
        Point a = Point(x, y);

        x = rand() % WindowWidth + 1;
        y = rand() % WindowHeight + 1;
        Point b = Point(x, y);

        lines.push_back(Line(a, b));
    }
    SendMessage(WM_PAINT);      //通知画图
}

猜你喜欢

转载自blog.csdn.net/wyg1997/article/details/78470729