zbatev Posted December 23, 2011 Share Posted December 23, 2011 I intend to enable/disable the wrap/unwrap capability of the edit control but it's not working at all, here's my code: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Constants.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 246, 165, 192, 114) $Edit1 = GUICtrlCreateEdit("", 8, 8, 225, 121,BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_HSCROLL)) GUICtrlSetData(-1, "this is supposed to be a very long and whiny statement that should force this string to go to the next line and I hope it does.") $Checkbox1 = GUICtrlCreateCheckbox("Wrap Text", 152, 136, 81, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 $iStyle = _WinAPI_GetWindowLong(ControlGetHandle($Form1,"",$Edit1), $GWL_STYLE) If GUICtrlRead($Checkbox1) = 1 Then ConsoleWrite("Checked" & @CRLF) GUICtrlSetStyle($Edit1, BitOR($iStyle,BitOR($ES_AUTOVSCROLL, $WS_HSCROLL))) Else ConsoleWrite("UnChecked" & @CRLF) GUICtrlSetStyle($Edit1, BitXOR($iStyle,BitOR($ES_AUTOVSCROLL, $WS_HSCROLL))) EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
zbatev Posted December 26, 2011 Author Share Posted December 26, 2011 I tried to delete and recreate the control but that doesn't work as well... Link to comment Share on other sites More sharing options...
LarsJ Posted December 26, 2011 Share Posted December 26, 2011 Try something like this #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 246, 165, 192, 114) $Edit1 = GUICtrlCreateEdit("", 8, 8, 225, 121) GUICtrlSetData($Edit1, "this is supposed to be a very long and whiny statement that should force this string to go to the next line and I hope it does.") $Checkbox1 = GUICtrlCreateCheckbox("Wrap Text", 152, 136, 81, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 $txt = GUICtrlRead($Edit1) GUICtrlDelete($Edit1) If GUICtrlRead($Checkbox1) = 1 Then $Edit1 = GUICtrlCreateEdit("", 8, 8, 225, 121,BitXOR($GUI_SS_DEFAULT_EDIT,$ES_AUTOHSCROLL,$WS_HSCROLL)) Else $Edit1 = GUICtrlCreateEdit("", 8, 8, 225, 121) EndIf GUICtrlSetData($Edit1, $txt) EndSwitch WEnd Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 26, 2011 Moderators Share Posted December 26, 2011 (edited) zbatev, delete and recreate the control but that doesn't workYes it does; #include <buttonconstants.au3> #include <editconstants.au3> #include <guiconstantsex.au3> #include <windowsconstants.au3> #include <staticconstants.au3> #include <constants.au3> #include <winapi.au3> $Form1 = GUICreate("Form1", 246, 165, 192, 114) $Edit1 = GUICtrlCreateEdit("", 8, 8, 225, 121, BitOr($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData(-1, "this is supposed to be a very long and whiny statement that should force this string to go to the next line and I hope it does.") $Checkbox1 = GUICtrlCreateCheckbox("Wrap Text", 152, 136, 81, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 $iStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($Edit1), $GWL_STYLE) If GUICtrlRead($Checkbox1) = 1 Then ConsoleWrite("Checked" & @CRLF) $sData = GUICtrlRead($Edit1) GUICtrlDelete($Edit1) $Edit1 = GUICtrlCreateEdit("", 8, 8, 225, 121, BitOr($ES_AUTOVSCROLL, $ES_MULTILINE)) GUICtrlSetData($Edit1, $sData) Else ConsoleWrite("UnChecked" & @CRLF) $sData = GUICtrlRead($Edit1) GUICtrlDelete($Edit1) $Edit1 = GUICtrlCreateEdit("", 8, 8, 225, 121, BitOr($ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUICtrlSetData($Edit1, $sData) EndIf EndSwitch WEnd I am still looking into how you can do it dynamically by changing the style alone. M23 Edit: Looks like it cannot be done - the styles are seemingly among those that cannot be altered dynamically. Even MSDN suggests the delete/create method. Edited December 26, 2011 by Melba23 zbatev 1 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...
zbatev Posted December 26, 2011 Author Share Posted December 26, 2011 I am still looking into how you can do it dynamically by changing the style alone. M23Edit: Looks like it cannot be done - the styles are seemingly among those that cannot be altered dynamically. Even MSDN suggests the delete/create method. Thanks a lot Melba... I'll try to integrate this into my app. So sad this can't be done dynamically... 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