AlmarM Posted March 17, 2009 Share Posted March 17, 2009 (edited) Hello, I was wondering, how to remove a style from a control? This doesn't seem to work. #include <EditConstants.au3> $GUI = GUICreate("Example", 300, 100) $Input = GUICtrlCreateInput(Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1), 10, 10, 280, 20, $ES_CENTER + $ES_PASSWORD) $HideShow = GUICtrlCreateButton("Show", 127, 40, 50) GUICtrlSetLimit($Input, 4, 0) GUISetState() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = -3 Exit Case $nMsg = $HideShow If GUICtrlRead($HideShow) = "Show" Then GUICtrlSetStyle($Input, $ES_CENTER) GUICtrlSetData($HideShow, "Hide") Else GUICtrlSetStyle($Input, $ES_CENTER + $ES_PASSWORD) GUICtrlSetData($HideShow, "Show") EndIf EndSelect WEnd AlmarM Edited March 17, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Authenticity Posted March 17, 2009 Share Posted March 17, 2009 Some styles are not changeable, you can use this for example: _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), $WS_VISIBLE)) To hide the window if it's visible and vice versa but if this style cannot be changed on run-time then it won't work. Link to comment Share on other sites More sharing options...
jvanegmond Posted March 17, 2009 Share Posted March 17, 2009 You should actually BitOR the styles together instead of adding them. github.com/jvanegmond Link to comment Share on other sites More sharing options...
AlmarM Posted March 17, 2009 Author Share Posted March 17, 2009 So how can I remove the $ES_PASSWORD in my example? AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Authenticity Posted March 17, 2009 Share Posted March 17, 2009 (edited) ANDing anything with not $ES_PASSWORD. $ES_PASSWORD = 32 _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), _ BitXOR($ES_PASSWORD, 0xFFFFFFFF))) But I think the this style is unchangeable on run-time. Edited March 17, 2009 by Authenticity Link to comment Share on other sites More sharing options...
AlmarM Posted March 17, 2009 Author Share Posted March 17, 2009 (edited) Yep, I think its unchangeable. #Include <WinAPI.au3> #include <EditConstants.au3> #include <Constants.au3> $GUI = GUICreate("Example", 300, 100) $Input = GUICtrlCreateInput(Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1), 10, 10, 280, 20, $ES_CENTER + $ES_PASSWORD) $HideShow = GUICtrlCreateButton("Show", 127, 40, 50) GUICtrlSetLimit($Input, 4, 0) GUISetState() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = -3 Exit Case $nMsg = $HideShow If GUICtrlRead($HideShow) = "Show" Then _WinAPI_SetWindowLong($GUI, $GWL_STYLE, BitAND(_WinAPI_GetWindowLong($GUI, $GWL_STYLE), BitXOR($ES_PASSWORD, 0xFFFFFFFF))) GUICtrlSetData($HideShow, "Hide") Else GUICtrlSetStyle($Input, $ES_CENTER + $ES_PASSWORD) GUICtrlSetData($HideShow, "Show") EndIf EndSelect WEnd AlmarM Edited March 17, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Authenticity Posted March 17, 2009 Share Posted March 17, 2009 You should change the $hEdit and not the $hGUI style. .. . . Case $nMsg = $HideShow $hEdit = GuiCtrlGetHandle($Input) WinAPI_SetWindowLong($hEdit, $GWL_STYLE, BitAND(_WinAPI_GetWindowLong($hEdit, $GWL_STYLE), BitXOR($ES_PASSWORD, 0xFFFFFFFF))) .. . . Then, confirm if it doesn't work. Link to comment Share on other sites More sharing options...
MrCreatoR Posted March 17, 2009 Share Posted March 17, 2009 Try this: expandcollapse popup#include <EditConstants.au3> #include <Constants.au3> ; $GUI = GUICreate("Example", 300, 100) $Input = GUICtrlCreateInput(Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1), 10, 10, 280, 20, $ES_CENTER) GUICtrlSetLimit($Input, 4, 0) $HideShow = GUICtrlCreateButton("Show", 127, 40, 50) _GUICtrlEdit_TogglePassChars($GUI, $Input, 1, Chr(149)) GUISetState() While 1 Switch GUIGetMsg() Case -3 Exit Case $HideShow If GUICtrlRead($HideShow) = "Show" Then _GUICtrlEdit_TogglePassChars($GUI, $Input, 0) GUICtrlSetData($HideShow, "Hide") Else _GUICtrlEdit_TogglePassChars($GUI, $Input, 1, Chr(149)) GUICtrlSetData($HideShow, "Show") EndIf EndSwitch WEnd Func _GUICtrlEdit_TogglePassChars($hWnd, $hCtrl, $iToggleState = -1, $sPassChar = "*") If Not IsHWnd($hWnd) Then $hWnd = WinGetHandle($hWnd) If Not IsHWnd($hCtrl) Then $hCtrl = ControlGetHandle($hWnd, "", $hCtrl) Local Const $EM_SETPASSWORDCHAR = 0xCC Local Const $EM_GETPASSWORDCHAR = 0xD2 Local $iPass_Char = 0 Local $aRet = DllCall("user32.dll", "long", "SendMessage", "hwnd", $hCtrl, "int", $EM_GETPASSWORDCHAR, "int", 0, "int", 0) If IsArray($aRet) And Not $aRet[0] Then $iPass_Char = Asc($sPassChar) If $iToggleState = 0 Then $iPass_Char = 0 DllCall("user32.dll", "long", "SendMessage", "hwnd", $hCtrl, "int", $EM_SETPASSWORDCHAR, "int", $iPass_Char, "int", 0) ControlFocus($hWnd, "", $hCtrl) EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
AlmarM Posted March 17, 2009 Author Share Posted March 17, 2009 Thx MrCreatoR! AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. 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