Solved

fsstayontop form disappears when i click show desktop in winxp

Posted on 2004-10-28
634 Views
Last Modified: 2010-04-05
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
0
Question by:jamesr123456
    11 Comments
     
    LVL 10

    Expert Comment

    by: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 ;)
    0
     
    LVL 5

    Expert Comment

    by:Hypoviax
    or similarly to what wildzero said:

    in a timer:

    form1.bringtofront;

    or

    application.bringtofront;

    Alternatively have a look at this post for more information:

    http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21148766.html

    You could use the left click out procedure i wrote in the post above to have form1.bringtofront instead of in a timer
    0
     
    LVL 5

    Expert Comment

    by:Hypoviax
    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
    0
     
    LVL 5

    Expert Comment

    by:Hypoviax
    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
    0
     

    Author Comment

    by:jamesr123456
    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.
    0
     
    LVL 12

    Accepted Solution

    by:
    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;

    type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        procedure OnShowDesktop (var Msg: TWMShowWindow); message WM_SHOWWINDOW;
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Self.FormStyle := fsStayOnTop;
    end;

    procedure TForm1.OnShowDesktop(var Msg: TWMShowWindow);
    begin
      if not Msg.Show then
        Msg.Result := 0
      else
        inherited;
    end;

    end.
    0
     
    LVL 5

    Expert Comment

    by:Hypoviax
    Nice code Ivanov_G, it works well, i reccomend his post to be accepted,

    Hypoviax
    0
     
    LVL 12

    Expert Comment

    by:esoftbg
    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;
    0
     
    LVL 12

    Expert Comment

    by:esoftbg
    please remove the line:
       Style := Style AND NOT WS_CAPTION;
    0
     
    LVL 12

    Expert Comment

    by:Ivanov_G
    Hypo, thanks bro :))))
    0
     
    LVL 5

    Expert Comment

    by:Hypoviax
    No worries, the best answer deserves the points

    Hypoviax
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    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…
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    860 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now