Private Declare Function SendMessageRef Lib "user32.dll" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal MSG As Long, wParam As Long, lParam As Long) As Long
Private Const EM_GETSEL = &HB0
Private Function LWORD(ByVal LongValue As Long) As Integer
If (LongValue And &HFFFF&) > &H7FFF Then
LWORD = (LongValue And &HFFFF&) - &H10000
Else
LWORD = LongValue And &HFFFF&
End If
End Function
Private Function HWORD(ByVal LongValue As Long) As Integer
HWORD = (LongValue And &HFFFF0000) \ &H10000
End Function
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim strIndex As Long, endIndex As Long, rc As Long, txt As String
If Me.Text1.SelLength > 0 Then
rc = SendMessageRef(Me.Text1.hWnd, EM_GETSEL, strIndex, endIndex)
txt = Me.Text1.Text
strIndex = strIndex + 1
endIndex = endIndex + 1
Me.Label1.Caption = Mid(txt, Me.Text1.SelStart + 1, Me.Text1.SelLength + 1)
Else
Me.Label1.Caption = ""
End If
End Sub |