如何在MFC中随机在一个区域中画点啊?我想这样去实现喷枪效果。

解决方案 »

  1.   

    建一个Timer事件处理函数
    里面写上
            CClientDC dc(this);
    CPoint randompoint;
    for (int i=1;i<=80;i++)  //此处80是喷的快慢  自己调
    {
    randompoint.x = rpoint.x+(50-rand()%100);
    randompoint.y = rpoint.y+(50-rand()%100);
    dc.SetPixel(randompoint,RGB(255,255,255));//这是1楼说的矩形喷枪 圆形的改下算法就 行了 自己写吧
    }然后在mousemove事件中加入
    rpoint = point;LButtonDown里
    SetTimer(1,100,NULL);LButtonUp
    KillTimer(1);