mpf5566 发表于 2013-11-13 10:45:13

_guitooltip_*类显示问题

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include<GuiButton.au3>
#include <GuiToolTip.au3>

Dim $handle3,$tip3
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 338, 275, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 32, 48, 105, 41)
                GUICtrlSetTip($Button1,"没有安装此客户端")
$Button2 = GUICtrlCreateButton("Button2", 184, 48, 113, 41)
                _GUICtrlButton_Enable($Button2,False)
                        GUICtrlSetTip($Button1,"没有安装此客户端");禁用控件无法显示TIP提示信息
$Button3 = GUICtrlCreateButton("Button3", 32, 136, 97, 41)
                $handle3=GUICtrlGetHandle($Button3)
                _GUICtrlButton_Enable($Button3,False)
                $tip3=_guitooltip_create($handle3,$TTS_ALWAYSTIP);$TTS_ALWAYSTIP这个参数写的是即使控件处于非活动状态,只要光标指向控件就能显示。
                _GUIToolTip_SetToolInfo($handle3,"没有安装此客户端")
                _GUIToolTip_PopUp($tip3)
$Button4 = GUICtrlCreateButton("Button4", 184, 136, 113, 41)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
我现在想实现的功能就是在控件被禁用的情况下(_GUICtrlButton_Enable($Button3,False)),当鼠标移动到该控件还是能显示冒泡提示,帮助文档的_guitooltip*例子没有。请大大帮忙谢谢。

mpf5566 发表于 2013-11-13 12:55:06

{:face (394):}发现自己帮助文档阅读能力好低.......还没整出来!!!

netegg 发表于 2013-11-15 03:22:22

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIToolTip.au3>

$Form1 = GUICreate("Form1", 954, 545, 192, 114)
GUISetState(@SW_SHOW)

Local $hToolTip = _GUIToolTip_Create($form1, $TTS_BALLOON)
_GUIToolTip_AddTool($hToolTip, 0, "hello world", $form1, 0, 0, 0, 0, 9)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
      Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

netegg 发表于 2013-11-15 03:23:14

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIToolTip.au3>

$Form1 = GUICreate("Form1", 954, 545, 192, 114)
GUISetState(@SW_SHOW)

Local $hToolTip = _GUIToolTip_Create($form1, $TTS_BALLOON)
_GUIToolTip_AddTool($hToolTip, 0, "hello world", $form1, 0, 0, 0, 0, 9)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
      Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

netegg 发表于 2013-11-15 03:29:08

#include <GuiToolTip.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $iIconID = 43
If @OSVersion == "WIN_VISTA" Then $iIconID = 51
Global $hIcon = _WinAPI_LoadShell32Icon($iIconID)


Global $hToolTip1 = _GUIToolTip_CreateToolTip(0, "Close tooltip to exit", "ToolTip 1", Default, _
      @DesktopWidth / 2, @DesktopHeight / 2 - 120, 2 + 16, 0xFF00, 0xFF0000, $hIcon)
_SetTipColors($hToolTip1, 0xFF00, 0xFF0000)

Global $hToolTip2 = _GUIToolTip_CreateToolTip(0, "UDF ToolTip", "ToolTip 2", 0, _
      @DesktopWidth / 2, @DesktopHeight / 2, 2 + 16, 0xFF0000, 0x00FF00, $hIcon)
_SetTipColors($hToolTip2, 0xFF0000, 0x00FF00)

Global $hToolTip3 = _GUIToolTip_CreateToolTip(0, "UDF ToolTip", "ToolTip 3", 0, _
      @DesktopWidth / 2, @DesktopHeight / 2 + 75, 2 + 16, 0, 0xFFFFFF)
_SetTipColors($hToolTip3, 0, 0xFFFFFF)

Global $hToolTip4 = _GUIToolTip_CreateToolTip(0, "", "ToolTip 4", 0, _
      @DesktopWidth / 2, @DesktopHeight / 2 + 130, 32 + 16, 0xFFFFFF, 0) ;
_SetTipColors($hToolTip4, 0xFFFFFF, 0)

_WinAPI_DestroyIcon($hIcon)

Do
    Sleep(10)
    Local $aPos = MouseGetPos()
    _GUIToolTip_TrackPosition($hToolTip4, $aPos + 10, $aPos + 20)
    _GUIToolTip_UpdateTipText($hToolTip4, 0, 0, "X: " & $aPos & " Y: " & $aPos)
