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

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

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

  14. While 1
  15.         $nMsg = GUIGetMsg()
  16.         Switch $nMsg
  17.                 Case $GUI_EVENT_CLOSE
  18.                         Exit
  19.                                         Case $Button1
  20.                                                 GUICtrlSetState($Input1, $GUI_DISABLE)

  21.                 Case $Button2
  22.                                         GUICtrlSetState($Input1, $GUI_ENABLE)
  23.                         GUICtrlSetData($Input1,"测试显示")

  24.         EndSwitch
  25. WEnd
复制代码
发表于 2010-10-9 20:42:10 | 显示全部楼层
我也遇到过这种情况
发表于 2010-10-10 00:56:42 | 显示全部楼层
帮你改了一下,楼上二位可参考:
[au3]
;注意,此时不要用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[/au3]

评分

参与人数 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 编辑
  1. #include <GuiEdit.au3>
  2. #include <WinAPI.au3> ; used for Lo/Hi word
  3. #include <WindowsConstants.au3>
  4. #include <GuiConstantsEx.au3>

  5. Opt('MustDeclareVars', 1)

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

  7. Global $hEdit

  8. _Example1()

  9. Func _Example1()
  10.         Local $hGUI

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

  15.         GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

  16.        
  17.         ; Loop until user exits
  18.         Do
  19.         Until GUIGetMsg() = $GUI_EVENT_CLOSE
  20.         GUIDelete()
  21. EndFunc   ;==>_Example1



  22. Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
  23.         #forceref $hWnd, $iMsg
  24.         Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
  25.         If Not IsHWnd($hEdit) Then $hWndEdit = GUICtrlGetHandle($hEdit)
  26.         $hWndFrom = $ilParam
  27.         $iIDFrom = _WinAPI_LoWord($iwParam)
  28.         $iCode = _WinAPI_HiWord($iwParam)
  29.         Switch $hWndFrom
  30.                 Case $hEdit, $hWndEdit
  31.                         Switch $iCode
  32.                                 Case $EN_CHANGE
  33.                                         _GUICtrlEdit_SetText($hEdit, '')
  34.                         EndSwitch
  35.         EndSwitch
  36.         Return $GUI_RUNDEFMSG
  37. 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, 2026-9-22 09:50 , Processed in 0.114906 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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