1

Exact Duplicate: How to make 'always on bottom' window?
Related: Window on desktop?


I'm developing a small application in Delphi that need to behave like a shell (replacement) launching pad (for Windows Embedded). I have some icons/buttons on it that will launch other applications. The point is that applications need to stay all the time in front of the "shell". Additionally the applications are started using simple-click, but if double click (accidentally) is used the application will go behind (the "shell" will be focused)

Since this application will replace the actual shell (Explorer) will have to behave similarly to Explorer ... so it has to stay in "background" all the time and should not appear in ALT+TAB list.

I tested a lot of combinations of SetWindowPos with HWND_BOTTOM, SWP_NOACTIVATE etc. without success..

Additionally I found some info regarding this but it doesn't work as advertised:
How to keep a form always in the background (bottommost)

Any hints how to achieve all these ?

Update: For hiding the window from ALT-TAB list/switcher (and from Taskbar, but since I'm interested to create shell replacement that will be no Taskbar) I found the following articles:

Hide a Delphi Application Button from the TaskBar
Hide a Delphi 2007 Application Button from the TaskBar (with MainFormOnTaskBar)

Community
  • 1
  • 1
user68682
  • 745
  • 2
  • 12
  • 18
  • Do you completly replace explorer.exe as your shell, or do you try to 'cover up' explorer with your own application? – Vegar Feb 20 '09 at 08:21
  • I need to create a "shell" replacement for a Windows Embedded solution where I can not use the regular Explorer shell. So I try to emulate how the Explorer behaves = stay on the bottom all the time and does not appear in ALT-TAB list. – user68682 Feb 20 '09 at 08:36
  • @jaguard, you might get a better response on your second portion of your question.. as a new question. About the alt-tab. – mmcdole Feb 20 '09 at 08:44
  • No, please use the search function first to read all answers to similar questions on SO. I have added one link already to the OP answer below. – mghie Feb 20 '09 at 08:46
  • I updated the question and included some Delphi specific ALT-TAB hiding articles – user68682 Feb 20 '09 at 09:03
  • Do you run you appliaction as a shell, or as an regular application? Have you told Windows to use your application as the shell? – Vegar Feb 20 '09 at 11:46
  • I set (in registry) my application as the Windows shell. I test it under a virtual machine to avoid creating havoc to my devel machine. – user68682 Feb 20 '09 at 14:58

6 Answers6

2

Hasn't that been asked before?

Community
  • 1
  • 1
dummzeuch
  • 10,975
  • 4
  • 51
  • 158
  • See my detailed comment bellow (partially here): The solution you mentioned does not include any code just some suggestions ... additionally does not handle the ALT-TAB issue that I need to solve too (My window should not apear into the ALT-TAB list, similar to how Explorer - as a shell - behave). – user68682 Feb 20 '09 at 08:38
  • this could be a comment not an answer :) – Gabriel Feb 21 '18 at 12:16
1

It's unclear if you are trying to make your application behave as a 'launchpad' on top of the current shell, or if you are trying to make your application be the shell.

There is a major difference between those two.

It sound like the last option is what you really want, and then taskbars etc shouldn't be any trouble at all - they won't be there, since they are part of the old shell (explorer.exe) that you have replaced.

SharpEnvironment, an open source shell-replacement made with Delphi, may give you some hints on the way.

mghie
  • 32,028
  • 6
  • 87
  • 129
Vegar
  • 12,828
  • 16
  • 85
  • 151
0

Is this what you want?

procedure SetWindowPosToBack(handle: HWND);
begin
  SetWindowPos(Handle,HWND_BOTTOM,0,0,0,0,SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
end;
Gabriel
  • 20,797
  • 27
  • 159
  • 293
0

I'm not sure what the exact effect is that you're trying to achieve, but I think you basically want to change the workarea on your screen.

You can obtain the current workarea as a TRect with Monitor.WorkareaRect. You can set it via SystemparametersInfo()

The example below turns your form into something that more or less resembles the way the Windows taskbar works:

  • no border
  • always on top
  • stuck at the bottom of the screen
  • other windows applications that maximize, will only maximize until the top of our form.

Let me know if this is what you mean.

procedure TfrmMain.FormCreate(Sender: TObject);
var
  Rect :TRect;
begin
  Height      := 25;
  BorderStyle := bsNone;
  FormStyle   := fsStayOnTop;
  Rect        := Monitor.WorkareaRect;
  Rect.Bottom := Rect.Bottom - Height;
  Left        := Rect.Left;
  Width       := Rect.Right;
  Top         := Rect.Bottom;
  SystemparametersInfo(SPI_SETWORKAREA,0, @Rect,SPIF_SENDCHANGE);
end;

Some things to keep in mind:

  • When your program finishes, the workarea on your desktop will still be the way you've set it, so remember to restore it before terminating the application. I'm sure you'll figure out how to do that.

  • When you resize the windows taskbar, running applications are notified of the change, and maximized applications adjust their size to the new workarea. The above code doesn't seem to trigger that, so you might need to find a way to do that.

Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122
  • See my detailed comment bellow (partially here): I need to create a shell replacement (borderless full screen form) that need to stay on the "bottom" all the time similar to regular Explorer shell (that will replace). So it should stay on the bottom not on the top as you suggested. – user68682 Feb 20 '09 at 08:42
0

@dummzeuch The solution you mentioned does not include any code just some suggestions ... additionally does not handle the ALT-TAB issue that I need to solve too (My window should not apear into the ALT-TAB list, similar to how Explorer - as a shell - behave).

@Wouter I need to create a shell replacement (borderless full screen form) that need to stay on the "bottom" all the time similar to regular Explorer shell (that will replace). So it should stay on the bottom not on the top as you suggested.

This "shell" replacement is used for a Windows Embeded solution where I can not use the regular Explorer shell. This shell form include some "soft buttons" (TImage to emulate icons) for some selected executable files that can be started from it. The problem is that is that I need to make sure that the shell stay behind all the time, otherwise it can hide some other applications (ex: multiple fast click on an icon that will start the application but will refocus on shell, or when using ALT TAB).

In this context, I have another question: there is any way to wait for any application to start ?

I will really appreciate some code hints to get started.

user68682
  • 745
  • 2
  • 12
  • 18
  • Please edit your question instead of adding an answer. Another question should be posted as such. For hiding from Alt+Tab see http://stackoverflow.com/questions/357076/best-way-to-hide-a-window-from-the-alt-tab-program-switcher – mghie Feb 20 '09 at 08:40
  • Please edit your question instead of adding an answer. – Gabriel Feb 21 '18 at 12:17
0

It's a Win32 FAQ for decades. See on professional Win32 api group