Private Declare Function TransparentBlt Lib "msimg32" _ (ByVal hdcDest As Long, _ ByVal nXOriginDest As Long, _ ByVal nYOriginDest As Long, _ ByVal nWidthDest As Long, _ ByVal nHeightDest As Long, _ ByVal hdcSrc As Long, _ ByVal nXOriginSrc As Long, _ ByVal nYOriginSrc As Long, _ ByVal nWidthSrc As Long, _ ByVal nHeightSrc As Long, _ ByVal crTransparent As Long) _ As Long
Private Declare Function GetPixel Lib "gdi32" _ (ByVal hdc As Long, _ ByVal x As Long, _ ByVal y As Long) _ As Long
Private Function MakeTransparentRegion(pbSource As PictureBox, _ pbDestination As PictureBox) Dim lTransColor As Long
lTransColor = GetPixel(pbSource.hdc, 0, 0)
Call TransparentBlt(pbDestination.hdc, 0, 0, pbSource.ScaleWidth, _ pbSource.ScaleHeight, _ pbSource.hdc, 0, 0, _ pbSource.ScaleWidth, _ pbSource.ScaleHeight, _ lTransColor) Picture2.Refresh End Function
Private Sub Command1_Click() MakeTransparentRegion Picture1, Picture2 End Sub
Private Sub Command2_Click() Unload Me End Sub
Private Sub Command3_Click() Picture2.Cls End Sub
Private Sub Form_Load() Command1.Caption = "Start" Command2.Caption = "Exit" Command3.Caption = "Clear"
With Picture1 .AutoRedraw = True .ScaleMode = 3 With Picture2 .AutoRedraw = True .ScaleMode = 3 .Width = Picture1.Width .Height = Picture1.Height End With End With End Sub |