Rawox Posted July 17, 2009 Share Posted July 17, 2009 Hey, Is there a way to create lines and rectangles in a GUI. I want to create them but I don't understand the GUICtrlCreateGraphic function. So, could someone explain that one a little bit better to me or are there other ways to do this? Rawox. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2009 Moderators Share Posted July 17, 2009 Rawox,Hello yet again.....Here is a commented example of how to use GUICtrlCreateGraphic and how to draw rectangles and lines:#include <GUIConstantsEx.au3> ; Create GUI $hGUI = GUICreate("Test", 500, 500) ; Create GREEN graphic $hGraph_1 = GUICtrlCreateGraphic(10, 10, 250, 250) GUICtrlSetBkColor(-1, 0x00FF00) ; Create BLACK bordered YELLOW rectangle within graphic GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xffff00) GUICtrlSetGraphic($hGraph_1, $GUI_GR_RECT, 20, 20, 210, 210) ; Create RED graphic $hGraph_2 = GUICtrlCreateGraphic(205, 250, 250, 250) GUICtrlSetBkColor(-1, 0xFF0000) ; Set line start point GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10) ; Set line colour to GREEN GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00) ; Draw line to this point GUICtrlSetGraphic(-1, $GUI_GR_LINE, 240, 240) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Rawox Posted July 17, 2009 Author Share Posted July 17, 2009 Thanks for your reply Melba. This will become handy Link to comment Share on other sites More sharing options...
RogFleming Posted August 4, 2009 Share Posted August 4, 2009 Is there a way to do this and have a transparent gui I just want to paint the graphic to the screen. Everything else to be transparent. Roger Rawox, Hello yet again..... Here is a commented example of how to use GUICtrlCreateGraphic and how to draw rectangles and lines: #include <GUIConstantsEx.au3> ; Create GUI $hGUI = GUICreate("Test", 500, 500) ; Create GREEN graphic $hGraph_1 = GUICtrlCreateGraphic(10, 10, 250, 250) GUICtrlSetBkColor(-1, 0x00FF00) ; Create BLACK bordered YELLOW rectangle within graphic GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xffff00) GUICtrlSetGraphic($hGraph_1, $GUI_GR_RECT, 20, 20, 210, 210) ; Create RED graphic $hGraph_2 = GUICtrlCreateGraphic(205, 250, 250, 250) GUICtrlSetBkColor(-1, 0xFF0000) ; Set line start point GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10) ; Set line colour to GREEN GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00) ; Draw line to this point GUICtrlSetGraphic(-1, $GUI_GR_LINE, 240, 240) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd M23 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2009 Moderators Share Posted August 4, 2009 RogFleming, Not asking for much, then.... >_< Actually, it is not that difficult. This code comes courtesy of ProgAndy (just in case you thought I was clever enough to have done it by myself!) expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WINAPI.au3> #include <sendmessage.au3> HotKeySet("ESC", "_Exit") $hGUI = GUICreate("Test", 500, 500, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) ; Create GREEN graphic $hGraph_1 = GUICtrlCreateGraphic(10, 10, 250, 250) GUICtrlSetBkColor(-1, 0x00FF00) ; Create BLACK bordered YELLOW rectangle within graphic GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xffff00) GUICtrlSetGraphic($hGraph_1, $GUI_GR_RECT, 20, 20, 210, 210) ; Create RED graphic $hGraph_2 = GUICtrlCreateGraphic(205, 250, 250, 250) GUICtrlSetBkColor(-1, 0xFF0000) ; Set line start point GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10) ; Set line colour to GREEN GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00) ; Draw line to this point GUICtrlSetGraphic(-1, $GUI_GR_LINE, 240, 240) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0) EndSwitch WEnd Func _Exit() Exit EndFunc Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False) ; ############################################# ; You are NOT ALLOWED to remove the following lines ; Function Name: _WinAPI_SetLayeredWindowAttributes ; Author(s): Prog@ndy ; ############################################# If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, _WinAPI_GetLastError(), 0) Case Else Return 1 EndSelect EndFunc ;==>_WinAPI_SetLayeredWindowAttributes Just click on the graphics to move the GUI - and use ESC to exit. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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