Until BitAND(WinGetState($hToolTip1), 2) <> 2 ; exit if Tooltip not visible (closed by balloon tip button)

_GUIToolTip_Destroy($hToolTip1)
_GUIToolTip_Destroy($hToolTip2)
_GUIToolTip_Destroy($hToolTip3)
_GUIToolTip_Destroy($hToolTip4)

Func _GUIToolTip_CreateToolTip($hWnd, $sTitle, $sText, $iStyle = Default, $iX = -1, _
      $iY = -1, $iFlags = 0, $iColTxt = Default, $iColBk = Default, $iIcon = 0)
    ;Author: rover and et al.
    ;$iIcon Pre-defined icon to show next to the title: Requires a title.
    ;0 = No icon, 1 = Info icon, 2 = Warning icon, 3 = Error Icon
    ; From _GUIToolTip_SetTitle() remarks
    ; As of Windows XP SP2 and later, $iIcon can contain an HICON value.
    ; Any value greater than 3 is assumed to be an HICON.
    Local Const $CW_USEDEFAULT = 0x80000000
    If Not IsHWnd($hWnd) Or IsKeyword($hWnd) Then $hWnd = 0
    If IsKeyword($iX) Or $iX < 0 Or Not IsNumber($iX) Then $iX = 0
    If IsKeyword($iY) Or $iY < 0 Or Not IsNumber($iY) Then $iY = 0
    If IsKeyword($iFlags) Or $iFlags <= 0 Or Not IsNumber($iFlags) Then $iFlags = 32 + 8 + 1
    If IsKeyword($iStyle) Then $iStyle = BitOR($TTS_BALLOON, $TTS_CLOSE)
    Local $hTip = _WinAPI_CreateWindowEx($WS_EX_TOPMOST, "tooltips_class32", "", _
            BitOR($iStyle, $TTS_ALWAYSTIP, $TTS_NOPREFIX), _
            $CW_USEDEFAULT, $CW_USEDEFAULT, $CW_USEDEFAULT, $CW_USEDEFAULT, $hWnd)

    _GUIToolTip_AddTool($hTip, $hWnd, $sText, $hWnd, 0, 0, 0, 0, $iFlags, 0)
    If Number($iIcon) > 3 And @OSVersion = "WIN_XP" And Number(StringRight(@OSServicePack, 1)) < 2 Then $iIcon = 0
    If Not IsNumber($iIcon) Or $iIcon < 0 Then $iIcon = 0
    _GUIToolTip_SetTitle($hTip, $sTitle, $iIcon)
    If IsInt($iColTxt) Then _GUIToolTip_SetTipTextColor($hTip, $iColTxt)
    If IsInt($iColBk) Then _GUIToolTip_SetTipBkColor($hTip, $iColBk)

    If $hWnd = 0 Or $hWnd = -1 Or IsKeyword($hWnd) Then
      _GUIToolTip_TrackPosition($hTip, $iX, $iY)
      _GUIToolTip_TrackActivate($hTip, True, $hWnd, $hWnd)
      Return $hTip
    EndIf

    Return $hTip
EndFunc   ;==>_GUIToolTip_CreateToolTip

Func _SetTipColors($hWnd, $iBkColor, $iTxtColor)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hWnd, "wstr", "", "wstr", "")
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $TTM_SETTIPBKCOLOR, "int", _RGB2BGR($iBkColor), "int", 0)
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $TTM_SETTIPTEXTCOLOR, "int", _RGB2BGR($iTxtColor), "int", 0)
EndFunc   ;==>_SetTipColors

; #FUNCTION# =============================================================
; Name............: RGB2BGR
; Description.....: Convert a RGB color mode to a BGR color mode
; Syntax..........: RGB2BGR($sColor)
; Parameter(s)....: $sColor - The color in HEX value
; Return value(s).: Converted color in HEX value
; Requirement(s)..:
; Note(s).........:
; Author(s).......: Siao
; ========================================================================
Func _RGB2BGR($iColor)
    Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF)
EndFunc   ;==>_RGB2BGR

mpf5566 发表于 2013-11-15 09:59:40

回复 5# netegg
多谢论坛元老的答复,结合您的提示我去实现下功能看看。
页: [1]
查看完整版本: _guitooltip_*类显示问题