基本所有可视的控件都有ToolTipText属性,目的是当鼠标移动到停留在一个控件时出现文本提示,但这种方法不能另我满意我的想法是1:鼠标移动到任何控件时,[立即]根据其控件name\caption等属性生成一段提示文本,然后[立即]弹出效果不错的ToolTipText提示但着手做起来碰到以下难点1:窗体有很多控件,用form_mousemove事件做由于控件盖住了窗体,是无法触发这个事件的,必须为每个控件组都添加obj_mousemove事件,实在现的太笨拙了2:我想过用TIMER控件+screen.ActiveControl解决上述问题,但是这个screen.ActiveControl对象指的是获得焦点的对象,但仅仅鼠标靠近目标控件而那个控件是获得不到焦点的3:想支持多个窗体都共享这个高级ToolTipText提示函数,不至于每个窗体都得重写一遍,就算调用其他窗体的这个函数,但那个窗体中的控件视图是无法超过一个窗体容器的
学艺不精,敬请各位赐教方法或给予相关源程序、教程。巨谢

解决方案 »

  1.   

    WindowFromPoint的例子:'Example Name:WindowFromPoint
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal wOptions As Long, ByVal lpRect As Any, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As POINTAPI) As Long
    Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim Pt As POINTAPI, mWnd As Long, WR As RECT, nDC As Long
        Dim TextSize As POINTAPI, CX As Long, CY As Long
        'Get the current cursor position
        GetCursorPos Pt
        'Get the window under the cursor
        mWnd = WindowFromPoint(Pt.X, Pt.Y)
        'Get the window's position
        GetWindowRect mWnd, WR
        'Get the window'zs device context
        nDC = GetWindowDC(mWnd)
        'Get the height and width of our text
        GetTextExtentPoint32 nDC, "Hello !", Len("Hello !"), TextSize
        For CX = 1 To WR.Right - WR.Left Step TextSize.X
            For CY = 1 To WR.Bottom - WR.Top Step TextSize.Y
                'Draw the text on the window
                ExtTextOut nDC, CX, CY, 0, ByVal 0&, "Hello !", Len("Hello !"), ByVal 0&
            Next
        Next
    End Sub
    Private Sub Form_Paint()
        Me.CurrentX = 0
        Me.CurrentY = 0
        Me.Print "Click on this form," + vbCrLf + "Hold the mouse button," + vbCrLf + "drag the mouse over another window," + vbCrLf + "release the mouse button" + vbCrLf + "and see what happens!"
    End Sub
      

  2.   

    各位请问:如果我用的datagrid控件中的某一字段为memo型的(有很多字节),
    如何实现类似tiptext的效果