Progress and Timer
-
I just post a message about this question Link but I don't obtain a good answer... I need to manage a Progress Bar created into my man app from a thread (while my app is using an ActiveX control). How can I do this? I must use a timer to increment the progress, but I can't use the CWnd::setTimer why my CThread class is derived from CWinThread an not from Cwnd, so how can I manage the Timer? Thanks for every observation.
-
I just post a message about this question Link but I don't obtain a good answer... I need to manage a Progress Bar created into my man app from a thread (while my app is using an ActiveX control). How can I do this? I must use a timer to increment the progress, but I can't use the CWnd::setTimer why my CThread class is derived from CWinThread an not from Cwnd, so how can I manage the Timer? Thanks for every observation.
Well, you can use
SetTimer
function of global namespace (passing NULL as HWND and a valid callback function pointer). But then, how do you communicate with the progress bar? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Well, you can use
SetTimer
function of global namespace (passing NULL as HWND and a valid callback function pointer). But then, how do you communicate with the progress bar? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
Thanks for the reply, I use SetTimer function you said but now my main problem is just how to comunicate with the pregress?? It's a global variable of my app, but can I access and use it from the thread? It's seems NO because nothing is performed by code that must increment it!! SO HOW DO THIS?
-
Thanks for the reply, I use SetTimer function you said but now my main problem is just how to comunicate with the pregress?? It's a global variable of my app, but can I access and use it from the thread? It's seems NO because nothing is performed by code that must increment it!! SO HOW DO THIS?
I suggest to you to post a message to the Application Window Thread (you can pass the application window
HANDLE
to your secondary thread whenever you create it) and let it (the Application Window Thread) do the updating job for you. P.S. Maybe the overall design is wrong: probably would be better to create a window in the secondary thread and build the progress bar in that context. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
I suggest to you to post a message to the Application Window Thread (you can pass the application window
HANDLE
to your secondary thread whenever you create it) and let it (the Application Window Thread) do the updating job for you. P.S. Maybe the overall design is wrong: probably would be better to create a window in the secondary thread and build the progress bar in that context. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Oh, I see..., he is going round and around forums to remain stick in his original design... :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Oh, I see..., he is going round and around forums to remain stick in his original design... :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
I try to explain well my problem.. In my MainWnd I use an ActiveX control (a REprot Viewer) that need time to compute his job (load report) and I need the increment the progress bar while it's computing. I can't set a timer to update the progress bar in the MainWnd (as said here) because while the activeX is working the Timer event is not processed. If the solution you suggest work, I don't need the MyThread but I can manage directly the progress in the MainWnd, but it's wrong. I hope to explain well my problem, and because I use this solution. Thanks
-
-
I try to explain well my problem.. In my MainWnd I use an ActiveX control (a REprot Viewer) that need time to compute his job (load report) and I need the increment the progress bar while it's computing. I can't set a timer to update the progress bar in the MainWnd (as said here) because while the activeX is working the Timer event is not processed. If the solution you suggest work, I don't need the MyThread but I can manage directly the progress in the MainWnd, but it's wrong. I hope to explain well my problem, and because I use this solution. Thanks
I'm totally lost (or you are :)) (I've been following all the threads on this topic). If your ActiveX control is busy processing stuff on the app's main thread, and your progress dialog/control was created on that same thread, then the progress dlg/control cannot process any window messages because your activex control has control of the thread so the thread's message loop isn't being processed. So, it seems to me you have two options - 1) Put the activeX control on another thread so the main thread can process window messages as usual (it can also process your timer messages) 2) Put the progress dialog on a separate thread and process all it's messages, including timer messages, on that thread. That way the ActiveX control can go about its business. Both these have been recommended to you several times. Try one! :) Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder