Tipulatoid Posted November 8, 2017 Share Posted November 8, 2017 Hello. Maybe this issue was discussed before, but I spent about a hour and didn't get the answer. Probably I used wrong search params. I am trying to draw a line in tabitem. That's is a sample script: expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $hGUI, $hGraphic, $hPen ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) GUISetState(@SW_SHOW) $hTab = GUICtrlGetHandle(GuiCtrlCreateTab(20, 10, 350, 280)) ; handle is got $hTabItem0 = GUICtrlGetHandle(GuiCtrlCreateTabItem("tabitem0")) ; doesn't get handle GuiCtrlCreateLabel("Test0", 100, 100) $hTabItem1 = GUICtrlGetHandle(GuiCtrlCreateTabItem("tabitem1")) ; doesn't get handle GuiCtrlCreateLabel("Test1", 200, 200) ConsoleWrite ($hTab & @CRLF) ConsoleWrite ($hTabItem0 & @CRLF) ConsoleWrite ($hTabItem1 & @CRLF) ; Draw line _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hTab) $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsDrawLine($hGraphic, 25, 150, 300, 120, $hPen) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example The line is drawn in the GUI, not in the needed tabitem (say, tabitem1). I think, I need to get the handle of the tabitem, but I don't know how. Thanks in advance. Link to comment Share on other sites More sharing options...
Deye Posted November 8, 2017 Share Posted November 8, 2017 (edited) try for example expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> Global $hGraphic, $hPen $hGUI = GUICreate("GDI+", 400, 300) _GDIPlus_Startup() Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hPen = _GDIPlus_PenCreate() OnAutoItExitRegister("_On_Exit") $hTab = GUICtrlCreateTab(20, 10, 350, 280) GUICtrlCreateTabItem("tabitem0") GUICtrlCreateLabel("Test0", 100, 100) GUICtrlCreateTabItem("tabitem1") GUICtrlCreateLabel("Test1", 200, 200) GUISetState() _Drawline() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $hTab If GUICtrlRead($hTab) = 0 Then _Drawline() Else _WinAPI_InvalidateRect($hGUI) EndIf Case $GUI_EVENT_RESTORE If GUICtrlRead($hTab) = 0 Then _Drawline() EndSwitch WEnd Exit Func _Drawline() _GDIPlus_GraphicsDrawLine($hGraphic, 25, 150, 300, 120, $hPen) EndFunc ;==>_Drawline Func _On_Exit() _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>_On_Exit Edited November 8, 2017 by Deye Tipulatoid 1 Link to comment Share on other sites More sharing options...
Tipulatoid Posted November 8, 2017 Author Share Posted November 8, 2017 (edited) 4 minutes ago, Deye said: try for example Sorry, this doesn't look like a decision.... maybe I didn't catch your idea. I need to draw a line in tabitem1 Edited November 8, 2017 by Tipulatoid Link to comment Share on other sites More sharing options...
Deye Posted November 8, 2017 Share Posted November 8, 2017 The previous example was for: how to get the controls not related to GDI .. check the modified above code .. Link to comment Share on other sites More sharing options...
Tipulatoid Posted November 8, 2017 Author Share Posted November 8, 2017 Oh, I see. The idea is to draw line each time when user clicks needed tabitem and erase it when he clicks another. Didn't think in such direction. Thank you very much, Deye Link to comment Share on other sites More sharing options...
Deye Posted November 8, 2017 Share Posted November 8, 2017 your welcome, added a on restore event , just in case .. Link to comment Share on other sites More sharing options...
funkey Posted November 15, 2017 Share Posted November 15, 2017 Why not use GUICtrlCreateGraphic for the line? Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. 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