Link to home
Start Free TrialLog in
Avatar of JDN
JDN

asked on

My program looses focus

Hi Experts,

A question about one of my programs that's running on a Citrix server:

This program looses focus once it has started. Probably because Citrix starts some process just after my program has started. I can't find out what process, but a fact is that my program is not the active windows once it has started.
Because my program starts with a login window, the user must click on my program first before typing anything in the login window; rather annoying.

When I run my program locally or in the IDE there's no problem; once started my program is the active program. So, it's rather difficult to track and solve this problem.

What I like to know is: is there perhaps a way to force my program to become the active program. I could for instance progam a TTimer event, that runs some code 1 second after the program has been started. This code must force my program to become the active program.

Is there a way to achieve this?
Or is there perhaps another solution for this problem?

Thanks,
JDN
Avatar of tongalite
tongalite

Hi JDN

This is a long shot...
Try this code in your on create....

-----------------------------------
SendMessage(Application.Handle,WM_ACTIVATE,WA_CLICKACTIVE,0);

//Maybe switch the Application.Handle with the mainforms handle, usually Form1.Handle
-----------------------------------
Good luck
T.
What about old      
 Application.BringToFront;

cj
ASKER CERTIFIED SOLUTION
Avatar of paulmoun
paulmoun

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh and I forgot, remove the minimize button from the form, otherwise the user will think windows has siezed up.
Avatar of JDN

ASKER

Tongalite, Czechmate,

Both solutions you proposed don't work.

You can test it yourself:

Start a compiled Delphi application and, when this application is launched, click the Windows taskbar or desktop. Your application becomes inactive (the title bar of your application becomes gray).
Now this is in fact my problem. I like to execute some code to force my application (that is inactive now) become active. Once the user has logged on, this TTimer event can stop.
I've tried both your code (in a TTimer event) but my application stays inactive in Windows 2000.

Paulmon, I will try your solution tomorrow (it's sleeping time in the Netherlands now).

Thanks,
JDN
Avatar of JDN

ASKER

This works.
Thanks.
Hi, I have the same problem but I tried to use the code of Paulmon and it don't work..
How did you do?

thanks
luca
lcaruso@anacomp.it