James Posted May 5, 2008 Posted May 5, 2008 Hi, Just been looking into GDI, here is my result: Func CreateEllipticRgn($hWnd, $X1, $Y1, $X2, $Y2) $wPos = WinGetPos($hWnd) $1 = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", $X1, "long", $Y1, "long", $wPos[2], "long", $Y2) DllCall("gdi32.dll", "long", "CombineRgn", "long", $1[0], "long", $1[0], "long", $1[0], "int", 2) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $1[0], "int", 1) EndFunc ;==>CreateEllipticRgn Func CreateRoundRectRgn($hWnd, $nLeftRect, $nTopRect, $nRightRect, $nBottomRect, $nWidthEllipse, $nHeightEllipse) $wPos = WinGetPos($hWnd) $dll = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $nLeftRect, "long", $nTopRect, "long", $nRightRect, "long", $nBottomRect, "long", $nWidthEllipse, "long", $nHeightEllipse) DllCall("gdi32.dll", "long", "CombineRgn", "long", $dll[0], "long", $dll[0], "long", $dll[0], "int", 2) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $dll[0], "int", 1) EndFunc ;==>CreateRoundRectRgn Yes I know, they have probably been done before, but this is my take on it. CreateRoundRectRgn() gives some good effects. I am looking into FillRgn() but not sure how it works. I am trying to make a triangle, which shouldn't be to hard. James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Malkey Posted May 6, 2008 Posted May 6, 2008 Hi,Just been looking into GDI, .....A little, simple example would be nice/easier.Please
smashly Posted May 6, 2008 Posted May 6, 2008 (edited) Hi, nice work on your finds. I am trying to make a triangle, which shouldn't be to hard.If you mean Polygon then you can already create a polygon with gdiplus as the function is already supplied. If you'd like to draw a filled polygon then try thisexpandcollapse popup#include <GuiConstantsEx.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hGUI, $hWnd, $hGraphic, $aPoints[4][2] ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) $hWnd = WinGetHandle("GDI+") GUISetState() ; Draw a polygon _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd) $aPoints[0][0] = 3 $aPoints[1][0] = 150 $aPoints[1][1] = 150 $aPoints[2][0] = 200 $aPoints[2][1] = 100 $aPoints[3][0] = 250 $aPoints[3][1] = 150 _GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown () EndFunc ;==>_Main Func _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush = 0) Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError $iCount = $aPoints[0][0] $tPoints = DllStructCreate("int[" & $iCount * 2 & "]") $pPoints = DllStructGetPtr($tPoints) For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next _GDIPlus_BrushDefCreate($hBrush) $aResult = DllCall($ghGDIPDll, "int", "GdipFillPolygonI", "hWnd", $hGraphics, "hWnd", $hBrush, _ "ptr", $pPoints, "int", $iCount, "int", "FillModeAlternate") $tmpError = @error $tmpExError = @extended _GDIPlus_BrushDefDispose() If $tmpError Then Return SetError($tmpError, $tmpExError, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_GraphicsFillPolygon Cheers Edit: I was actually surprised that there's no _GDIPlus_GraphicsFillPolygon() already added to autoit gdi udf Edited May 6, 2008 by smashly
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now