找回密码
 加入
搜索
查看: 8700|回复: 13

[AU3基础] 输入框禁止输入后 自己设置的颜色也变灰色了。。

 火.. [复制链接]
发表于 2010-10-9 19:25:32 | 显示全部楼层 |阅读模式
如何让输入框 锁定后 让字体颜色依然显示为 红色 。。。。。。。。
代码如下  INPUT锁定后 原本红色的字体也变成了灰色。。。。。。。。。。。。。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 322, 99, 192, 124)
$Input1 = GUICtrlCreateInput("测试显示", 16, 16, 289, 21)
 GUICtrlSetColor(-1, 0xff0000)   ; Red
$Button1 = GUICtrlCreateButton("保存", 64, 56, 75, 25)
$Button2 = GUICtrlCreateButton("重置", 168, 56, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                        Case $Button1
                                                GUICtrlSetState($Input1, $GUI_DISABLE)

                Case $Button2
                                        GUICtrlSetState($Input1, $GUI_ENABLE)
                        GUICtrlSetData($Input1,"测试显示")

        EndSwitch
WEnd
发表于 2010-10-9 20:42:10 | 显示全部楼层
我也遇到过这种情况
发表于 2010-10-10 00:56:42 | 显示全部楼层
帮你改了一下,楼上二位可参考:

;注意,此时不要用input,而用edit,并改变风格即可
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 322, 99, 192, 124)
$Input1 = GUICtrlCreateEdit("测试显示", 16, 16, 289, 21,$ES_AUTOHSCROLL+$ES_AUTOVSCROLL)
 GUICtrlSetColor(-1, 0xff0000)   ; Red
$Button1 = GUICtrlCreateButton("保存", 64, 56, 75, 25)
$Button2 = GUICtrlCreateButton("重置", 168, 56, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                        Case $Button1
                                                GUICtrlSetStyle($Input1, $ES_READONLY+$ES_AUTOHSCROLL+$ES_AUTOVSCROLL)

                Case $Button2
                                        GUICtrlSetStyle($Input1, $ES_AUTOHSCROLL+$ES_AUTOVSCROLL)
                        GUICtrlSetData($Input1,"测试显示")

        EndSwitch
WEnd

评分

参与人数 1金钱 +30 收起 理由
afan + 30

查看全部评分

 楼主| 发表于 2010-10-10 21:41:11 | 显示全部楼层
支持一下 。。 。方法不错。嘿嘿。。。。。
发表于 2010-10-10 21:49:58 | 显示全部楼层
变通一下还是不错的。。。。。。只是感觉有点逃避问题
发表于 2010-10-10 22:11:33 | 显示全部楼层
4#改标题。

变通一下还是不错的。。。。。。只是感觉有点逃避问题
karlpopper 发表于 2010-10-10 21:49


这个应该不是逃避问题吧~
禁止输入有多种方法,而LZ使用的刚好是影响字体状态的 GUICtrlSetState($Input1, $GUI_DISABLE)
本身就是不对的。3#的 $ES_READONLY 无疑是很好的方法。
发表于 2010-10-10 22:21:38 | 显示全部楼层
用 disable 的方法会使字体变灰,背景变暗。
用 readonly 的方法会保持字体颜色,但背景变暗。
如果想禁止编辑,同时保持字体不变,背景不变,请参考
http://www.autoitx.com/forum.php ... 8941&highlight=
发表于 2010-10-10 22:32:24 | 显示全部楼层
用 disable 的方法会使字体变灰,背景变暗。
用 readonly 的方法会保持字体颜色,但背景变暗。
如果想禁止 ...
xianhou 发表于 2010-10-10 22:21



    $ES_READONLY 风格与 非 $ES_READONLY 风格背景色不同,我认为其一目的是让用户能更好的识别可写操作,减少没必要的操作,不觉得这样更好(⊙_⊙)?
   不过如果用来伪装倒是( ^_^ )不错~
发表于 2010-10-10 22:48:40 | 显示全部楼层
回复 8# afan

另外一个策略

http://www.autoitx.com/forum.php ... 8941&highlight=

2楼
发表于 2010-10-11 10:52:21 | 显示全部楼层
学习一下,看看内容,等钱多了在下载
发表于 2010-10-11 15:22:40 | 显示全部楼层
你提出问题
从热心的坛友那又学到东西了
发表于 2010-10-14 10:39:59 | 显示全部楼层
本帖最后由 netegg 于 2010-10-14 10:41 编辑
#include <GuiEdit.au3>
#include <WinAPI.au3> ; used for Lo/Hi word
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)

$Debug_Ed = False ; Check ClassName being passed to Edit functions, set to True and use a handle to another control to see it work

Global $hEdit

_Example1()

Func _Example1()
        Local $hGUI

        ; Create GUI
        $hGUI = GUICreate("Edit Create", 400, 300)
        $hEdit = _GUICtrlEdit_Create($hGUI, "This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
        GUISetState()

        GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

        
        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>_Example1



Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
        #forceref $hWnd, $iMsg
        Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
        If Not IsHWnd($hEdit) Then $hWndEdit = GUICtrlGetHandle($hEdit)
        $hWndFrom = $ilParam
        $iIDFrom = _WinAPI_LoWord($iwParam)
        $iCode = _WinAPI_HiWord($iwParam)
        Switch $hWndFrom
                Case $hEdit, $hWndEdit
                        Switch $iCode
                                Case $EN_CHANGE
                                        _GUICtrlEdit_SetText($hEdit, '')
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

评分

参与人数 1金钱 +25 收起 理由
afan + 25

查看全部评分

发表于 2010-10-14 11:01:10 | 显示全部楼层
不错,学习一下。。
发表于 2010-10-14 11:20:08 | 显示全部楼层
3楼的方法不错啊~借鉴了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-28 23:54 , Processed in 0.099577 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表