Ik ben bezig met een applicatie in VB6 (omdat het makkelijk is te distribueren met 1 dll) om mensen 4 scores te laten behalen in 4 categorieen. Deze scores worden vervolgens op een circel met drie ringen voor 15-10-5 punten getoond m.b.v. stippen. Tussen deze stippen worden lijnen getrokken. Er wordt dus een polygon van gemaakt.
Nu is mijn vraag, kan ik een polygon transparant maken t.o.v. de achtergrond van een picturebox.
VB6 en graphics....bah!
Nu heb ik de volgende code...
Nu is mijn vraag, kan ik een polygon transparant maken t.o.v. de achtergrond van een picturebox.
VB6 en graphics....bah!
Nu heb ik de volgende code...
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| Public Type COORD
x As Long
y As Long
End Type
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" Alias "Polygon" (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
Const ALTERNATE = 1
Const WINDING = 2
Const BLACKBRUSH = 4
Public Function DrawPolygon(picBox As PictureBox, poly() As COORD)
Dim NumCoords As Long, hBrush As Long, hRgn As Long
NumCoords = UBound(poly)
' Polygon function creates unfilled polygon on screen.
' Remark FillRgn statement to see results.
polygon picBox.hdc, poly(1), NumCoords
' Gets stock black brush.
hBrush = GetStockObject(BLACKBRUSH)
' Creates region to fill with color.
hRgn = CreatePolygonRgn(poly(1), NumCoords, ALTERNATE)
picBox.FillColor = vbYellow
' If the creation of the region was successful then color.
If hRgn Then FillRgn picBox.hdc, hRgn, hBrush
DeleteObject hRgn
End Function |
[ Voor 3% gewijzigd door kevinv2u op 03-10-2007 14:58 ]