各位兄弟,我要在背景图上面另外透明显示另外一张小图?该如何是好?
1.背景图是一张大图,用picturebox装载,
2.小图是用pictureclip装载,取其中的clip(1);
3.然后在背景图上显示,我弄了好久,就是没有显示出来,大家帮帮忙Private Sub Form_paint()
    Dim Pic2 As Picture
    Dim hOldBmp1 As Long, hOldBmp2 As Long
    Dim hdcSrc As Long
    Dim BITMAP As Long
    Dim hdcDes As Long    Picture1.ScaleMode = vbPixels
    Set Pic2 = PictureClip2.GraphicCell(1)
    
    hdcDes = GetDC(Picture1.hwnd)
    hdcSrc = CreateCompatibleDC(hdcDes)
    BITMAP = SelectObject(hdcSrc, Pic1)
    Call TransparentBlt(hdcDes, 100, 100, 50, 50, hdcSrc, 0, 0, 50, 50, RGB(0, 0, &H0))
    hOldBmp2 = SelectObject(hdcSrc, BITMAP)
    
End Sub

解决方案 »

  1.   

    给个透明图片显示的函数给你吧:Public Type rBlendProps
        tBlendOp As Byte
        tBlendOptions As Byte
        tBlendAmount As Byte
        tAlphaType As Byte
    End TypePrivate Declare Function AlphaBlend Lib "msimg32" (ByVal hDestDC As Long, _
            ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
            ByVal nHeight As Long, ByVal hSrcDC As Long, _
            ByVal xSrc As Long, ByVal ySrc As Long, ByVal widthSrc As Long, _
            ByVal heightSrc As Long, ByVal blendFunct As Long) As BooleanPrivate Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
            (Destination As Any, Source As Any, ByVal Length As Long)Public Sub ShowTransparency(cSrc As PictureBox, cDest As PictureBox, _
        ByVal nLevel As Byte)
        Dim LrProps As rBlendProps
        Dim LnBlendPtr As Long
        Dim w As Long, h As Long
        On Error GoTo errr
        cDest.Cls
        LrProps.tBlendAmount = nLevel
        CopyMemory LnBlendPtr, LrProps, 4
        With cSrc
            w = .ScaleWidth / Screen.TwipsPerPixelX
            h = .ScaleHeight / Screen.TwipsPerPixelY
            AlphaBlend cDest.hDC, 0, 0, w, h, .hDC, 0, 0, w, h, LnBlendPtr
        End With
        cDest.Refresh
    errr:
    End Sub
      

  2.   

    老大,我的不是两个picturebox哦,是一个picclip,怎么办
      

  3.   

    没用过picclip,为什么不用PictureBox+Image控件呢?Image中的图片为Gif格式就可以了。
      

  4.   

    直接使用API函数把两个图片合成后显示在PictureBox中不可以吗?
      

  5.   

    啊哈,对了,如果要绘的小图可以使用PNG,那就可以用GDI+函数去绘,嘿嘿.这里有个例子:使用GDI+显示PNG图象,以及显示PNG图象时大小不正常的解决方案(VB6.0代码)