Re: Closing modeless dialogs
- From: "Tom Serface" <tom.nospam@xxxxxxxxxxxxx>
- Date: Thu, 13 Mar 2008 07:45:37 -0700
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
.
- Follow-Ups:
- Re: Closing modeless dialogs
- From: Joseph M . Newcomer
- Re: Closing modeless dialogs
- References:
- Closing modeless dialogs
- From: Torsten Hensel
- Re: Closing modeless dialogs
- From: Torsten Hensel
- Re: Closing modeless dialogs
- From: David Wilkinson
- Re: Closing modeless dialogs
- From: Torsten Hensel
- Re: Closing modeless dialogs
- From: Joseph M . Newcomer
- Re: Closing modeless dialogs
- From: Torsten Hensel
- Closing modeless dialogs
- Prev by Date: Re: Can't read CString after serialization
- Next by Date: Re: C# vs. C++ (was Re: UNICODE conversion)
- Previous by thread: Re: Closing modeless dialogs
- Next by thread: Re: Closing modeless dialogs
- Index(es):
Relevant Pages
|