This is sometimes caused by using the wrong calling convention in the pinvoke declaration.
You don't show the declarations of your pinvoke methods, so this is a guess.
As I am not very good at VB I am not sure how this is declared in this language.
In c# you write like this.
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention.StdCall)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
CallingConvention.StdCall
is the default value.
See this link for more info:
pinvoke.net: SendMessage (user32)[
^]