region for TransparentColor(mask color)
this code make a mask color in picture box.Code:Private Function MakeRegion(picSkin As PictureBox) As Long Dim x As Long, y As Long, StartLineX As Long Dim FullRegion As Long, LineRegion As Long Dim TransparentColor As Long Dim InFirstRegion As Boolean Dim InLine As Boolean Dim hdc As Long Dim PicWidth As Long Dim PicHeight As Long hdc = picSkin.hdc PicWidth = picSkin.ScaleWidth PicHeight = picSkin.ScaleHeight InFirstRegion = True: InLine = False x = y = StartLineX = 0 TransparentColor = 14215660 For y = 0 To PicHeight - 1 For x = 0 To PicWidth - 1 If GetPixel(hdc, x, y) = TransparentColor Or x = PicWidth Then If InLine Then InLine = False LineRegion = CreateRectRgn(StartLineX, y, x, y + 1) If InFirstRegion Then FullRegion = LineRegion InFirstRegion = False Else CombineRgn FullRegion, FullRegion, LineRegion, RGN_OR DeleteObject LineRegion End If End If Else If Not InLine Then InLine = True StartLineX = x End If End If Next Next MakeRegion = FullRegion End Function Private Sub setrgn(picmainskin As PictureBox) Dim WindowRegion As Long WindowRegion = MakeRegion(picmainskin) SetWindowRgn picmainskin.hwnd, WindowRegion, True End Sub
I want to delete a region




Reply With Quote