Jump to content

Help drawing lines in GUI


jgbonc
 Share

Recommended Posts

New to AutoIT and im having trouble understanding the GUICtrlSetGraphic and all of the other graphics functions any pointers would be greatly appreciated. I basically made a template GUI for me to mess around with until I get comfortable enough to actually attempt to code some thing.

#include <GUIConstantsEx.au3>
#include <FontConstants.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>

Opt('MustDeclareVars', 1)
MainGUI()

Func MainGUI()
;;CREATING THE BASE GUI(OWNER)
GUICreate("Night Reports", 1000, 300)
Opt("GUICoordMode", 2)
;;GUISetIcon("PathtoIcon")

;;Set Variables
Local $msg, $create, $programname



;; Run the GUI until the window is closed
GUISetState()
    While 1
    $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BUTTON CREATION;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    $create = GUICtrlCreateButton("Add Report", 10, 30, 100)
    GUICtrlSetPos(-1, 0, 260, 1000, 40)

;   $programname = GUICtrlCreateInput("INV.FLOW7", 0, 0)
;   GUICtrlSetPos(-1, 0, 0, 50, 20)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BUTTON CREATION STOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GRAPHICS CREATION;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 10)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GRAPHICS CREATION STOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BUTTON FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            Case $msg = $create







;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BUTTON FUNCTIONS STOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



        EndSelect

    WEnd

EndFunc   ;==>MainGUI

I fixed the issue my self, it was a stupid mistake. Another question about the code above. Is it the best way to keep the GUI active ? The loop statement that I use seems.... sensitive about where things go.

 

Thanks J

Edited by jgbonc
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <FontConstants.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>


;;Set Variables
Local $msg, $create, $programname

Opt('MustDeclareVars', 1)

;;CREATING THE BASE GUI(OWNER)
Local $hGUI = GUICreate("Night Reports", 1000, 300)
Opt("GUICoordMode", 2)
;;GUISetIcon("PathtoIcon")

Local $create = GUICtrlCreateButton("Add Report", 10, 30, 100)
GUICtrlSetPos(-1, 0, 260, 1000, 40)


Local $Graphic = GUICtrlCreateGraphic(10, 10, 200, 200);this graphic was taken from the example
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 30, 40)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 70, 70)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 50)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 100, 100, 50, 80)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xc0c0ff)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)




;; Run the GUI until the window is closed
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $create
            Exit;Put whatever you need to happen when the button is pressed
    EndSelect
WEnd

You were creating the gui elements inside the While loop.

You were also using the  GUICtrlSetGraphic function before having created the graphic area itself with a GUICtrlCreateGraphic

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...