一个窗体,1个PictureBoxDim cc1 As POINTAPI
Public hmemdc_Picture, hBitmap_Picture, oldbitmap_Picture As Long
Public m_nWidth, m_nHeight As Long在窗体Load的时候
Private Sub Form_Load()
    '  获得PictureBox尺寸
    m_nWidth = Me.Picture1.ScaleWidth
    m_nHeight = Me.Picture1.ScaleHeight    '  创建与Pictrue1.hdc关联的内存位图
    hmemdc_Picture = CreateCompatibleDC(Me.Picture1.hdc)
    hBitmap_Picture = CreateCompatibleBitmap(Me.Picture1.hdc, m_nWidth, m_nHeight)    '  在内存位图里面画线
    hPen = CreatePen(0, 1, 255)
    pOldPen = SelectObject(hmemdc_Picture, hPen)
    Call MoveToEx(hmemdc_Picture, 0, 0, cc1)
    Call LineTo(hmemdc_Picture, 10000, 10000)
    longflag = SelectObject(hmemdc_Picture, pOldPen)
    longflag = DeleteObject(hPen)
End SubPrivate Sub Form_Paint()
     '  贴图
     BitBlt(Me.Picture1.hdc, 0, 0, m_nWidth, m_nHeight, hmemdc_Picture, 0, 0, &HCC0020)
End Sub
但是,却没有画出线,不知道哪里有问题

解决方案 »

  1.   

    画线之前加了这句,线出来了,
    oldbitmap_Picture = SelectObject(hmemdc_Picture, hBitmap_Picture)
      

  2.   

    接着问,窗口再加一个PictureBox,载入一副图,
    我想将它贴到内存位图里面,怎么做呢,我是这样做的,但是,图片却是窗口产生时的背景而不是载入的图。
    Me.Picture2.Picture = LoadPicture("D:\\LeveL\\bmp\\地图.bmp")
    longflag = BitBlt(hmemdc_Picture, 0, 0, m_nWidth, m_nHeight, Me.Picture2.hdc, 0, 0, &HCC0020)
      

  3.   

    靠,将Picture1.AutoRedraw属性设置为True
    后再贴图就可以了。