2024年2月21日发(作者:)

'移动背景透明图片

Public Declare Function BitBlt Lib "gdi32" _

(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

dwRop As Long) As Long

'目标环境DC,x,y,width,height

'源x,y;操作方法

Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

Const SRCPAINT = &HEE0086 ' (DWORD) dest = source OR dest

Const SRCAND = &H8800C6 ' (DWORD) dest = source AND dest

Const SRCINVERT = &H660046 ' (DWORD) dest = source XOR dest

Const SRCERASE = &H440328 ' (DWORD) dest = source AND (NOT dest )

Const NOTSRCCOPY = &H330008 ' (DWORD) dest = (NOT source)

Const NOTSRCERASE = &H1100A6 ' (DWORD) dest = (NOT src) AND (NOT

dest) Const DSTINVERT = &H550009 ' (DWORD) dest = (NOT dest)

Const MERGEPAINT = &HBB0226

'===================================================================== ========================

'===================================================================== =======================

Public Function TransparentImageMove(ByVal Screen_Pic As PictureBox,

ByVal Front_Pic As PictureBox, ByVal Mask_Pic As PictureBox, ByVal

BackGround_Pic As PictureBox, ByVal X As Single, ByVal Y As Single) As

Long

'Screen_Pic 最终显示屏幕

'BackGround_Pic 背景图片缓存

'Front_Pic 显示彩图缓存

'Mask_Pic 掩模缓存

'(X,Y)坐标

Dim Rst As Long

Dim PicWd As Single, PicHt As Single '图片尺寸

Dim SWD As Single, SHT As Single '屏幕尺寸

Screen_draw = True: BackGround_draw = True

Front_draw = True: Mask_draw = True

Screen_e = True

Front_e = False

Mask_e = False

BackGround_e = False

SWD = Screen_idth: SHT = Screen_eight

PicWd = Front_idth: PicHt = Front_eight

'背景恢复

Screen_e = BackGround_e

'掩模

Rst = BitBlt(Screen_, X, Y, PicWd, PicHt, Mask_, 0, 0,

MERGEPAINT) '彩图

Rst = BitBlt(Screen_, X, Y, PicWd, PicHt, Front_, 0,

0, SRCAND)

'显示

'Screen_e = Screen_

End Function

'在指定(X,Y) 做Width,Height的透明图片

Public Function TransparentImage(ByVal ScreenPicBox As PictureBox,

ByVal ImagePicBox As PictureBox, ByVal MaskPicbox As PictureBox, ByVal X

As Single, ByVal Y As Single, ByVal WidFactor As Single, ByVal HgtFactor

As Single) As Boolean

Dim PWidth As Single, PHeight As Single

'这里可以选择是否清除图片

'

'设置基本输出属性

draw = True: ze = True:

ode = 3

draw = True: ze = True:

ode = 3

draw = True: ze = True:

ode = 3

'设置宽度

PWidth = * WidFactor

PHeight = * HgtFactor

'开始画透明图

icture e, X, Y, PWidth, PHeight,

0, 0, (), (), (&HBB0226)

icture e, X, Y, PWidth,

PHeight, 0, 0, (), (), (&H8800C6)

End Function