This code works on Windows7X32:
There are two PictureBoxes on the form
In Windows7 res = 1 the image is copied normally, in Windows10X64 res = 0 and there is no image.
If the image is assigned to Picture2 in the IDE, copying is fine. But I need to upload and copy a lot of images.
I can't figure out what the problem might be.
There are two PictureBoxes on the form
Code:
Option Explicit
Private Declare Function TransparentBlt Lib "msimg32.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()
Form1.ScaleMode = 3
Picture1.ScaleMode = 3
Picture1.Picture = LoadPicture(App.Path & "\0001.jpg")
Picture2.ScaleMode = 3
Picture2.BackColor = vbGreen
Picture2.AutoRedraw = True
Picture2.Visible = False
Picture2.ScaleHeight = 180
Picture2.ScaleWidth = 160
End Sub
Private Sub Form_Activate()
Form1.Picture2.Picture = LoadPicture(App.Path & "\0000.gif")
Dim res As Long
Picture1.Cls
DoEvents
res = TransparentBlt(Picture1.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, _
Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, vbGreen)
MsgBox res
End Sub
If the image is assigned to Picture2 in the IDE, copying is fine. But I need to upload and copy a lot of images.
I can't figure out what the problem might be.