气泡提示框(ToolTip)上Option Explicit
Private Declare Function CreateWindowEx Lib "User32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function SendMessageAny Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DestroyWindow Lib "User32" (ByVal hWnd As Long) As Long
'Private Declare Function GetClientRect Lib "User32" (ByVal hWnd As Long, lpRect As RECT) As LongPrivate Const WM_USER = &H400
Private Const CW_USEDEFAULT = &H80000000
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOPMOST = -1Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End TypePrivate Const TTS_NOPREFIX = &H2
Private Const TTF_TRANSPARENT = &H100
Private Const TTF_CENTERTIP = &H2
Private Const TTM_ADDTOOLA = (WM_USER + 4)
Private Const TTM_ACTIVATE = WM_USER + 1
Private Const TTM_UPDATETIPTEXTA = (WM_USER + 12)
Private Const TTM_SETMAXTIPWIDTH = (WM_USER + 24)
Private Const TTM_SETTIPBKCOLOR = (WM_USER + 19)
Private Const TTM_SETTIPTEXTCOLOR = (WM_USER + 20)
Private Const TTM_SETTITLE = (WM_USER + 32)
Private Const TTS_BALLOON = &H40
Private Const TTS_ALWAYSTIP = &H1
Private Const TTF_SUBCLASS = &H10
Private Const TOOLTIPS_CLASSA = "tooltips_class32"Private Type TOOLINFO
    lSize As Long
    lFlags As Long
    lHwnd As Long
    lId As Long
    lpRect As RECT
    hInstance As Long
    lpStr As String
    lParam As Long
End TypePrivate mvarBackColor As Long 'local copy
Private mvarTitle As String 'local copy
Private mvarForeColor As Long 'local copy
Private mvarParentControl As Object 'local copy
Private mvarIcon As ttIconType 'local copy
Private mvarCentered As Boolean 'local copy
Private mvarStyle As ttStyleEnum  'local copy
Private mvarTipText As StringPublic Enum ttIconType
    TTNoIcon = 0
    TTIconInfo = 1
    TTIconWarning = 2
    TTIconError = 3
End EnumPublic Enum ttStyleEnum
    TTStandard
    TTBalloon
End EnumPrivate lHwnd As Long
Private Ti As TOOLINFOPublic Property Let Style(ByVal vData As ttStyleEnum)
    mvarStyle = vData
End PropertyPublic Property Get Style() As ttStyleEnum
    Style = mvarStyle
End PropertyPublic Property Let Centered(ByVal vData As Boolean)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Centered = 5
    mvarCentered = vData
End PropertyPublic Property Get Centered() As Boolean
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.Centered
    Centered = mvarCentered
End Property
       以上代码来自: SourceCode Explorer(源代码数据库)
           复制时间: 2002-06-16 22:13:08
           当前版本: 1.0.707
               作者: Shawls
           个人主页: Http://Shawls.Yeah.Net
             E-Mail: [email protected]
                 QQ: 9181729

