Jump to content
Sign in to follow this  

Draw a rectangle in my GUI

Recommended Posts


I need a method to draw a rectangle as fast as possible on a GUI.

I thought of using GDIPlus but I found only examples of drawing on an image.

Share this post

Link to post
Share on other sites

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

Opt('MustDeclareVars', 1)


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

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)

    ; Draw line
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
    $hPen = _GDIPlus_PenCreate ()
    _GDIPlus_GraphicsDrawLine ($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_GraphicsDrawLine ($hGraphic, 10, 100, 10, 150, $hPen)
    _GDIPlus_GraphicsDrawLine ($hGraphic, 10, 100, 390, 100, $hPen)
    _GDIPlus_GraphicsDrawLine ($hGraphic, 390, 100, 390, 150, $hPen)

    ; Loop until user exits
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; 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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.