topten Posted December 27, 2015 Posted December 27, 2015 (edited) I create buttons, which I can move in GUI. When I drag drop them they are flashing and sometimes the button has the label of the other button. What can I do to make their behavior looking more professional, prevent them from flashing? expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> ; Mouse coords relative to GUI client area Opt("MouseCoordMode", 2) ; Set target coords Global $iTgt_Left = 10, $iTgt_Right = 210, $iTgt_Top = 10, $iTgt_Bot = 110 ; Create GUI $hGUI = GUICreate("Test", 300, 200) $cLabel = GUICtrlCreateButton("Move me", 10, 170, 80, 23) $cLabel1 = GUICtrlCreateButton("Move me", 10, 130, 80, 23) ;GUICtrlSetBkColor(-1, 0x00FF00) $cButton = GUICtrlCreateButton("Me too", 10, 150, 80, 23) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN ; If the mouse button is pressed - get info about where $cInfo = GUIGetCursorInfo($hGUI) ; Is it over a control $iControl = $cInfo[4] Switch $iControl ; If it is a control we want to move ; for $z = 1 to 4 Case $cLabel, $cButton, $cLabel1 ; Work out offset of mouse on control $aPos = ControlGetPos($hGUI, "", $iControl) $iSubtractX = $cInfo[0] - $aPos[0] $iSubtractY = $cInfo[1] - $aPos[1] ; And then move the control until the mouse button is released Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $iControl, 10, $cInfo[1] - $iSubtractY) Until Not $cInfo[2] ; See if the mouse was released over the target $aMPos = MouseGetPos() EndSwitch EndSwitch WEndGreat thanx in advance! I enclose a picture first picture what I get, the second picture is when I move the mouse over the gui Edited December 28, 2015 by topten
Moderators Melba23 Posted December 28, 2015 Moderators Posted December 28, 2015 topten,Adding the $WS_CLIPSIBLINGS style to the GUI seems to solve the problem for me.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
topten Posted December 28, 2015 Author Posted December 28, 2015 So, I am trying this code with clipsiblings And now I dont even see my gui at all. It starts hiding, I can see it only when I move my mouse of the script icon on the process bar expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> ; Mouse coords relative to GUI client area Opt("MouseCoordMode", 2) ; Set target coords Global $iTgt_Left = 10, $iTgt_Right = 210, $iTgt_Top = 10, $iTgt_Bot = 110 ; Create GUI $hGUI = GUICreate("Test", 300, 200, $WS_CLIPSIBLINGS) $cLabel = GUICtrlCreateButton("Move me", 10, 170, 80, 23) $cLabel1 = GUICtrlCreateButton("Move me", 10, 130, 80, 23) ;GUICtrlSetBkColor(-1, 0x00FF00) $cButton = GUICtrlCreateButton("Me too", 10, 150, 80, 23) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN ; If the mouse button is pressed - get info about where $cInfo = GUIGetCursorInfo($hGUI) ; Is it over a control $iControl = $cInfo[4] Switch $iControl ; If it is a control we want to move ; for $z = 1 to 4 Case $cLabel, $cButton, $cLabel1 ; Work out offset of mouse on control $aPos = ControlGetPos($hGUI, "", $iControl) $iSubtractX = $cInfo[0] - $aPos[0] $iSubtractY = $cInfo[1] - $aPos[1] ; And then move the control until the mouse button is released Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $iControl, 10, $cInfo[1] - $iSubtractY) Until Not $cInfo[2] ; See if the mouse was released over the target $aMPos = MouseGetPos() EndSwitch EndSwitch WEnd
Gianni Posted December 28, 2015 Posted December 28, 2015 also with $WS_CLIPSIBLINGS it seems that the issue doesn't go away,the problem arises when the mousepointer is hovering on the other buttons while dragging the picked button.The underlying buttons "react" to the mouse move causing the visual issue.I've seen that adding GUICtrlSetState(-1, $GUI_DISABLE ) after each GUICtrlCreateButton (disabling indeed to buttons), you will be still allowed to drag the buttons but without the visual issue. Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Moderators Melba23 Posted December 28, 2015 Moderators Posted December 28, 2015 topten,I said "ADD", not "REPLACE" - so you would need to use this:$hGUI = GUICreate("Test", 300, 200, Default, Default, BitOr($GUI_SS_DEFAULT_GUI, $WS_CLIPSIBLINGS))What you did was replace all the existing styles - the Setting Styles tutorial in the Wiki explains why you need to do this.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
mikell Posted December 28, 2015 Posted December 28, 2015 (edited) May I add, better use $GUI_EVENT_SECONDARYDOWN to do this move so you don't execute a 'click button' when the mouse button is releasedEditGuiCtrlSendMsg seems better for me than $WS_CLIPSIBLINGSexpandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> ; Mouse coords relative to GUI client area Opt("MouseCoordMode", 2) ; Set target coords Global $iTgt_Left = 10, $iTgt_Right = 210, $iTgt_Top = 10, $iTgt_Bot = 110 ; Create GUI $hGUI = GUICreate("Test", 300, 200) $cLabel = GUICtrlCreateButton("Move me", 10, 170, 80, 23) $cLabel1 = GUICtrlCreateButton("Move me", 10, 130, 80, 23) $cButton = GUICtrlCreateButton("Me too", 10, 150, 80, 23) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_SECONDARYDOWN ; If the mouse button is pressed - get info about where $cInfo = GUIGetCursorInfo($hGUI) ; Is it over a control $iControl = $cInfo[4] Switch $iControl ; If it is a control we want to move Case $cLabel, $cButton, $cLabel1 GuiCtrlSendMsg($iControl, $BM_SETSTATE, 1, 0) ; Work out offset of mouse on control $aPos = ControlGetPos($hGUI, "", $iControl) $iSubtractX = $cInfo[0] - $aPos[0] $iSubtractY = $cInfo[1] - $aPos[1] ; And then move the control until the mouse button is released Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $iControl, 10, $cInfo[1] - $iSubtractY) Until Not $cInfo[3] ; See if the mouse was released over the target $aMPos = MouseGetPos() GuiCtrlSendMsg($iControl, $BM_SETSTATE, 0, 0) EndSwitch Case $cLabel, $cButton, $cLabel1 msgbox(0,"", "test") EndSwitch WEnd Edited December 28, 2015 by mikell
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