This is a function that will retrieve the first line of an edit box by passing the handle. It works great on Windows 2000, but crashes VB on Windows 98. WHY?!?!
I really need to get this working on Windows 9x!Code:Public Function GetLineText(hwnd As Long) As String Dim li As Long, liCnt As Long, CurrentLine As String, result As Long li = SendMessage(hwnd, EM_LINEINDEX, 1, ByVal 0&) liCnt = SendMessage(hwnd, EM_LINELENGTH, li, ByVal 0&) CurrentLine = MKI(CInt(liCnt)) & String(liCnt + 1, 0) result = SendMessage(hwnd, EM_GETLINE, 1, ByVal CurrentLine) CurrentLine = Left(CurrentLine, liCnt) GetLineText = CurrentLine End Function Public Function MKI(x As Integer) As String 'This Function Sets up the EM_GETLINE Buffer. Dim y As Long y = CLng(x) And &HFFFF& MKI = Chr(y And &HFF&) & Chr((y And &HFF00&) \ &H100&) End Function
Thanks,
Jordan




Reply With Quote