要做一个小球滚动,碰壁,折回反复进行的程序,
请教大侠,如何使一幅位图移动?

解决方案 »

  1.   

    如果你是用是mfc的话,那就是不停的改变显示的位置就可以了。
      

  2.   

    BitBlt(
       int x,
       int y,
       int nWidth,
       int nHeight,
       CDC* pSrcDC,
       int xSrc,
       int ySrc,
       DWORD dwRop 
    );
    Parameters

    Specifies the logical x-coordinate of the upper-left corner of the destination rectangle. 

    Specifies the logical y-coordinate of the upper-left corner of the destination rectangle. 
    nWidth 
    Specifies the width (in logical units) of the destination rectangle and source bitmap. 
    nHeight 
    Specifies the height (in logical units) of the destination rectangle and source bitmap. 
    pSrcDC 
    Pointer to a CDC object that identifies the device context from which the bitmap will be copied. It must be NULL if dwRop specifies a raster operation that does not include a source. 
    xSrc 
    Specifies the logical x-coordinate of the upper-left corner of the source bitmap. 
    ySrc 
    Specifies the logical y-coordinate of the upper-left corner of the source bitmap. 
    dwRop 
    Specifies the raster operation to be performed. Raster-operation codes define how the GDI combines colors in output operations that involve a current brush, a possible source bitmap, and a destination bitmap. See BitBlt in the Platform SDK for a list of the raster-operation codes for dwRop and their descriptions
      

  3.   

    我教你一种方法,你先把图象显示在内存dc中,然后把内存dc映射到你的当前dc中,因为映射的位置,你可以给出,也就是说你的小球可以动,
      

  4.   

    CreateCompatibleDC建立内存环境,把图片BitBlt进去,然后按需要从内存中读图片到你指定的位置,,,
      

  5.   

    re:没听说过有内存DC这样东西,不过倒可以用一个缓冲位图代替(用TBitmap object)
      

  6.   

    先声明视图类变量CDC* vDC,memDC;vDC = CView/*你的视图类*/->GetDC;
    memDC = CreateCompatibleDC(vDC);
    memDC->BitBlt(.........);//查一下MSDN,找参数,我忘了,把图片放入内存环境
    ReleaseDC()//别忘了当你需要移动时
    pDC->BitBlt(....x,y,...memDC...);改变x,y等一些的值就可以了,从内存环境拷贝图片到设备环境