Solved

Windows Focus problems

Posted on 2006-07-03
6
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Title # Comments Views Activity
Comparing dates in Delphi. Greater than/ Less than 3 301
control image tags in a string ? 12 154
Twebbrowser add css to the header 3 39
Delphi: sending SMS on android platform 1 70
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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…

696 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