mpossible strange behaviour with sendmessage (make no sense at all)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • michelqa

    mpossible strange behaviour with sendmessage (make no sense at all)

    Hi,

    I use sendMessage to retrieve information from another application.

    For some obscur reasons, my code work only in a button click event and
    nowhere else in my application. I mean I get unexpected result
    depending where the code is placed in my application ?!?!?!?!?

    Here is my code:
    =============== =============== ==
    //retrieve all line in a win32 multiline textbox
    IntPtr
    NbOfLines=SendM essage(1050958, EM_GETLINECOUNT ,IntPtr.Zero,In tPtr.Zero);
    string CtrlContent="";
    // MessageBox.Show ("Uncomment this line and everything work....");
    for (int cnt=0;cnt<(int) NbOfLines;cnt++ )
    {
    StringBuilder textBuffer = new StringBuilder() ;
    int NbOfChars=SendM essage(1050958, EM_GETLINE,cnt, textBuffer);
    CtrlContent+=te xtBuffer.ToStri ng();
    }
    MessageBox.Show ("Content="+Ctr lContent);


    The preceding code placed in a button click event work
    perfectly....bu t the same code in a TreeView afterSelect event is not
    working at all, the content is always empty without any reasons...

    if I put a messagebox before the loop, everything work
    perfectly.....T his is totally weird is anybody can explain what is
    going on???

    This non logic behaviour is a ***MAJOR PROBLEM*** in my application I
    really need to find a way to fix this..

    Thanks!
Working...