We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

select form

Mitsy
Mitsy asked
on
Medium Priority
157 Views
Last Modified: 2010-04-06
i have a icon in the system tray for my application when i double click the icon the to show the app it shows but the other apps still have focus.How cani give the form and bring to top. I tried setfocus and topmostWindow  in windows API.
I use delphi 1. thanx
Mits
Comment
Watch Question

Suppose the form you want to show up is called FORM1.

In the OnResize event of this form, put FORM1.ACTIVATE;

I think this should do it.

Author

Commented:
no the form does not have focus and remains hidden under other apps, when i double click the icon.
Mits
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
You could also use this......

FormName.BringToFront;

Regards,
Viktor Ivanov

Author

Commented:
It doesnt work it still does not have focus, i think focus has been given to the icon in the tray
Mits
It depends on where do you call that......Did you try in OnShow()

Author

Commented:
hey viktornet
i can now bring the form to front with setWindowPos in win API but still cant give focus, the title bar is greyed.
Mitsy
Would you please send me the project so I can take a loot at it???

Author

Commented:
ok i will
I sent you some suggestions........You could also try this.....

public
  Procedure ActiveApp(Sender : TObject);
{...}
In OnCreate() enter this code...
Application.OnActivate := ActiveApp;
//The code for the AcitveApp() procedure...
procedure TForm1.ActiveApp(Sender : TObject);
begin
  if Visible then
    Hide
  else
  begin
    if not(GetForegroundWindow = Handle) then
      SetForegroundWindow(Handle);
  end;
end;

Try this if the suggestions I gave you don't work....

Regards,
Viktor Ivanov
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.