amadisyeh 发表于 2010-8-31 22:58:39

請問如何改變按過的 按鈕的顏色 [已解決]

本帖最后由 amadisyeh 于 2010-8-31 23:19 编辑

請問如何改變按過的 按鈕的顏色

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("Button Test", 0, -1)
;GUICtrlSetColor(-1,0x0200FB)

    GUISetState()      ; will display andialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
      $msg = GUIGetMsg()
      Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
        $Button_1 =GUICtrlSetColor(-1,0x0200FB)
        Run('Notepad.exe')    ; Will Run/Open Notepad
            Case $msg = $Button_2
        GUICtrlSetColor(-1, 0xcccccc)   
                MsgBox(0, 'Testing', 'Button 2 was pressed')    ; Will demonstrate Button 2 being pressed
      EndSelect
    WEnd
EndFunc   ;==>Example

我總是只能改變Button_2 的顏色
------------------------------------------------------------------------------
先用 Au3Info.exe 把 button 的 controlID 找出來並且填上就可以了
页: [1]
查看完整版本: 請問如何改變按過的 按鈕的顏色 [已解決]