Solved

Windows Focus problems

Posted on 2006-07-03
6
327 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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…

911 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

22 Experts available now in Live!

Get 1:1 Help Now