haorui658 发表于 2011-6-29 15:35:56

Button设置了点击后有颜色后怎么恢复默认的背景色

如标题, 我创建了一个button 点击后用GUICtrlSetBkColor ( controlID, backgroundcolor )设定了颜色, 我想恢复原来的样子(貌似比较有立体感)怎么办呢?
用什么函数呢?

haorui658 发表于 2011-6-30 08:29:27

{:face (319):}居然没有人回答, 不要告诉我要把那个按钮删掉, 再创建个一样的

502762378 发表于 2011-6-30 09:42:02

你又没有代码,没有人知道你想要的结果,
如果是颜色的话,你再用GUICtrlSetBkColor 设置回来不就可以了
如果还有立体感什么的话,你看之前设置button的样式

haorui658 发表于 2011-6-30 12:50:25

#include <GUIConstantsEx.au3>
$Form1_1 = GUICreate("Tool box", 261, 454, 386, 203)
$Button7 = GUICtrlCreateButton("Device infomation", 16, 304, 225, 33)
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
               
                Case $Button7
                        GUICtrlSetBkColor($Button7, 0xAAAAAA)

                        MsgBox(0,0,"点击确定变回原样")
                       
                        ;GUICtrlSetBkColor($Button7, 0xFFFFFF)这里该怎么写变回原来的?
        EndSwitch
WEnd就是上面的代码, 路过的和3楼都看一下

3mile 发表于 2011-6-30 13:47:40

不大明白你的意思.想要完美的话,拦截WM_DRAWITEM消息自绘按钮吧.
如果想要简单的实现的话,试下以下内容.
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

$Form1_1 = GUICreate("Tool box", 261, 454, 386, 203)
$Button7 = GUICtrlCreateButton("Device infomation", 16, 304, 225, 33,0x8000)
GUISetState(@SW_SHOW)
While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
               
                Case $Button7
                        ;GUICtrlSetBkColor($Button7, 0xAAAAAA)                                               
                                                $Button_temp=GUICtrlCreateButton("Device infomation", 16, 304, 225, 33)
                                                GUICtrlSetState($Button7,$GUI_HIDE)
                                                GUICtrlSetBkColor(-1,0xAAAAAA)
                        MsgBox(0,0,"点击确定变回原样")
                                                GUICtrlDelete($Button_temp)
                                                GUICtrlSetState($Button7,$GUI_SHOW)
                        ;GUICtrlSetBkColor($Button7, 0xF0F0F0);这里该怎么写变回原来的?
      EndSwitch
WEnd

menfan1 发表于 2011-6-30 13:55:47

$GUI_HIDE+$GUI_SHOW,呵呵,不错哈

kevinch 发表于 2011-6-30 13:59:46

顺便问下,au3有鼠标移动之类的事件没?

haorui658 发表于 2011-7-1 12:45:46

回复 5# 3mile


    你的方法曲线实现了我说的效果, 但是我比较好奇, button一旦更改了背景色就不可以还原成以前的?

haorui658 发表于 2011-7-4 08:29:29

伤心了, 没人理了

hzxymkb 发表于 2011-7-4 12:14:11

没有代码贴出来,谁知道你想要什么效果!

haorui658 发表于 2011-7-4 12:47:31

本帖最后由 haorui658 于 2011-7-4 12:49 编辑

代码在四楼啊. 就是想那个button回到初始的状态和颜色, 相当于撤销第12行代码GUICtrlSetBkColor($Button7, 0xAAAAAA)的作用
页: [1]
查看完整版本: Button设置了点击后有颜色后怎么恢复默认的背景色