Solved

Windows Focus problems

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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