解决方案 »

  1.   

    气泡提示框(ToolTip)中Public Function Create() As Boolean
        Dim lpRect As RECT
        Dim lWinStyle As Long
        
        If lHwnd <> 0 Then
            DestroyWindow lHwnd
        End If
        
        lWinStyle = TTS_ALWAYSTIP Or TTS_NOPREFIX
        
        ''create baloon style if desired
        If mvarStyle = TTBalloon Then lWinStyle = lWinStyle Or TTS_BALLOON
        
        ''the parent control has to have been set first
        If Not mvarParentControl Is Nothing Then
            lHwnd = CreateWindowEx(0&, _
                        TOOLTIPS_CLASSA, _
                        vbNullString, _
                        lWinStyle, _
                        CW_USEDEFAULT, _
                        CW_USEDEFAULT, _
                        CW_USEDEFAULT, _
                        CW_USEDEFAULT, _
                        mvarParentControl.hWnd, _
                        0&, _
                        App.hInstance, _
                        0&)
                        
            ''make our tooltip window a topmost window
            SetWindowPos lHwnd, _
                HWND_TOPMOST, _
                0&, _
                0&, _
                0&, _
                0&, _
                SWP_NOACTIVATE Or SWP_NOSIZE Or SWP_NOMOVE
                        
            ''get the rect of the parent control
            GetClientRect mvarParentControl.hWnd, lpRect
            
            ''now set our tooltip info structure
            With Ti
                ''if we want it centered, then set that flag
                If mvarCentered Then
                    .lFlags = TTF_SUBCLASS Or TTF_CENTERTIP
                Else
                    .lFlags = TTF_SUBCLASS
                End If
                
                ''set the hwnd prop to our parent control's hwnd
                .lHwnd = mvarParentControl.hWnd
                .lId = 0
                .hInstance = App.hInstance
                '.lpstr = ALREADY SET
                .lpRect = lpRect
            End With
            
            ''add the tooltip structure
            SendMessageAny lHwnd, TTM_ADDTOOLA, 0&, Ti
            
            ''if we want a title or we want an icon
            If mvarTitle <> vbNullString Or mvarIcon <> TTNoIcon Then
                SendMessageAny lHwnd, TTM_SETTITLE, CLng(mvarIcon), ByVal mvarTitle
            End If
            
            If mvarForeColor <> Empty Then
                SendMessageAny lHwnd, TTM_SETTIPTEXTCOLOR, mvarForeColor, 0&
            End If
            
            If mvarBackColor <> Empty Then
                SendMessageAny lHwnd, TTM_SETTIPBKCOLOR, mvarBackColor, 0&
            End If
            
        End If
    End FunctionPublic Property Set ParentControl(ByVal vData As Object)
    'used when assigning an Object to the property, on the left side of a Set statement.
    'Syntax: Set x.ParentControl = Form1
        Set mvarParentControl = vData
    End PropertyPublic Property Get ParentControl() As Object
    'used when retrieving value of a property, on the right side of an assignment.
    'Syntax: Debug.Print X.ParentControl
        Set ParentControl = mvarParentControl
    End Property
           以上代码来自: SourceCode Explorer(源代码数据库)
               复制时间: 2002-06-16 22:13:51
               当前版本: 1.0.707
                   作者: Shawls
               个人主页: Http://Shawls.Yeah.Net
                 E-Mail: [email protected]
                     QQ: 9181729
      

  2.   

    气泡提示框(ToolTip)下Public Property Let Icon(ByVal vData As ttIconType)
    'used when assigning a value to the property, on the left side of an assignment.
    'Syntax: X.Icon = 5
        mvarIcon = vData
        If lHwnd <> 0 And mvarTitle <> Empty And mvarIcon <> TTNoIcon Then
            SendMessageAny lHwnd, TTM_SETTITLE, CLng(mvarIcon), ByVal mvarTitle
        End IfEnd PropertyPublic Property Get Icon() As ttIconType
    'used when retrieving value of a property, on the right side of an assignment.
    'Syntax: Debug.Print X.Icon
        Icon = mvarIcon
    End Property
    Public Property Let ForeColor(ByVal vData As Long)
    'used when assigning a value to the property, on the left side of an assignment.
    'Syntax: X.ForeColor = 5
        mvarForeColor = vData
        If lHwnd <> 0 Then
            SendMessageAny lHwnd, TTM_SETTIPTEXTCOLOR, mvarForeColor, 0&
        End IfEnd PropertyPublic Property Get ForeColor() As Long
    'used when retrieving value of a property, on the right side of an assignment.
    'Syntax: Debug.Print X.ForeColor
        ForeColor = mvarForeColor
    End PropertyPublic Property Let Title(ByVal vData As String)
    'used when assigning a value to the property, on the left side of an assignment.
    'Syntax: X.Title = 5
        mvarTitle = vData
        If lHwnd <> 0 And mvarTitle <> Empty And mvarIcon <> TTNoIcon Then
            SendMessageAny lHwnd, TTM_SETTITLE, CLng(mvarIcon), ByVal mvarTitle
        End If
    End PropertyPublic Property Get Title() As String
    'used when retrieving value of a property, on the right side of an assignment.
    'Syntax: Debug.Print X.Title
        Title = Ti.lpStr
    End PropertyPublic Property Let BackColor(ByVal vData As Long)
    'used when assigning a value to the property, on the left side of an assignment.
    'Syntax: X.BackColor = 5
        mvarBackColor = vData
        If lHwnd <> 0 Then
            SendMessageAny lHwnd, TTM_SETTIPBKCOLOR, mvarBackColor, 0&
        End If
        
    End PropertyPublic Property Get BackColor() As Long
    'used when retrieving value of a property, on the right side of an assignment.
    'Syntax: Debug.Print X.BackColor
        BackColor = mvarBackColor
    End PropertyPublic Property Let TipText(ByVal vData As String)
    'used when assigning a value to the property, on the left side of an assignment.
    'Syntax: X.TipText = 5
        Ti.lpStr = vData
        If lHwnd <> 0 Then
            SendMessageAny lHwnd, TTM_UPDATETIPTEXTA, 0&, Ti
        End If
        
    End PropertyPublic Property Get TipText() As String
    'used when retrieving value of a property, on the right side of an assignment.
    'Syntax: Debug.Print X.TipText
        TipText = mvarTipText
    End PropertyPrivate Sub Class_Terminate()
        If lHwnd <> 0 Then
            DestroyWindow lHwnd
        End If
    End Sub       以上代码来自: SourceCode Explorer(源代码数据库)
               复制时间: 2002-06-16 22:14:02
               当前版本: 1.0.707
                   作者: Shawls
               个人主页: Http://Shawls.Yeah.Net
                 E-Mail: [email protected]
                     QQ: 9181729放到类里面调用
    dim tbtoptip as new class1
        TBTopTip.Style = TTBalloon
        TBTopTip.TipText = tbTipText
        Set TBTopTip.ParentControl = DrawPIC
        TBTopTip.Title = tbTitle
        TBTopTip.Icon = 0
        TBTopTip.Create