I wrote a RichTextBox-based app years ago and it works well. I recently found out that something is not quite right although it hasn't caused m any problems untill I used a very very large text.
I've collected the relative code from my app (the app is very large):
With the error checking (recently added) I get the following:
Native EM_REQUESTRESIZE Error: 5
Access is denied
Native EM_REQUESTRESIZE Error: 5
Access is denied
Native EM_REQUESTRESIZE Error: 5
Access is denied
That happens before I enter text so it's not related to having much text.
I do many other messages with the same handle so I can't imagine what is causing the denied message.
If you can't tell me what is probably wrong in the code can you give me any suggestions as to experiment I could perform?
I've collected the relative code from my app (the app is very large):
VB.NET:
Public Declare Auto Function SendMessage Lib "user32.dll" (hWnd As IntPtr, msg As Integer, wParam As IntPtr, lParam As IntPtr) As IntPtr
Public Const WM_USER As Integer = &H400
Public Const EM_REQUESTRESIZE As Integer = WM_USER + 65
Private Sub RequestSizeFromTxtControl()
'EM_REQUESTRESIZE message: Forces a rich edit control to send an EN_REQUESTRESIZE notification code to its parent window
'Try
SendMessage(RichTextBox_Txt.Handle, EM_REQUESTRESIZE, IntPtr.Zero, IntPtr.Zero)
'Catch
Dim ex As Win32Exception = New Win32Exception(Marshal.GetLastWin32Error())
TxtAppendLine("Native EM_REQUESTRESIZE Error: " & ex.NativeErrorCode & vbCrLf & ex.Message & vbCrLf)
'End Try
End Sub
With the error checking (recently added) I get the following:
Native EM_REQUESTRESIZE Error: 5
Access is denied
Native EM_REQUESTRESIZE Error: 5
Access is denied
Native EM_REQUESTRESIZE Error: 5
Access is denied
That happens before I enter text so it's not related to having much text.
I do many other messages with the same handle so I can't imagine what is causing the denied message.
If you can't tell me what is probably wrong in the code can you give me any suggestions as to experiment I could perform?
Last edited by a moderator: