Skip to content

pharaon

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 62 total)
  • Author
    Posts
  • #190538
    pharaon
    Member

    yes

    #190540
    pharaon
    Member

    i did but couldn’t find any thing

    #190542
    pharaon
    Member

    that is the exception i get

    Warning: A StringBuilder buffer has been overflowed by unmanaged code.  The process may become unstable.  Insufficient capacity allocated to the StringBuilder before marshaling it.

    #190544
    pharaon
    Member

    it work but some times i give me this message A StringBuilder buffer has been overflowed by unmanaged code

    #190546
    pharaon
    Member
        Declare Unicode Function SendMessage Lib "USER32" Alias "SendMessageW" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
    
        Declare Auto Function SendMessage Lib "USER32" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    
    #190548
    pharaon
    Member

    still give me the same error

    #190550
    pharaon
    Member

    this is the code im using

    Dim iLineIndex As Integer = SendMessage(hwnd, EM_LINEINDEX, ilastLine, 0)
    Dim iLineLength As Integer = SendMessage(hwnd, EM_LINELENGTH, iLineIndex, 0)
    if iLineLength = 0 return Nothing ' or return ""
    Dim sb As StringBuilder = New StringBuilder(iLineLength)
    sb.Append(ChrW(iLineLength))
    sb.Length = iLineLength
    SendMessage(hwnd, EM_GETLINE, ilastLine, sb)
    
    #190552
    pharaon
    Member

    ok

    #190554
    pharaon
    Member

    chike what is the use of the two declaration???

    Declare Unicode Function SendMessage Lib "USER32" Alias "SendMessageW" _
         (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer,
         ByVal lParam As StringBuilder) As Integer
    
    Declare Auto Function SendMessage Lib "USER32" _
         (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer,
         ByVal lParam As Integer) As Integer
    

     

    will I use both or just one of them?

    #190560
    pharaon
    Member

    this one work fine thanks

    #190562
    pharaon
    Member
        Declare Auto Function SendMessage Lib "USER32" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
    
    Dim strBuffer As New StringBuilder(1024)
    strBuffer.Append(Chr(1024 And 255))
            strBuffer.Append(Chr(1024 / 256))

    return symbol

    Declare Auto Function SendMessage Lib "USER32" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
    
    Dim strBuffer As New StringBuilder(1024)
            strBuffer.Append(1024)

    return nothing

        Declare Unicode Function SendMessage Lib "USER32" Alias "SendMessageW" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
    
    
    Dim strBuffer As New StringBuilder(1024)
    strBuffer.Append(Chr(1024 And 255))
            strBuffer.Append(Chr(1024 / 256))
    

     

    return nothing

        Declare Unicode Function SendMessage Lib "USER32" Alias "SendMessageW" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As StringBuilder) As Integer
    
    Dim strBuffer As New StringBuilder(1024)
            strBuffer.Append(ChrW(1024))

     

     

    return symbol

     

     

    #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

    #190565
    pharaon
    Member

    i didn’t try this yet

    but right now when I type 123 in the room I get this 123꧐첼ಬ

    #190569
    pharaon
    Member

    now it get just 63 letter

    #190571
    pharaon
    Member

    ok now I know what is the problem

    it’s the net framework version it have to be 3.5

    when it’s 3.5 every thing work just fine

    but when it’s 4 it doesn’t work and my app have to be net framework 4

    so is there any way to fix this?

Viewing 15 posts - 1 through 15 (of 62 total)