Jump to content
Sign in to follow this  

Constant update on lines - How?!

Recommended Posts


_GDIPlus_GraphicsDrawLine ($hGraphic, 10, 150, $Gui_X, $Gui_Y, $hPen)

I snagged the code from the help tutorial, as it's my first time using a GDI. I need to constantly update the coords of the 2nd point (gui_x and y). But I cant just keep reloading that command in a loop, as given time, ill have a solid black area. how can i constantly get new cords, without having to create over 500+ lines!

Share this post

Link to post
Share on other sites

Hi, using a modded help file example , but my mod to the code not very well optimized..

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
Opt('MustDeclareVars', 1)


Func _Main()
    Local $hGUI, $hWnd, $hGraphic, $hPen

    ; Create GUI
    $hWnd = GUICreate("GDI+", 190, 190)

    ; Draw line
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    $hPen = _GDIPlus_PenCreate ()

    ; Loop until user hit ESC
    While 1
        Local $x = 10, $y = 10
        For $i = 0 To 680
            _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFF00)
            _GDIPlus_GraphicsDrawLine ($hGraphic, 95, 95, $x, $y, $hPen)
            If $i < 170 Then 
                $x += 1
            ElseIf $i > 169 And $i < 340 Then 
                $x = 180
                $y += 1
            ElseIf $i > 339 And $i < 510 Then 
                $x -= 1
                $y = 180 
            ElseIf $i > 509 And $i < 680 Then
                $x = 10
                $y -= 1
            If _IsPressed("1B") Then ExitLoop 2

    ; Clean up resources
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

EndFunc   ;==>_Main


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this