Jump to content

$GUI_WS_EX_PARENTDRAG Question


alawoona
 Share

Recommended Posts

I have a script where I define a Label style as:

GUICtrlSetStyle ($cLabel01, -1, $GUI_WS_EX_PARENTDRAG).

This works as I can drag the GUI across my screen by clicking and dragging the label. My question is how do I turn off this function by changing the style of the label. I can do it now by deleting the control and then recreating it with default styles, i.e. not-draggable. Is there a more elegant solution?

Link to comment
Share on other sites

You can turn it off by using this code: GUICtrlSetStyle ($cLabel01, -1, 0)

and to turn it on again use this code: GUICtrlSetStyle ($cLabel01, -1, $GUI_WS_EX_PARENTDRAG)

Link to comment
Share on other sites

  • Moderators

alawoona,

Becareful if you have other styles applied to the label in addition to $GUI_WS_EX_PARENTDRAG as they will be removed when you use the GUICtrlSetStyle function - applying a new style value overwrites existing style values. ;)

You can get round this in 2 ways:

- 1. Store the current style value in a variable, adjust it as required and then use it when resetting the style.

- 2. Read the current style value each time by calling the Windows API directly:

#include <Constants.au3> ; Do not forget these include files!
#include <WinAPI.au3>

$iStyle   = _WinAPI_GetWindowLong(GUICtrlGetHandle($iControlID), $GWL_STYLE)
$iExStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($iControlID), $GWL_EXSTYLE)

; Once you have the current value then you can easily add or subtract other styles from it.

; Adding a new style is simple - we just use BitOR as usual:
GUICtrlSetStyle($iControlID, BitOR($iOldStyleValue, $iNewStyle))

; Subtracting a style can be done in 2 ways - although one is much easier to use:
GUICtrlSetStyle($iControlID, BitXOR($iOldStyleValue, $iStyleToRemove))
GUICtrlSetStyle($iControlID, BitAnd($iOldStyleValue, BitNOT($iStyleToRemove)))

; You can do a similar operation for the extended style value

If you want to learn more about styles and why you have to go through this pretty complex procedure, I recommend the Setting Styles tutorial in the Wiki. :)

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

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...