CyberSlug Posted March 29, 2004 Share Posted March 29, 2004 (edited) Can the style and exStyle of a control be set dynamically? I want to toggle word wrap on an edit control..... My workaround is to create two Edit controls (one with wordwrap, one without) and only have one visible at a time.expandcollapse popupGlobal $title = "text editor foo" Global $typeface = "Courier New" Global $wrapping = 1 ; stores status of word wrap; 1 = disabled, 2 = enabled ; the $wrap checkbox control is read and note that 0=disabled, 1=enabled Opt("GuiNotifyMode",1) GUICreate($title, 440, 280, 100, 100) WinActivate($title) Global $txt1 = GUISetControl("edit", "", 0, 30 ,430 ,220) Global $txt2 = GUISetControl("edit", "", 0, 30 ,430 ,220, 0x50200104, 0x00000200) Global $wrap = GUISetControl("checkbox", "Word wrap", 5,5, 400,20) ControlCommand($title,"", "Word wrap", "Check", "") GUISetControlFont($txt1, 10, 400, $typeface) GUISetControlFont($txt2, 10, 400, $typeface) GUIShow() ;loop until user clicks the close button while 1 ;ToolTip(GUIMsg(0), 0,0) sleep(100) If GuiMsg(0) = -3 Then If GUIRead( Eval("txt" & $wrapping) ) <> "" Then MsgBox(4096,"","Quitting") ExitLoop EndIf $w = 1 + ControlCommand ($title,"", "Word wrap", "IsChecked", "") If $w <> $wrapping Then ; set controls to contain same text, then toggle which is visible $text = GUIRead( Eval("txt" & $wrapping) ) ControlSetText ($title,"", "Edit"&$w, $text) ControlShow ($title,"", "Edit"&$w ) ControlHide ($title,"", "Edit"&$wrapping ) $wrapping = $w EndIf Wend Exit Edited March 29, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
jpm Posted March 29, 2004 Share Posted March 29, 2004 I don't think so, because only some control can be change with special Windows API. Which Style ExStyle are you thinking about? Link to comment Share on other sites More sharing options...
Valik Posted March 29, 2004 Share Posted March 29, 2004 I don't think so, because only some control can be change with special Windows API. Which Style ExStyle are you thinking about?I can change the style in 2 lines, provided you already have the HWND to the window/control and the new style to add... LONG style = GetWindowLong(hWnd, GWL_STYLE); SetWindowLong(hWnd, GWL_STYLE, style | newStyle); And I can do the same for extended styles... LONG exStyle = GetWindowLong(hWnd, GWL_EXSTYLE); SetWindowLong(hWnd, GWL_EXSTYLE, exStyle | newExStyle); And I usually use this to remove a style: LONG style = GetWindowLong(hWnd, GWL_STYLE); if (style & styleToRemove) SetWindowLong(hWnd, GWL_STYLE, style ^ newStyle); // If the style isn't there, nothing needs to be done... Link to comment Share on other sites More sharing options...
Valik Posted March 30, 2004 Share Posted March 30, 2004 Larry, here is my thoughts on that. If you are messing with something, you should know what you are doing with it. If you try to mess with something you don't understand and you screw something up, well, it sucks to be you then, cause I would of had enough sense to know what I'm doing first. Link to comment Share on other sites More sharing options...
CyberSlug Posted March 30, 2004 Author Share Posted March 30, 2004 If you are messing with something, you should know what you are doing with it. If you try to mess with something you don't understand and you screw something up, well, it sucks to be you ...Agreed.Anyway, how is this any different from calling GUISetControl with style and exStyle? You allow the user that much control all ready Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted March 30, 2004 Share Posted March 30, 2004 (edited) I agree, except I don't think there needs to be seperate functions for controls and Windows. Just a GetStyle, SetStyle, GetStyleEx, SetStyleEx should be sufficient.Edit: Never mind that. I realize why you have to do it that way now (Forgot we can't get HWND's of controls (yet)). Edited March 30, 2004 by Valik Link to comment Share on other sites More sharing options...
jpm Posted March 30, 2004 Share Posted March 30, 2004 Larry, Valik, I add the support in GuiWrite(controlref,state,text,style,exstyle) is it OK for you? 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