问:如何实现鼠标取词? 答:所要用到的函数、常量、类型 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function WindowFromPoint Lib "user32" (ByVal x As Long, ByVal y As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Const WM_GETTEXT = &HD Private Const WM_SETTEXT = &HC Private Type POINTAPI x As Long y As Long End Type Private Sub Form_Load() End Sub Private Sub Timer1_Timer() Dim Shu As POINTAPI Dim Str As String * 300 GetCursorPos Shu SendMessage WindowFromPoint(Shu.x, Shu.y), WM_GETTEXT, 299, ByVal Str Label1.Caption = Str End Sub 根据代码加入相应控件,timer1的interval的属性为100再加入把当前窗口置顶就是一个完美的简单的取词工具了!
|