题目有点长,有好的实现方法嘛?

解决方案 »

  1.   

    楼主是什么意思?是你显示 1.BMP 时,它并没有显示?而要等到你控制显示 2.BMP 时,才显示 1.BMP 的图片内容?那是不是你在控制显示 1.BMP 时,没有刷新显示图片的区域啊?不然,不会看不到图片内容的 啊
      

  2.   

    声明变量如下: float fWidth,fHeight;
    /* CBitmap bitmapPoint,bitmapLine,bitmapCaver,bitmapNavi;
    BITMAP bmpPoi,bmpLine,bmpCaver,bmpNavi;
    CDC dcPoi,dcLine,dcCaver,dcNavi;
    CDC *pDCPoi,*pDCLine,*pDCCaver,*pDCNavi;
    CRect rectPoi,rectLine,rectCaver,rectNavi;*/ CBitmap bitmap[9],bitmapTop,bitmapBot,bitmapIcon;
    BITMAP bmp[9],bmpTop,bmpBot,bmpIcon;
    CDC dc[9],dcTop,dcBot,dcIcon;
    CDC *pDC[9],*pDCTop,*pDCBot,*pDCIcon;
    CRect rect[9],rectTop,rectBot,rectIcon;显示代码如下:    float BmpX=100,BmpY=40,BmpScale=7; bitmap[1].LoadBitmap(IDB_BITMAP1);      
    bitmap[1].GetBitmap(&bmp[1]);
          //CDC P=GetDC()
    pDC[1] = GetDC();// dc[1].CreateCompatibleDC(pDC[1]);
    dc[1].SelectObject(&bitmap[1]);
    GetClientRect(&rect[1]); pDC[1]->SetStretchBltMode(HALFTONE);
    pDC[1]->StretchBlt(BmpX+fWidth,BmpY,rect[1].Width()/BmpScale,rect[1].Height()/BmpScale,&dc[1],0,0,bmp[1].bmWidth,bmp[1].bmHeight,SRCCOPY);   
    ReleaseDC(pDC[1]);
      

  3.   

    1.BMP 有显示,但是我想显示2.BMP 时,1.BMP不显示,即及时刷新
    代码如下:
    图片显示void CTestDlg::OnPaint()
    {
          //CDC *pdc;
          float fWidth=0,fHeight=0;
    float BmpX=100,BmpY=40,BmpScale=7;
    CBitmap bitmap[9],bitmapTop,bitmapBot,bitmapIcon;
    BITMAP bmp[9],bmpTop,bmpBot,bmpIcon;
    CDC dc[9],dcTop,dcBot,dcIcon;
    CDC *pDC[9],*pDCTop,*pDCBot,*pDCIcon;
    CRect rect[9],rectTop,rectBot,rectIcon;
           if(t)
    {
    bitmap[1].LoadBitmap(IDB_BITMAP1);      
    bitmap[1].GetBitmap(&bmp[1]);
          //CDC P=GetDC()
    pDC[1] = GetDC();// dc[1].CreateCompatibleDC(pDC[1]);
    dc[1].SelectObject(&bitmap[1]);
    GetClientRect(&rect[1]); pDC[1]->SetStretchBltMode(HALFTONE);
    pDC[1]->StretchBlt(BmpX+fWidth,BmpY,rect[1].Width()/BmpScale,rect[1].Height()/BmpScale,&dc[1],0,0,bmp[1].bmWidth,bmp[1].bmHeight,SRCCOPY);   
    ReleaseDC(pDC[1]);
    }
           else if(f)
    bitmap[2].LoadBitmap(IDB_BITMAP2);      
    bitmap[2].GetBitmap(&bmp[2]);
          //CDC P=GetDC()
    pDC[2] = GetDC();// dc[2].CreateCompatibleDC(pDC[2]);
    dc[2].SelectObject(&bitmap[2]);
    GetClientRect(&rect[2]); pDC[2]->SetStretchBltMode(HALFTONE);
    pDC[2]->StretchBlt(BmpX+fWidth,BmpY,rect[2].Width()/BmpScale,rect[2].Height()/BmpScale,&dc[2],0,0,bmp[2].bmWidth,bmp[2].bmHeight,SRCCOPY);   
    ReleaseDC(pDC[2]);      point p;
         // point::point(0);
    //      p.Draw();
    if (IsIconic())
    {
    CPaintDC dc(this); // 用于绘制的设备上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // 使图标在工作矩形中居中
    int cxIcon = GetSystemMetrics(SM_CXICON);
    int cyIcon = GetSystemMetrics(SM_CYICON);
    CRect rect;
    GetClientRect(&rect);
    int x = (rect.Width() - cxIcon + 1) / 2;
    int y = (rect.Height() - cyIcon + 1) / 2; // 绘制图标
    dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
    CDialog::OnPaint();
    }
    }图片切换控制void CGVisitDlg::OnBnClickedButup()
    {
    // TODO: Add your control notification handler code here
          int iBtn;
          if(t) //切换线
          {
            f;
         }
          else if(f)
         {
             t;
          }
          CGVisitDlg::OnPaint();
    }