Re: Closing modeless dialogs

Tech-Archive recommends: Speed Up your PC by fixing your registry



My guess is that with PostMessage your string was going out of scope before being used by the window (when message processed). SendMessage() will cause the thread to wait until the message is processed and may not be what you really want. Maybe you could add the string object as a CString to your thread class then it would always be in scope so long as that object exists? You could copy the other string data (from wherever in your thread) to that class member (or members if more than on string needed). What I typically do is create a object for the data I want to pass around and make a new object in the thread that is deleted after being used in the handler. That seems to work pretty well.

Tom

"Torsten Hensel" <Hensz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:1205417580.04@xxxxxxxxxxxxxxxxxxxxx
Joseph M. Newcomer wrote:
PostMessage is robust, up to the issue of message queue saturation (the result of sending
thousands of messages per second), and I have a generalization that works even in this
situation, although it is probably overkill in yours.

I changed my application that it now uses messages - but SendMessage instead of PostMessage. With PostMessage I could not send strings (I received access violations).

But what about closing the application? Currently I'm using PostMessage(WM_QUIT, ErrorCode, 0); which is quite brute. Before that I tried EndDialog, but this failed when I used a worker thread.

Best regards,
Torsten


.



Relevant Pages

  • Re: String between unmanaged and managed
    ... Directly from Help on PostMessage: ... exit before the receiver copies off the data (it's quite likely to happen in ... PostMessage(hwndinoc, 20000, (WPARAM) textitem, textlen); ... I have tried, the problem is that I always receive an invalid string, ...
    (microsoft.public.windowsce.app.development)
  • Re: Postmessage API
    ... Also review the PostMessage declaration. ... declare function PostMessage lib "user32.dll" (byval hWnd as intptr, ... | Private Sub Button1_Click(ByVal sender As System.Object, ... | "FindWindowA" (ByVal lpClassName As String, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Closing modeless dialogs
    ... CString * s = new CString; ... Maybe you could add the string object as a CString to your ... class member. ... With PostMessage I could not send strings (I ...
    (microsoft.public.vc.mfc)
  • Re: String --> Pointer --> LongInt
    ... >Global Var A: String; ... So you are going in for obfuscation and using PostMessage ...
    (alt.comp.lang.borland-delphi)
  • Re: Closing modeless dialogs
    ... CString * s = new CString; ... Maybe you could add the string object as a CString to your ... With PostMessage I could not send strings (I ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)