PostMessage() Problem in ActiveX Control from Thread
-
Hey Everyone I was working on a Browser based ActiveX Control (MFC VC++ 6 SP5) for doing file transferring. I have an internal thread in the control that handles all the transferring and such. I would like to send messages back to the main dialog for display (logging). However, I'm unable to send a message from the thread that the Control catches. I can throw messages in the control and catch them.. I can throws messages in the thread and catch them in the thread, just unable to send a message from the thread to be caught by the control (COleControl class). I have done something similar in an App, but I used an AfxGetMainWnd()->PostMessage(...) when posting the message, since this is a control and there by being a dialog based app, How do I get the message back to the main control or main dialog class? As a note, I used the "ON_REGISTERED_MESSAGE" macro to register a custom message mapping to a handler function. Is there any reason why this would cause a problem? It works in an .exe App. Thanks for any help or suggestions :confused: Rick Gavin
-
Hey Everyone I was working on a Browser based ActiveX Control (MFC VC++ 6 SP5) for doing file transferring. I have an internal thread in the control that handles all the transferring and such. I would like to send messages back to the main dialog for display (logging). However, I'm unable to send a message from the thread that the Control catches. I can throw messages in the control and catch them.. I can throws messages in the thread and catch them in the thread, just unable to send a message from the thread to be caught by the control (COleControl class). I have done something similar in an App, but I used an AfxGetMainWnd()->PostMessage(...) when posting the message, since this is a control and there by being a dialog based app, How do I get the message back to the main control or main dialog class? As a note, I used the "ON_REGISTERED_MESSAGE" macro to register a custom message mapping to a handler function. Is there any reason why this would cause a problem? It works in an .exe App. Thanks for any help or suggestions :confused: Rick Gavin
I am not quite sure that I follow your question, but I believe that you will want to look at the PostThreadMessage function.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life! -
I am not quite sure that I follow your question, but I believe that you will want to look at the PostThreadMessage function.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!I have tried PostThreadMessage with no luck. I have an activex control, generated with the 'MFC ActiveX ControlWizard', which gives me an app class of type COleControlModule, the program is structerd as such.... The COleControl Creates the Dialog, which intern creates the Thread, which intern creates the Socket. The data from the socket needs to be displayed in the dialog. COleControlModule (App) - COleControl (Ctrl) - - CDialog - - - CWinThread - - - - CAsyncSocket How do I get a message from the CAsyncSocket derived class back to the COleControl or the CDialog? If this was an App and Not a Control, I could use AfxGetApp() or AfxGetMainWnd()->PostMessage(...) to get a handle back to the main thread. However, these reference doesn't seem to be working for me in a Control. Thanks for any help.