Closed infogulch closed 12 years ago
Wait, ReadOnly is already listed in the ControlStyles listing for CEditControl... but it's not working
Even something like GuiControl, -ReadOnly, Edit1
doesn't work and produces an ErrorLevel.
I tried a normal gui script (non-CGUI) which switches the ReadOnly state of an edit control with the above line and it works fine.
That is weird, are you sure you didn't make another error?
Yep, I just checked with your branch and it does the same thing. I'll make a simpler test case and try it again.
Yep, not working, in both my latest and your current.
x := new testgui()
x.show()
return
#Include <CGUI>
class testgui extends CGUI {
edt := this.AddControl("Edit", "edt", "readonly", "")
btn := this.AddControl("Button", "btn", "", "Switch")
btn_Click() {
this.edt.ReadOnly := !this.edt.ReadOnly
}
}
Edit: and it doesn't matter if it starts out readonly or not, the button doesn't change it.
Edit2: funny, Control doesn't report any errors and ControlGet reports that the change was applied properly...
confused
Yep pretty much:
Gui, Add, Edit, vedt readonly hwndedtHwnd
Gui, Add, Button, , Change
Gui, Show
return
ButtonChange:
ControlGet, get, Style, , , ahk_id %edtHwnd%
set := get & 0x800 ? "-0x800" : "+0x800"
msgbox % "before: " get & 0x800 "`nsetting: " set
Control, Style, % set, , ahk_id %edtHwnd%
return
It actually does toggle numerically. I.e. the style technically changes, but it has no effect... :-/
Aha! This works great:
Gui, Add, Edit, vedt readonly hwndedtHwnd
Gui, Add, Button, , Change
Gui, +LastFound
guiHwnd := WinExist()
Gui, Show
return
ButtonChange:
ControlGet, get, Style, , , ahk_id %edtHwnd%
SendMessage, 0xCF, % !(get & 0x800), , , ahk_id %edtHwnd%
return
I'll work on this and other SendMessage-dependent style changes next.
Agreed, it should be a property.