• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 148
  • Last Modified:

select form

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
0
Mitsy
Asked:
Mitsy
  • 5
  • 4
1 Solution
 
belgianbasmanCommented:
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.

0
 
MitsyAuthor Commented:
no the form does not have focus and remains hidden under other apps, when i double click the icon.
Mits
0
 
viktornetCommented:
SetForegroundWindow(FormName.Handle);

Regards,
Viktor Ivanov
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
viktornetCommented:
You could also use this......

FormName.BringToFront;

Regards,
Viktor Ivanov
0
 
MitsyAuthor Commented:
It doesnt work it still does not have focus, i think focus has been given to the icon in the tray
Mits
0
 
viktornetCommented:
It depends on where do you call that......Did you try in OnShow()
0
 
MitsyAuthor 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
0
 
viktornetCommented:
Would you please send me the project so I can take a loot at it???
0
 
MitsyAuthor Commented:
ok i will
0
 
viktornetCommented:
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
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now