Link to home
Start Free TrialLog in
Avatar of jamesr123456
jamesr123456

asked on

fsstayontop form disappears when i click show desktop in winxp

I have a form with the style set to fsstayontop. The form stays on top until I press "show desktop" on the winxp taskbar. How can i make my form stay on top all the time?

Thanks
Avatar of wildzero
wildzero

A 'honkey' solution could be to put a timmer on the form and set it to say 500, then on timer evet do form1.setfocus;

Not sure if that will work - but could be worth a shot ;)
or similarly to what wildzero said:

in a timer:

form1.bringtofront;

or

application.bringtofront;

Alternatively have a look at this post for more information:

https://www.experts-exchange.com/questions/21148766/How-can-i-check-if-the-user-gave-a-LEFT-MOUSE-CLICK-out-the-application.html

You could use the left click out procedure i wrote in the post above to have form1.bringtofront instead of in a timer
With showdesktop Windows minimises all the apps. To keep your app up use:

application.Restore;

You could put this in a timer of 100 so that when you app is minimised by showdesktop then it will automatically restore.

To minimise normally just turn of the timer when you minimise
This is perhaps a more elegant solution :

procedure TForm1.FormCreate(Sender: TObject);

begin
  Application.OnMinimize := AppStartTimer;
end;

procedure TForm1.AppStartTimer(Sender: TObject);

begin
  Timer1.Enabled := True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin
  Application.Restore;
  Timer1.Enabled := False;
end;

Hypoviax
Avatar of jamesr123456

ASKER

hmmm. I dont really want a honkey solution. I'd like it to stop it disappearing in the first place. The taskbar can stay visible, and I have "Statbar" running at the top of my screen which also stays visible.

Im increasing the points.
ASKER CERTIFIED SOLUTION
Avatar of Ivanov_G
Ivanov_G
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nice code Ivanov_G, it works well, i reccomend his post to be accepted,

Hypoviax
type
  TForm2 = class(TForm)
    Memo: TMemo;
  private   { Private declarations }
    procedure CreateParams(var Params: TCreateParams); override;
  public    { Public declarations }
  end;

//........

procedure TForm2.CreateParams(var Params: TCreateParams);
begin
  inherited;
  with Params do
  begin
   ExStyle := ExStyle or WS_EX_TOPMOST;
   WndParent := GetDesktopwindow;
   Style := Style AND NOT WS_CAPTION;
 end;
end;
please remove the line:
   Style := Style AND NOT WS_CAPTION;
Hypo, thanks bro :))))
No worries, the best answer deserves the points

Hypoviax