altex Posted September 29, 2014 Posted September 29, 2014 Hello, Just wonder how can I draw two GUI label items (I already know this part ). These two labels are not drawn at the same time and they're partly overlapped. My actual question is how to keep the old label box on top of the new one? Anyone has idea how to do it? Thanks.
hiho Posted September 29, 2014 Posted September 29, 2014 Cant you create one label and then update its contet using GUICtrlSetData?
altex Posted September 29, 2014 Author Posted September 29, 2014 Cant you create one label and then update its contet using GUICtrlSetData? I'm using GUICtrlSetData to adjust the label items. But I need to make sure the most recent label is underneath the old one. In other words, the old label box should be always on top of new one.
Moderators Melba23 Posted September 29, 2014 Moderators Posted September 29, 2014 altex,The only way I can think of to do this is to delete and recreate the old label when you update the other - something like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cLabel_1 = GUICtrlCreateLabel("First Label", 10, 10, 200, 200) GUICtrlSetBkColor($cLabel_1, 0xCCFFCC) $cLabel_2 = GUICtrlCreateLabel("Second Label", 100, 100, 200, 200, $SS_RIGHT) GUICtrlSetBkColor($cLabel_2, 0xFFCCCC) $cBtn_1 = GUICtrlCreateButton("Update Red", 10, 450, 120, 30) $cBtn_2 = GUICtrlCreateButton("Update Green", 260, 450, 120, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cBtn_1 GUICtrlSetData($cLabel_2, "Updated label") $sData = GUICtrlRead($cLabel_1) ; So you can reset the current content and not the "Old label" text used below $aPos = ControlGetPos($hGUI, "", $cLabel_1) GUICtrlDelete($cLabel_1) $cLabel_1 = GUICtrlCreateLabel("Old label", $aPos[0], $aPos[1], $aPos[2], $aPos[3]) GUICtrlSetBkColor($cLabel_1, 0xCCFFCC) Case $cBtn_2 GUICtrlSetData($cLabel_1, "Updated label") $sData = GUICtrlRead($cLabel_2) $aPos = ControlGetPos($hGUI, "", $cLabel_2) GUICtrlDelete($cLabel_2) $cLabel_2 = GUICtrlCreateLabel("Old label", $aPos[0], $aPos[1], $aPos[2], $aPos[3], $SS_RIGHT) GUICtrlSetBkColor($cLabel_2, 0xFFCCCC) EndSwitch WEndThere must be a more elegant solution - I shall keep looking. 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
altex Posted September 29, 2014 Author Posted September 29, 2014 If using your method and do it quickly, I bet it will make the screen flicker,so not a perfect solution
Syed23 Posted September 29, 2014 Posted September 29, 2014 Hi Altex, Hope i am not out of the track You can create 2 label with same X,Y co-ordinates and hide both of them using GUICTRLSETSTATE(-1,$GUI_HIDE) whenever you want to show the label you want to show use the function GUICTRLSETSTATE($Lable1,$GUI_SHOW) Melba please correct me if i am wrong. Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
Moderators Melba23 Posted September 29, 2014 Moderators Posted September 29, 2014 altex,How about explaining why you want to do this - why must the old label be under the newer one? Then you might get a better suggestion of how you might solve your problem. Syed23,Very clever idea - as long as you create the labels in the correct order that works very nicely: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $sLabel = "A" $hGUI = GUICreate("Test", 500, 500) $cLabel_1A = GUICtrlCreateLabel("First Label A", 10, 10, 200, 200) GUICtrlSetBkColor($cLabel_1A, 0xCCFFCC) $cLabel_2 = GUICtrlCreateLabel("Second Label", 100, 100, 200, 200, $SS_RIGHT) GUICtrlSetBkColor($cLabel_2, 0xFFCCCC) $cLabel_1B = GUICtrlCreateLabel("First Label B", 10, 10, 200, 200) GUICtrlSetBkColor($cLabel_1B, 0xCCFFCC) GUICtrlSetState($cLabel_1B, $GUI_HIDE) $cBtn_1 = GUICtrlCreateButton("Update Red", 10, 450, 120, 30) $cBtn_2 = GUICtrlCreateButton("Update Green", 260, 450, 120, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cBtn_1 GUICtrlSetData($cLabel_2, "Updated at " & @SEC) If $sLabel = "A" Then $sLabel = "B" GUICtrlSetState($cLabel_1B, $GUI_SHOW) GUICtrlSetState($cLabel_1A, $GUI_HIDE) Else $sLabel = "A" GUICtrlSetState($cLabel_1A, $GUI_SHOW) GUICtrlSetState($cLabel_1B, $GUI_HIDE) EndIf Case $cBtn_2 GUICtrlSetData($cLabel_1A, "Updated A at " & @SEC) GUICtrlSetData($cLabel_1B, "Updated B at " & @SEC) If $sLabel = "A" Then $sLabel = "B" GUICtrlSetState($cLabel_1B, $GUI_SHOW) GUICtrlSetState($cLabel_1A, $GUI_HIDE) Else $sLabel = "A" GUICtrlSetState($cLabel_1A, $GUI_SHOW) GUICtrlSetState($cLabel_1B, $GUI_HIDE) EndIf 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
Syed23 Posted September 29, 2014 Posted September 29, 2014 Syed23, Very clever idea - as long as you create the labels in the correct order that works very nicely: M23 I am feeling very great today. Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
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