IAMK Posted December 19, 2018 Share Posted December 19, 2018 I was looking to implement some Drag and Drop GUI, and I found the following code: It works fine, but I noticed that when the button overlaps the label, the way the label looks changes. Is this an issue or is there something I need to set up on my side to stop this happening? E.g. Link to comment Share on other sites More sharing options...
Subz Posted December 19, 2018 Share Posted December 19, 2018 You can use _WinAPI_RedrawWindow to send a $WM_PAINT message or use SendMessage. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2018 Moderators Share Posted December 19, 2018 IAMK, What Subz said! 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...
pixelsearch Posted December 19, 2018 Share Posted December 19, 2018 Hi IAMK Glad you shared Melba's script with us, another great one ! I tried SubZ advice to avoid the issue you described, let's hope I did it right... 3 parts should be added to Melba's script. First : #include <WinAPIGdi.au3> Second, anywhere before While 1 : Global $tRECT = DllStructCreate($tagRECT) Third, replace this : Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $iControl, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY) Until Not $cInfo[2] with that : GUICtrlSetState($iControl, $GUI_DISABLE) Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $iControl, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY) If $iControl = $cLabel Then DllStructSetData($tRECT,"Left" , $cInfo[0] - $iSubtractX) DllStructSetData($tRECT,"Top", $cInfo[1] - $iSubtractY) DllStructSetData($tRECT,"Right", $cInfo[0] - $iSubtractX + 60) ; 60 is label width DllStructSetData($tRECT,"Bottom", $cInfo[1] - $iSubtractY + 20) ; 20 is label height _WinAPI_RedrawWindow($hGUI, $tRECT) EndIf Until Not $cInfo[2] GUICtrlSetState($iControl, $GUI_ENABLE) Thanks to anyone reading this to share his knowledge, in case something should be done differently Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2018 Moderators Share Posted December 19, 2018 pixelsearch, No need for the struct. Just get the label handle using GUICtrlGetHandle and pass it directly to the WinAPI call. 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...
pixelsearch Posted December 19, 2018 Share Posted December 19, 2018 Hi Melba23, Yes, it works too and much easier, thanks So IAMK, here is version 2 : Add 3 parts to Melba's script. First : #include <WinAPIGdi.au3> Second, add the variable $hLabel after the existing $cLabel line : $cLabel = GUICtrlCreateLabel("Move me", 10, 150, 60, 20) $hLabel = GUICtrlGetHandle($cLabel) Third, replace this : Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $iControl, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY) Until Not $cInfo[2] with that : GUICtrlSetState($iControl, $GUI_DISABLE) Do $cInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, "", $iControl, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY) If $iControl = $cLabel Then _WinAPI_RedrawWindow($hLabel) EndIf Until Not $cInfo[2] GUICtrlSetState($iControl, $GUI_ENABLE) I like it when we learn new things Link to comment Share on other sites More sharing options...
IAMK Posted December 20, 2018 Author Share Posted December 20, 2018 Thanks. all. That solves this issue. There is also one other small thing I was wondering about: How does the top-down ordering work? It seems that the button is visually on top of the label, but the label is actually on top of the button (regardless of the order I create them in). 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