Re: Give the Focus to my application

Tech-Archive recommends: Speed Up your PC by fixing your registry



Frederic wrote:
Hello,

I've got a question that looks simple but that gave me a headache...

I've got an application and this application must always have the focus. I created a timer that expires each second, and each time it expires, it must give the focus to my application (in case user switched to another application).

I tried many functions below to give the focus to my app, but none worker:
* ShowWindow(SW_SHOW);
* SetActiveWindow();
* SetFocus();
* SetForegroundWindow();
* SetRedraw();
* SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
I also simulated a click within my dialog but it did not worked.

How can I give the focus to my app???

In general, WinXP & Win2K are very very tough on applications that demand to get the focus. They generally don't allow any random app to grab the keyboard focus; rather, the button in the tak bar blinks indicating to the user an app is begging for attention. This is a much better user interface design, but it sure can be frustrating from the developer point of view.

--
Jonathan Arnold
inSORS
.


Quantcast