Article ID: 110403
Article Last Modified on 12/9/2003
ret& = SendMessage(hWnd%, uMsg%, wParam%, lParam&)where:
ret& holds the return value of the function call.
hWnd% identifies the window handle that is to receive the message.
uMsg% the message to be sent (EM_SETREADONLY).
wParam% specifies whether to set or remove the read-only state of
the edit control. A value of TRUE sets the state to
read-only; a value of FALSE sets the state to read/write.
lParam& not used for this message, set its value to 0&.
The return value of this function is nonzero if the function was
successful, and it is zero if an error occurred.
Const WM_USER = &H400
Const EM_SETREADONLY = (WM_USER + 31)
' Enter the following Declare statement as one, single line:
Declare Function SendMessage Lib "User" (ByVal hWnd As Integer,
ByVal wMsg As Integer, ByVal wParam As Integer,
ByVal lParam As Any) As Long
NOTE: If you add the Const declarations to the .BAS module, you need to
delcare them as Global Const.
Sub Form_Load()
Dim TmpStr As String
Dim ret as Long
Open "C:\AUTOEXEC.BAT" For Input As #1
While Not Eof(1)
' Read a line of text in from the input file:
Line Input #1, TmpStr
' Append it to the text box, adding carriage return and line feed:
Text1.Text = Text1.Text & TmpStr & Chr$(13) & Chr$(10)
Wend
' Set the text box to read-only mode:
ret = SendMessage(Text1.hWnd, EM_SETREADONLY, True, 0&)
If ret = 0 Then ' Check the return value for error
MsgBox "Could Not Set Text Box to Read-Only."
End If
End Sub
Additional query words: 2.00 3.00
Keywords: KB110403