p;dcCompatible = CreateCompatibleDC(Picture1.hdc)
bm = CreateCompatibleBitmap(Picture1.hdc, Picture1.Width \ 15, _
Picture1.Height \ 15)
pBitmapOld = SelectObject(dcCompatible, bm)
rectTemp.Left = 0: rectTemp.Top = 0
rectTemp.Right = Picture1.Width \ 15: rectTemp.Bottom = _
Picture1.Height \ 15
tLog.lbColor = gColor
tLog.lbStyle = BS_SOLID
tLog.lbHatch = 0
lBrush = CreateBrushIndirect(tLog)
FillRect dcCompatible, rectTemp, lBrush
BitBlt Picture1.hdc, 0, 0, Picture1.Width \ 15, _
Picture1.Height \ 15, dcCompatible, 0, 0, SRCAND
SelectObject dcCompatible, pBitmapOld
BitBlt Picture1.hdc, 0, 0, Picture1.Width \ 15, _
Picture1.Height \ 15, Picture2.hdc, 0, 0, SRCPAINT
DeleteDC dcCompatible
End Sub
运行
程序,点击Command1,你就可以看到Picture2上的图象叠加到了Picture1上面了。改变上面
源
程序中的 Const gColor = &HFFFFFF 一句中的gColor的值(在0到&HFFFFFFFF间变动),就可以
使图象的叠加产生不同的透明效果。
以上
程序在Win98、VB6.0下运行通过。