Jump to content
Xtreme .Net Talk

kevin_lam

Members
  • Posts

    1
  • Joined

  • Last visited

kevin_lam's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi all, I have been trying to use SendMessage to determine no. of characters in each line within a textbox. API Declaration Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Int32, ByVal lParam As Object) As Long Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As System.IntPtr, ByVal wMsg As Long, ByVal wParam As Int32, ByRef lParam As String) As Long Private Const EM_GETLINE As Int32 = &HC4 Private Const EM_GETLINECOUNT As Int32 = &HBA Private Const EM_LINEINDEX As Int32 = &HBB Private Const EM_LINELENGTH As Int32 = &HC1 Code to determine length of each line Dim lngCount As Long, lngLineIndex As Long, lngLength As Long Dim i As Int32 Dim strBuffer As String 'Get Line count lngCount = SendMessage(txtContent1.Handle, EM_GETLINECOUNT, 0, IntPtr.Zero) txtCount.Text = "" txtLineCount.Text = "" With txtContent1 For i = 0 To lngCount - 1 'Get line index lngLineIndex = SendMessage(.Handle, EM_LINEINDEX, i, Nothing) 'lngLineIndex ALWAYS return 0 !! 'get line length lngLength = SendMessage(.Handle, EM_LINELENGTH, lngLineIndex, Nothing) 'lngLength ALWAYS return length of 1st line 'resize buffer strBuffer = Space(lngLength) 'get line text SendMessageStr(.Handle, EM_GETLINE, i, strBuffer) ''Number each line txtLineCount.Text &= "line " & i & " : " & strBuffer.Length & ", " & lngLength & ControlChars.CrLf Next End With Can someone help me to take a look the code and see what's wrong ? Thanks :o
×
×
  • Create New...