alawoona Posted January 29, 2012 Share Posted January 29, 2012 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 More sharing options...
Guest Posted January 29, 2012 Share Posted January 29, 2012 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 More sharing options...
alawoona Posted January 29, 2012 Author Share Posted January 29, 2012 thank you Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2012 Moderators Share Posted January 29, 2012 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 valueIf 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 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...
alawoona Posted January 29, 2012 Author Share Posted January 29, 2012 Great! Thank you Melba23 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