Solved

Windows Focus problems

Posted on 2006-07-03
6
326 Views
Last Modified: 2012-06-21
Dear experts,

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

SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
ShowWindow(Application.Handle, SW_HIDE);

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.
0
Comment
Question by:david-marti
6 Comments
 
LVL 3

Expert Comment

by:flasht
ID: 17031271
ShowWindow(FormHandle,SW_Normal) ;
0
 
LVL 3

Expert Comment

by:flasht
ID: 17031295
Dont really understand what the problem is... maybe set your form as a child of that application?
Windows.SetParent();
0
 

Author Comment

by:david-marti
ID: 17031667
Ok, I agree that my explanation is awfull, but after a deep review of my application I solved the problem setting Windows.SetForegroundWindow(application.Handle) before showing the form.

Thanks to all that answer the question.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 17033479
try also SetActiveWindow with parameter Form1.Handle after showing the form...
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18288997
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now