andreww
03-08-2002, 03:04 AM
i want to know how to change my region from black to a different colour
heres the code:
Private Type COORD
x As Long
y As Long
End Type
Dim mouses As COORD
Dim inside
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Any, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As Any, ByVal nCount As Long) As Long
Private Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
Const ALTERNATE = 2
Const WINDING = 4
Const BLACKBRUSH = 4
Dim poly(1 To 3) As COORD, NumCoords As Long, hBrush As Long, hRgn As Long
Private Sub Command1_Click()
NumCoords = 3
Me.ScaleMode = vbPixels
poly(1).x = 100
poly(1).y = 100
poly(2).x = Form1.ScaleWidth / 4 + 100
poly(2).y = 3 * Form1.ScaleHeight / 4 + 100
poly(3).x = 3 * Form1.ScaleWidth / 4 + 100
poly(3).y = 3 * Form1.ScaleHeight / 4 + 100
Polygon Me.hdc, poly(1), NumCoords
hBrush = GetStockObject(BLACKBRUSH)
hRgn = CreatePolygonRgn(poly(1), NumCoords, ALTERNATE)
If hRgn Then FillRgn Me.hdc, hRgn, hBrush
If PtInRegion(hRgn, 1, 1) <> 0 Then Me.Caption = "Inside"
DeleteObject hRgn
End Sub
heres the code:
Private Type COORD
x As Long
y As Long
End Type
Dim mouses As COORD
Dim inside
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Any, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As Any, ByVal nCount As Long) As Long
Private Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long
Const ALTERNATE = 2
Const WINDING = 4
Const BLACKBRUSH = 4
Dim poly(1 To 3) As COORD, NumCoords As Long, hBrush As Long, hRgn As Long
Private Sub Command1_Click()
NumCoords = 3
Me.ScaleMode = vbPixels
poly(1).x = 100
poly(1).y = 100
poly(2).x = Form1.ScaleWidth / 4 + 100
poly(2).y = 3 * Form1.ScaleHeight / 4 + 100
poly(3).x = 3 * Form1.ScaleWidth / 4 + 100
poly(3).y = 3 * Form1.ScaleHeight / 4 + 100
Polygon Me.hdc, poly(1), NumCoords
hBrush = GetStockObject(BLACKBRUSH)
hRgn = CreatePolygonRgn(poly(1), NumCoords, ALTERNATE)
If hRgn Then FillRgn Me.hdc, hRgn, hBrush
If PtInRegion(hRgn, 1, 1) <> 0 Then Me.Caption = "Inside"
DeleteObject hRgn
End Sub