VB 6。0 API
GdiTransparentBlt函数调用方面的问题
我的目的是想调用一下函数,把图片框中1中的图片画到窗体1中,很简单的,请大家看看哪里出了问题....
Private Declare Function GdiTransparentBlt Lib "gdi32" (ByVal hdc1 As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal W1 As Long, ByVal H1 As Long, ByVal Hdc2 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal W2 As Long, ByVal H2 As Long, ByVal Color As Long) As Long '声明
Private Sub Command1_Click()
Main.Cls
n = GdiTransparentBlt(Form1.hDC, 0, 0, Form1.Picture1.Width, Form1.Picture1.Height, Form1.Picture.hDC, 0, 0, Form1.Picture1.Width, Form1.Picture1.Height, RGB(255, 255, 255)) '在窗口中画上图片框中的图片
End Sub
结果窗体中没有任何反应,请大家帮帮忙吧,谢谢大家了

解决方案 »

  1.   


    'Example Name:GdiTransparentBlt
    'This project needs 2 pictureboxes
    'Picturebox1 must contain a picture with a lot of white pixels (we're going to use white as transparent color)
    Private Declare Function GdiTransparentBlt Lib "gdi32.dll" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
    Private Sub Form_Load()
        'KPD-Team 2001
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Picture1.AutoSize = True
        'API uses pixels
        Picture1.ScaleMode = vbPixels
        Picture2.ScaleMode = vbPixels
    End Sub
    Private Sub Picture2_Paint()
        'If we don't call DoEvents first, our transparent image will be completely wrong
        DoEvents
        GdiTransparentBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbWhite
    End Sub
      

  2.   

    你form1的autoredraw要设为ture才行.