PROBLEM: EM_HIDESELECTION, SendMessage

basic212

New member
Joined
Mar 13, 2006
Messages
1
Programming Experience
5-10
vb6-------------------------------------------------
VB.NET:
Private Declare Function SendMessage Lib "user32" _
                                Alias "SendMessageA" _
                                (ByVal hwnd As Long, _
                                ByVal wMsg As Long, _
                                ByVal wParam As Long, _
                                lParam As Any) As Long
Call SendMessage(RichTextBox1.hwnd, EM_HIDESELECTION, 1, ByVal 0&)
----------------------------------------------------
the previous code works just fine.

vb.net------------------------------------------------
VB.NET:
Public Declare Auto Function SendMessage Lib "user32"  _
(ByVal hWnd As IntPtr, ByVal msg As Integer, _
ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr

Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Int32, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32) As Int32
'this code is in derived class from RichTextBox Class.
SendMessage(MyBase.Handle.ToInt32,EM_HIDESELECTION, 1, 0)
SendMessage(MyBase.Handle, EM_SETSEL, Start, Start + Length)
----------------------------------------------------
the story is that, i want to select a current range from "Start" to "Start + Length" in a RichTextBox .. and i want to hide that selection
the ..
SendMessage(MyBase.Handle.ToInt32,EM_HIDESELECTION, 1, 0)
.. does not do anything while in VB6 it works fine...
another thing, it does not work too when i use WndProc method, like this:
VB.NET:
Const WM_USER As Long = &H400
Const EM_HIDESELECTION As Long = (WM_USER + 63)
dim msg as new message
msg.hWnd = mybase.handle
msg.wparam = new intptr(1)
msg.lparam = intptr.zero
msg.msg = EM_HIDESELECTION
mybase.wndproc(msg)
' it does not WORK????????????
'note i am inharieting the RTB class in my own class control .. so i am using
'myBase word ...

one Another thing is that when i am using WndProc with EM_SETSEL message it fails and does not do anything, and it is successful when i use SendMessage Function with it
 
Back
Top