Click to See Complete Forum and Search --> : Activating an MFC app from one of its worker threads


James Hughes
July 14th, 1999, 08:43 AM
I have an app which has a worker thread. When the worker thread reaches a certain stage it need to bring the app to the foreground ready for user input.

What is the best way to activate the app and bring it to the foreground from a different thread?

I have tried AfxGetMainWnd()->SetWindowPos(&CWnd::wndTop....) but this doesnt seem to work.

Any other ideas?

I also need to kick the idle processing off (the main app needs to do some processing in idle time, on demand from the worker thread). However, the idle fn is not called unless the window in active. Is there a way of kicking off the idle time stuff, agian from theworker thread?

TIA



James Hughes
Software Engineer
Spaceward Graphics Ltd, Home of Satori

Yorik
July 14th, 1999, 10:10 AM
try CWnd::BringWindowToTop ()

James Hughes
July 15th, 1999, 05:34 AM
Hi Yorick,

the problem is that making it work from a different thread (not derived from CWinThread)

I have tried using SetWindowPos(Hwnd...) where HWND is the HWND of the MainFrame, but again this doesnt seem to work, but I dont know why.

WRT kicking idle time off, if I could so this I could do theactivation in the idle loop, but I cannot figure a way of making the main thread go into OnIdle from the worker thread.

Any ideas?

James

James Hughes
Software Engineer
Spaceward Graphics Ltd, Home of Satori