rt

解决方案 »

  1.   

    何谓动态显示?将位置保存在CBitmap中,在OnPaint中显示?弄个Timer,InvaliateRect(rect,FALSE);?应该使用双缓冲。
      

  2.   

    动态的意思是说根据得到图像的路径,在对话框中显示多幅图像,能不能不再对话框中先放picture框呀
      

  3.   

    随便怎么都行,显示在static中,或者直接在dialog上显示都行// This OnDraw() handler loads a bitmap from system resources, centers
    // it in the view, and uses BitBlt to paint the bitmap bits.void CBlat2View::OnDraw(CDC* pDC)
    {
      CBlat2Doc* pDoc = GetDocument();
      ASSERT_VALID(pDoc);  // Load IDB_BITMAP1 from the resources.
      CBitmap bmp;
      if (bmp.LoadBitmap(IDB_BITMAP1))
      {
        // Get the size of the bitmap.
        BITMAP bmpInfo;
        bmp.GetBitmap(&bmpInfo);    // Create an in-memory device context compatible with the
        // display device context that is used to paint.
        CDC dcMemory;
        dcMemory.CreateCompatibleDC(pDC);    // Select the bitmap into the in-memory device context.
        CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);    // Find a center point for the bitmap in the client area.
        CRect rect;
        GetClientRect(&rect);
        int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
        int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;    // Copy the bits from the in-memory device context to the on-
        // screen device context to do the painting. Use the computed center
        // point for the target offset.
        pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
          0, 0, SRCCOPY);    dcMemory.SelectObject(pOldBitmap);
      }
      else
        TRACE0("ERROR: Where is IDB_BITMAP1?\n");
    }
      

  4.   

    先谢谢,试试先,我先得到比如说十幅图象的路径,然后在循环里把这十幅图像显示在对话框上,我的程序是基于对话框的,放在OnPaint()里面也应该可以的吧
      

  5.   

    小三的就行.或者:CBitmap m_bmp;
    if( m_bmp.m_hObject != NULL )
    m_bmp.DeleteObject();

    HBITMAP hbmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), 
    "这里为文件的路径", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);

    if( hbmp == NULL ) 
    return ;

    m_bmp.Attach( hbmp );
    CDC *dc=GetDC(); CDC memdc;
    memdc.CreateCompatibleDC(dc); CBitmap* pOldBitmap =memdc.SelectObject( &m_bmp );
    CWnd::DefWindowProc(WM_PAINT, (WPARAM)memdc.m_hDC , 0);

    dc->BitBlt(rcclient.left, rcclient.top, rcclient.Width(), rcclient.Height(), 
                &memdc, 0, 0,SRCCOPY);
    memdc.SelectObject(pOldBitmap); ReleaseDC(dc);
      

  6.   

    按两位说的我试了一下,还可以,不过在对话框的onpaint()函数里做的,需要拖动一下对话框才可以显示出来,是不是没有刷新的缘故?