hzxymkb 发表于 2010-1-8 13:12:32

鼠标经过按钮提示的讨论

怎么样能让鼠标经过某个按钮时出现这样的提示?

还有,可不可以让提示的文字在标题上显示呢?

maxkingmax 发表于 2010-1-8 13:45:42

按钮上显示提示
tooltip()

sanmoking 发表于 2010-1-8 14:20:35

我比较喜欢用状态栏提示文字这种方式,下面是随手写的一个界面提示的例子,用tooltip有时候太麻烦,而且容易遮挡界面。。。


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 228, 128, 192, 124)
$Button1 = GUICtrlCreateButton("1", 8, 8, 65, 25)
$Button2 = GUICtrlCreateButton("2", 80, 8, 65, 25)
$Button3 = GUICtrlCreateButton("3", 152, 8, 65, 25)
$Button4 = GUICtrlCreateButton("4", 8, 40, 65, 25)
$Button5 = GUICtrlCreateButton("5", 80, 40, 65, 25)
$Button6 = GUICtrlCreateButton("6", 152, 40, 65, 25)
$Button7 = GUICtrlCreateButton("7", 8, 72, 65, 25)
$Button8 = GUICtrlCreateButton("8", 80, 72, 65, 25)
$Button9 = GUICtrlCreateButton("9", 152, 72, 65, 25)
$Label1 = GUICtrlCreateLabel("状态栏", 8, 104, 140, 17)
GUICtrlSetColor(-1, 0x0000FF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$Lastcontrol = 0
While 1
        $nMsg = GUIGetMsg()
        $mouse = GUIGetCursorInfo($Form1)
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
        Switch $mouse;鼠标移到指定控件显示提示文字,可增加很多
                Case $Button1
                        If $mouse <> $Lastcontrol Then
                                GUICtrlSetData($Label1, "按钮1") ;给出工具提示
                                $Lastcontrol = $mouse;记录最后一次鼠标放置的控件
                        EndIf
                Case $Button2
                        If $mouse <> $Lastcontrol Then;必须加这个验证一下上次鼠标放置的控件是不是当前控件,否则会一直更新提示文字
                                GUICtrlSetData($Label1, "按钮2")
                                $Lastcontrol = $mouse
                        EndIf
                Case $Button3
                        If $mouse <> $Lastcontrol Then
                                GUICtrlSetData($Label1, "按钮3")
                                $Lastcontrol = $mouse
                        EndIf
                Case $Button4
                        If $mouse <> $Lastcontrol Then
                                GUICtrlSetData($Label1, "按钮4") ;给出工具提示
                                $Lastcontrol = $mouse;记录最后一次鼠标放置的控件
                        EndIf
                Case $Button5
                        If $mouse <> $Lastcontrol Then;必须加这个验证一下上次鼠标放置的控件是不是当前控件,否则会一直更新提示文字
                                GUICtrlSetData($Label1, "按钮5")
                                $Lastcontrol = $mouse
                        EndIf
                Case $Button6
                        If $mouse <> $Lastcontrol Then
                                GUICtrlSetData($Label1, "按钮6")
                                $Lastcontrol = $mouse
                        EndIf                               
;~                 Case Else
;~                         If $mouse <> $Lastcontrol Then
;~                                 GUICtrlSetData($Label1, "这里是状态栏提示文字。。。。。")
;~                                 $Lastcontrol = $mouse
;~                         EndIf
        EndSwitch
WEnd
页: [1]
查看完整版本: 鼠标经过按钮提示的讨论