Windows Focus problems
Posted on 2006-07-03
I'm developing a Delphi application and I have a lot of problems when I show forms. Let me explain:
My aplication initially have 2 forms, all of them hided: the main is hided by Application.ShowMainForm, and the second setting visible to False. The goal of this application is to help ANOTHER application: for example: when the other app needs to show a dialog to open a file, via tcpip contacts my app and is my app who shows the form. Ok, the application is working well, but I have a lot a problems setting the focus on the forms: For example, first time a form is showed all works well, the form is showed as the active form, but subsequent calls, don't show the form (I have to use ALT-TAB to see it), or sometimes the form is showed blinking on the taskbar.
On mainform I'm using a component to put my app on the system tray, and on form create I use
to make sure that no forms are showed on the task bar.
So, my first question is: How to put a form as active form ALLWAYS and this have the focus so the user things that this form is from other app? I used some APIs like SetWindowForeground or setWindowActive ... but more APIS or things I try, more nightmare comes.
Other question is: how to activate an application as the taskbar does?
Thanks in advance.