VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Extend the function of Multi Line Text Control with SendMessage Fucntion..Must Visit.

by SYED ZUBAIR ALI (7 Submissions)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 8th October 2009
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Extend the function of Multi Line Text Control with SendMessage Fucntion..Must Visit.

API Declarations


'-------------------------------
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, IParam As Any) As Long

Public Const EM_GETFIRSTVISIBLELINE = &HCE
Public Const EM_GETLINE = &HC4
Public Const EM_GETLINECOUNT = &HBA
''Now switch to form and paste this code in General Decelartion
'--------------------------------------------------------------
Dim m_sLineString As String * 1056
Dim m_IngRet As Long
Dim m_SretString As String

Rate Extend the function of Multi Line Text Control with SendMessage Fucntion..Must Visit.



'Another Text box and Name it txtLineNumberChange
'Another Text box and Name it txtNumberofLines
'Another Text box and Name it txtLineFromFile
'Another Text box and Name it txtFirstLineVisible
'Take Updown1 Control Set the properties min 0 and max 100 and attach it with 'txtlinenumberchange
'Take Timer Control make is Enable=False and Interval=3500
Take A Command Button,Name it cbLoadFile, Caption it Load.
'Take another Command Button, Name it cmbUpdate and caption it Update
'Take another Command button, Caption it Quit
'Also take Label Boxes and caption it according to ur will and keep them with 'text box controls
'-----------------------------------------
'Now Paste this Code......ENjoy!!!!!!!!! and any query plz email 'me:[email protected]

-----------------------------
Private Sub cbLoadFile_Click()
Label1.Caption = "Wait - File is Loading |||||||||||||||||||||||||||||"
Screen.MousePointer = vbHourglass
Timer1.Enabled = True
cbLoadFile.Enabled = False



End Sub

Private Function ReadLine(iLine As Integer) As String
Dim m_IngRet As Long
m_sLineString = Space$(1056)
m_IngRet = SendMessage(txtMultiLine.hwnd, EM_GETLINE, iLine, ByVal m_sLineString)
ReadLine = m_sLineString


End Function

Private Sub CountLineS()
m_IngRet = SendMessage(txtMultiLine.hwnd, EM_GETLINECOUNT, 0, 0)
txtNumberofLines.Text = Str$(m_IngRet)

End Sub

Private Function ReadFirstVisibleLine() As Integer
ReadFirstVisibleLine = SendMessage(txtMultiLine.hwnd, EM_GETFIRSTVISIBLELINE, 0, 0)


End Function

Private Sub cmbUpdate_Click()
txtFirstVisibleLine.Text = ReadLine(ReadFirstVisibleLine())
'cmbUpdate.Enabled = False

End Sub

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Timer1_Timer()
Screen.MousePointer = vbDefault
Label1.Caption = "Successfully Loaded Text File."

On Error Resume Next
Dim iHandle As Integer
Dim iFileString As String
Dim iLine As String
iHandle = FreeFile
Open "C:\Documents and Settings\Xone\My Documents\OFFISETU\OFFICE\binder.txt" For Input As #iHandle
Do While Not EOF(iHandle)
Line Input #iHandle, sLine
iFileString = iFileString + sLine + vbCr + vbLf
Loop
Close #iHandle
txtMultiLine.Text = iFileString
Call txtLineNumberChange_Change
CountLineS
UpDown1.Min = 1
UpDown.Max = m_IngRet
UpDown1.Value = 1
cmbUpdate.Enabled = True
Timer1.Enabled = False
End Sub

Private Sub txtLineNumberChange_Change()
txtLineFromFile.Text = ReadLine(Val(txtLineNumberChange.Text) - 1)

End Sub

Private Sub UpDown1_Change()
txtLineNumberChange.Text = Str$(UpDown1.Value)
If Val(txtLineNumberChange.Text) > Val(txtNumberofLines.Text) Then
MsgBox "Irr Regular Line Number!!", vbCritical, "In-Valid Line Number."
txtLineNumberChange.Text = 1
End If

End Sub


Download this snippet    Add to My Saved Code

Extend the function of Multi Line Text Control with SendMessage Fucntion..Must Visit. Comments

No comments have been posted about Extend the function of Multi Line Text Control with SendMessage Fucntion..Must Visit.. Why not be the first to post a comment about Extend the function of Multi Line Text Control with SendMessage Fucntion..Must Visit..

Post your comment

Subject:
Message:
0/1000 characters