How to make ActiveX Control Redraw in a work thread?
-
I wrote an ActiveX Control, I hope it can show different picture every 10 seconds. So I start a work thread, it prepairs the picture's data and calls the control's FireViewChange method every 10 seconds. Now it seems like that FireViewChange call does not work because the picture that control shows out won't change until I resize the test web page. My control is apartment thread mode and I call CoInitialize(NULL) in my work thread. What changes should I do to make my control work as I want? Thank you.:confused:
-
I wrote an ActiveX Control, I hope it can show different picture every 10 seconds. So I start a work thread, it prepairs the picture's data and calls the control's FireViewChange method every 10 seconds. Now it seems like that FireViewChange call does not work because the picture that control shows out won't change until I resize the test web page. My control is apartment thread mode and I call CoInitialize(NULL) in my work thread. What changes should I do to make my control work as I want? Thank you.:confused:
Hello samfromcn, It is possible that you have not marshalled the ActiveX's event interface (which contains the FireViewChange() method) to your worker thread. - Bio.
-
Hello samfromcn, It is possible that you have not marshalled the ActiveX's event interface (which contains the FireViewChange() method) to your worker thread. - Bio.
Thank Bio, Someone said that FireViewChange interact with the container, then the container tells the control to redraw. It's a little complicated for me. Now I create a hide window in main thread, work thread send user message to the window, the window call control's FireViewChange. This is easy to implement and it works well^_^. :-D
-
Thank Bio, Someone said that FireViewChange interact with the container, then the container tells the control to redraw. It's a little complicated for me. Now I create a hide window in main thread, work thread send user message to the window, the window call control's FireViewChange. This is easy to implement and it works well^_^. :-D
Hello samfromcn, >> Someone said that FireViewChange interact with the container... Yes, the "container" is actually what we know of as the "apartment". It is a good analogy. >> Now I create a hide window in main thread, work thread send user message to the window, the window call control's FireViewChange... This will certainly work. It also works similarly to the actual industrial practice of firing an event from across a separate thread via a proxy to the event interface of the ActiveX marshalled in from the main thread. However, samfromcn, it is better to learn event interface marsalling in the long run. Best of luck, - Bio.