ahmet Posted March 4, 2010 Share Posted March 4, 2010 Line does not show when I draw it and I can only use menu "Line" once.drawing_tool.au3 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 4, 2010 Moderators Share Posted March 4, 2010 ahmet, Looks to me as if you were destroying the graphic each time you tried to draw a new line. I can get multiple lines with this code: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GuiConstantsEx.au3> #include <GDIPlus.au3> $main = GUICreate("Drawing", 400, 400) $file_menu = GUICtrlCreateMenu("File") $exit_sub = GUICtrlCreateMenuItem("Exit", $file_menu) $draw_menu = GUICtrlCreateMenu("Draw") $line = GUICtrlCreateMenuItem("Line", $draw_menu) $arc = GUICtrlCreateMenuItem("Arc", $draw_menu) $circle = GUICtrlCreateMenuItem("Circle", $draw_menu) $spline = GUICtrlCreateMenuItem("Spline", $draw_menu) $rectangle = GUICtrlCreateMenuItem("Rectangle", $draw_menu) GUISetState() _GDIPlus_Startup() $graphic = _GDIPlus_GraphicsCreateFromHWND($main) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exit_sub ExitLoop Case $msg = $line GUISetState(@SW_DISABLE) GUICreate("Coordinates", 200, 150) GUISetState() GUICtrlCreateGroup("Start Point", 10, 10, 80, 80) $x1 = GUICtrlCreateInput("x", 15, 30, 30, 20) $y1 = GUICtrlCreateInput("y", 50, 30, 30, 20) GUICtrlCreateGroup("End Point", 100, 10, 80, 80) $x2 = GUICtrlCreateInput("x", 105, 30, 30, 20) $y2 = GUICtrlCreateInput("y", 140, 30, 30, 20) $ok_button = GUICtrlCreateButton("OK", 60, 120, 40, 20) $cancel_button = GUICtrlCreateButton("Cancel", 110, 120, 40, 20) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $ok_button $p1 = GUICtrlRead($x1) $p2 = GUICtrlRead($x2) $t1 = GUICtrlRead($y1) $t2 = GUICtrlRead($y2) GUIDelete() GUISetState(@SW_ENABLE, $main) WinActivate($main) _GDIPlus_GraphicsDrawLine($graphic, $p1, $t1, $p2, $t2) ExitLoop EndSelect WEnd EndSelect WEnd _GDIPlus_GraphicsDispose($graphic) _GDIPlus_Shutdown() I hope it helps. 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...
ahmet Posted March 4, 2010 Author Share Posted March 4, 2010 Last line always deletes after I draw a new one Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 4, 2010 Moderators Share Posted March 4, 2010 ahmet, First, a belated welcome to the AutoIt forum. I am not an expert with GDI, but this now refreshes the lines - although you do have to close all other windows first: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> $main = GUICreate("Drawing", 400, 400) $file_menu = GUICtrlCreateMenu("File") $exit_sub = GUICtrlCreateMenuItem("Exit", $file_menu) $draw_menu = GUICtrlCreateMenu("Draw") $line = GUICtrlCreateMenuItem("Line", $draw_menu) $arc = GUICtrlCreateMenuItem("Arc", $draw_menu) $circle = GUICtrlCreateMenuItem("Circle", $draw_menu) $spline = GUICtrlCreateMenuItem("Spline", $draw_menu) $rectangle = GUICtrlCreateMenuItem("Rectangle", $draw_menu) GUISetState() _GDIPlus_Startup() $graphic = _GDIPlus_GraphicsCreateFromHWND($main) $bitmap = _GDIPlus_BitmapCreateFromGraphics(401, 401, $graphic) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exit_sub ExitLoop Case $msg = $line GUISetState(@SW_DISABLE) GUICreate("Coordinates", 200, 150) GUISetState() GUICtrlCreateGroup("Start Point", 10, 10, 80, 80) $x1 = GUICtrlCreateInput("x", 15, 30, 30, 20) $y1 = GUICtrlCreateInput("y", 50, 30, 30, 20) GUICtrlCreateGroup("End Point", 100, 10, 80, 80) $x2 = GUICtrlCreateInput("x", 105, 30, 30, 20) $y2 = GUICtrlCreateInput("y", 140, 30, 30, 20) $ok_button = GUICtrlCreateButton("OK", 60, 120, 40, 20) $cancel_button = GUICtrlCreateButton("Cancel", 110, 120, 40, 20) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $ok_button $p1 = GUICtrlRead($x1) $p2 = GUICtrlRead($x2) $t1 = GUICtrlRead($y1) $t2 = GUICtrlRead($y2) GUIDelete() GUISetState(@SW_ENABLE, $main) WinActivate($main) _GDIPlus_GraphicsDrawLine($backbuffer, $p1, $t1, $p2, $t2) _GDIPlus_GraphicsDrawImageRect($graphic, $bitmap, 0, 0, 401, 401) ExitLoop EndSelect WEnd EndSelect WEnd _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphic) _GDIPlus_Shutdown() 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...
ahmet Posted March 5, 2010 Author Share Posted March 5, 2010 Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2010 Moderators Share Posted March 5, 2010 ahmet,Glad I could help. Might I suggest that you make your titles a bit more descriptive of the problem in future? If you had added "GDI" to the title, you would have attracted the GDI gurus and got more expert help (perhaps!).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...
ahmet Posted March 5, 2010 Author Share Posted March 5, 2010 Now I get the message ' "EndSelect" statement with no matching "Select" statement 'drawing_tool.au3 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2010 Moderators Share Posted March 5, 2010 ahmet,And what have you done to solve the problem before posting here? We would prefer that you make some effort to debug something as simple as this by yourself before asking for help. If you have the full version of SciTE4AutoIt3 then run Tidy (by pressing Ctrl-T or via the <Tools> menu) and it will indicate where the problem is. If you do not have the full SciTE package, I recommend you download it from here.If you do not have Tidy available, then here is a clue: Where is the WEnd to match the While 1 on line 89?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