Jump to content

Gui Drag and Drop Label Misbehaviour


IAMK
 Share

Recommended Posts

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.
image.png.f12159ca8bfce00b69f2e76ee6f07d65.png

Link to comment
Share on other sites

  • Moderators

IAMK,

What Subz said!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Moderators

pixelsearch,

No need for the struct. Just get the label handle using GUICtrlGetHandle and pass it directly to the WinAPI call.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...