PostMessage fires my message twice

Hi,

I have a very strange problem,

In my project (Cpp) I use PostMessage, the problem is that it fires my message twice - even though I wish to post it ones. More clearly, Whenever I try to post a message from my addin to my automation project I receive two messages, and thus, I trigger my responding function twice. It costs me computation time and it also causes computation errors.

Does any one have a clue

Best regards.




Answer this question

PostMessage fires my message twice

  • SylvirCoder

    That shouldn't happen, and it doesn't sound like a bug or common issue I'm familiar with. Are you absolutely certain that you've got it all right

    You may have better luck with questions such as this in the ui or MFC newsgroups at http://msdn.microsoft.com/newsgroups.



  • Buddy_15

    Typically you would run into this problem if more than one Messages have same Message ID. Might be your MessageID is conflicting with some existing.

    You would need to put a breakpoint to check the call stack and traverse back to find out the source of the origin of the message.

    You can also use SPY++ to check what all messages are getting fixed.

    Well this would not be something that couldbe answered easily without doing debugging and looking at code.


  • floresg

    Sorry . . ., the problem seems to in related to something else - May be some one will know something:
    Well postmessage works just fine the problem is in my addin, my addin has a button which is being sink by a sink_event object.
    The problem is that when the button is being pressed by the user, it calls Invoke function of my sink_event object twice, i.e. INVOKE is being called twice its NOT postmessage!!!
    After some investigations I come the following results:
    1. if I add a counter to the "Invoke function" it counts each two calls as ONE call - i.e. if I press the button, the debugger shows that we are getting FOUR times into "Invoke" but the counter will have the value of TWO. Thus, I cant go through by skipping ode calls.
    2. If the button is pressed and through the first entrance to "Invoke" we kill an object then the second time we are passing through "invoke" we will have an error - the object is death. Well . . ., I can use it to overcome the problem but it seems to me as VERY non-elegant way.
    I dont know why it happens, and Im not sure I have any thing to do with it since it is related to the hosting application (MS-Word).
    I wrote about it in some (msdn) news groups for addins, automation's and office but it seems like no one is interested or alternatively no one knows how to help.
    I hope that may be here some one will have a clued.
    Best regards,


  • PostMessage fires my message twice