Ticket #275: GDIPlus_GraphicsFillPolygon.au3

File GDIPlus_GraphicsFillPolygon.au3, 1.6 KB (added by smashly, on May 13, 2008 at 3:22:32 AM)

Example of _GDIPlus_GraphicsFillPolygon()

Line 
1#include <GuiConstantsEx.au3>
2#include <GDIPlus.au3>
3
4Opt('MustDeclareVars', 1)
5
6_Main()
7
8Func _Main()
9 Local $hGUI, $hWnd, $hGraphic, $aPoints[4][2], $hBrush2
10
11 ; Create GUI
12 $hGUI = GUICreate("GDI+", 400, 300)
13 $hWnd = WinGetHandle("GDI+")
14 GUISetState()
15
16 ; Draw a polygon
17 _GDIPlus_Startup()
18 $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
19
20 $aPoints[0][0] = 3
21 $aPoints[1][0] = 150
22 $aPoints[1][1] = 150
23 $aPoints[2][0] = 200
24 $aPoints[2][1] = 100
25 $aPoints[3][0] = 250
26 $aPoints[3][1] = 150
27
28 _GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints)
29
30 ; Loop until user exits
31 Do
32 Until GUIGetMsg() = $GUI_EVENT_CLOSE
33
34 ; Clean up resources
35 _GDIPlus_BrushDispose($hBrush2)
36 _GDIPlus_GraphicsDispose($hGraphic)
37 _GDIPlus_Shutdown()
38
39EndFunc ;==>_Main
40
41Func _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush = 0)
42 Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError
43
44 $iCount = $aPoints[0][0]
45 $tPoints = DllStructCreate("int[" & $iCount * 2 & "]")
46 $pPoints = DllStructGetPtr($tPoints)
47 For $iI = 1 To $iCount
48 DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1)
49 DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2)
50 Next
51
52 _GDIPlus_BrushDefCreate($hBrush)
53 $aResult = DllCall($ghGDIPDll, "int", "GdipFillPolygonI", "hWnd", $hGraphics, "hWnd", $hBrush, _
54 "ptr", $pPoints, "int", $iCount, "int", "FillModeAlternate")
55 $tmpError = @error
56 $tmpExError = @extended
57 _GDIPlus_BrushDefDispose()
58 If $tmpError Then Return SetError($tmpError, $tmpExError, False)
59 Return SetError($aResult[0], 0, $aResult[0] = 0)
60EndFunc ;==>_GDIPlus_GraphicsFillPolygon