Jump to content

UnSet Style of control


Recommended Posts

searched and only found a couple of things, but can't seem to get it to work on edit control

Any help would greatly be appreciated

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 398, 320, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 32, 24, 329, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
GUICtrlSetData($Edit1, "AEdit1")
GUISetState(@SW_SHOW)
Local $ostyle = _GetStyle($Form1, $Edit1)
ConsoleWrite($ostyle & @LF)
$ostyle = BitAND($ostyle, BitNOT($ES_READONLY)); This removes the style
ConsoleWrite($ostyle & @LF)
_SetStyle($Form1, $Edit1, $ostyle)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

Func _GetStyle($title, $GuiCtrlRef)
    Local $foo = ControlGetHandle($title, "", $GuiCtrlRef)
    Local $style = DllCall("user32.dll","Long","GetWindowLong","hWnd",$foo,"int",-16)
    Return $style[0]
 EndFunc
 
Func _SetStyle($title, $GuiCtrlRef, $style)
    Local $foo = ControlGetHandle($title, "", $GuiCtrlRef)
    Local $scall = DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $foo, "int", -16, "long", $style);remove Style from old style
EndFunc
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

got some white color... nada much

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 398, 320, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 32, 24, 329, 257, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
GUICtrlSetData($Edit1, "AEdit1")
GUISetState(@SW_SHOW)


Local $ostyle = _GetStyle($Form1, $Edit1)
ConsoleWrite($ostyle & @LF)
$ostyle = BitAND($ostyle, BitNOT($ES_READONLY)); This removes the style
ConsoleWrite($ostyle & @LF)
_SetStyle($Form1, $Edit1, $ostyle)


Sleep(2000)
;GUICtrlSetState( $Edit1, $GUI_FOCUS); shows white on one line

;GUISetState(@SW_HIDE); shows all white
;GUISetState(@SW_SHOW); with above

GUICtrlSetState( $Edit1, BitOr($GUI_SS_DEFAULT_EDIT, $ostyle)); turns all white

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
   ;;;;;;;
    EndSelect
WEnd
Exit

Func _GetStyle($title, $GuiCtrlRef)
    Local $foo = ControlGetHandle($title, "", $GuiCtrlRef)
    Local $style = DllCall("user32.dll","Long","GetWindowLong","hWnd",$foo,"int",-16)
    Return $style[0]
EndFunc

Func _SetStyle($title, $GuiCtrlRef, $style)
    Local $foo = ControlGetHandle($title, "", $GuiCtrlRef)
    Local $scall = DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $foo, "int", -16, "long", $style);remove Style from old style
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

after further reading at MSDN i figured out that can't do it that way with edit control

This works

#include <GUIConstants.au3>

Global Const $EM_SETREADONLY = 0xCF

; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 400, 500, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 32, 24, 329, 257, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL))
GUICtrlSetData($Edit1, "AEdit1")
$btn_set = GUICtrlCreateButton("Read Only", 10, 400, 120, 25)
$btn_unset = GUICtrlCreateButton("Editable", 140, 400, 120, 25)
GUISetState(@SW_SHOW)
GUICtrlSendMsg($Edit1, $EM_SETREADONLY, False, 0)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $btn_set
            GUICtrlSendMsg($Edit1, $EM_SETREADONLY, True, 0)
        Case $msg = $btn_unset
            GUICtrlSendMsg($Edit1, $EM_SETREADONLY, False, 0)
        Case Else
        ;;;;;;;
    EndSelect
WEnd
Exit
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...