Sign in to follow this  
Followers 0
AlmarM

How to remove a style?

9 posts in this topic

#1 ·  Posted (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 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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Authenticity

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Try this:

#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_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0