Reply To: problem with SendMessageA

#190564
pharaon
Member

The problem is with marshaling. for ansi the code should be
<div id=”wpshdo_6″ class=”wp-synhighlighter-outer”>
<div id=”wpshdt_6″ class=”wp-synhighlighter-expanded”>
<table border=”0″ width=”100%”>
<tbody>
<tr>
<td align=”left” width=”80%”>Code</td>
<td align=”right”> </td>
</tr>
</tbody>
</table>
</div>
<div id=”wpshdi_6″ class=”wp-synhighlighter-inner” style=”display: block;”>
<div class=”vbnet” style=”font-family: monospace;”>strBuffer.<span class=”me1″>Append</span><span class=”br0″>(</span><span class=”kw7″>Chr</span><span class=”br0″>(</span>1024 <span class=”kw5″>And</span> 255<span class=”br0″>)</span><span class=”br0″>)</span> strBuffer.<span class=”me1″>Append</span><span class=”br0″>(</span><span class=”kw7″>Chr</span><span class=”br0″>(</span><span class=”nu0″>1024</span> <span class=”sy0″>/</span> <span class=”nu0″>256</span><span class=”br0″>)</span><span class=”br0″>)</span></div>
</div>
</div>
Because the buffer is marshaled from unicode to anso on it’s way out Char by Char. 1024 fits in a Char which is 2 byte unicode but when marshaled the high byte is lost. or somehow converted I suggest to declare and use SendMessage as follows, since the edit control is unicode anyway
<div id=”wpshdo_7″ class=”wp-synhighlighter-outer”>
<div id=”wpshdt_7″ class=”wp-synhighlighter-expanded”>
<table border=”0″ width=”100%”>
<tbody>
<tr>
<td align=”left” width=”80%”>Code</td>
<td align=”right”> </td>
</tr>
</tbody>
</table>
</div>
<div id=”wpshdi_7″ class=”wp-synhighlighter-inner” style=”display: block;”>
<div class=”vbnet” style=”font-family: monospace;”><span class=”kw6″>Declare</span> <span class=”kw1″>Unicode</span> <span class=”kw6″>Function</span> SendMessage Lib <span class=”st0″>”USER32″</span> <span class=”kw1″>Alias</span> <span class=”st0″>”SendMessageW”</span> _ <span class=”br0″>(</span><span class=”kw2″>ByVal</span> hwnd <span class=”kw2″>As</span> IntPtr, <span class=”kw2″>ByVal</span> wMsg <span class=”kw2″>As</span> <span class=”kw4″>Integer</span>, <span class=”kw2″>ByVal</span> wParam <span class=”kw2″>As</span> <span class=”kw4″>Integer</span>, <span class=”kw2″>ByVal</span> lParam <span class=”kw2″>As</span> StringBuilder<span class=”br0″>)</span> <span class=”kw2″>As</span> <span class=”kw4″>Integer</span> strBuffer.<span class=”me1″>Append</span><span class=”br0″>(</span><span class=”kw7″>ChrW</span><span class=”br0″>(</span><span class=”nu0″>1024</span><span class=”br0″>)</span><span class=”br0″>)</span></div>
</div>
</div>

it keep showing my symbols at the end of the text like his 머ࢆ洰Հ╈࢐ even after I tried what you said