Solved

Form always on bottom but allow dragging with mouse?

Posted on 2003-12-11
5
445 Views
Last Modified: 2010-04-05
I'm trying to make a form that is "pinned" to the desktop but can be also dragged around with the mouse. I've used:

SetWindowPos(WindowHandle, HWND_BOTTOM,    0,0,0,0, SWP_NOMOVE or SWP_NOSIZE);

to send it to the bottom, but whenever it is clicked on it becomes activated and is on top.

I added the same line of code to the form's FormMouseDown method but this results in the window being temporarily shown then disappearing which is annoying (and also sometimes doesn't get sent back at all - it stays on top).

Is there some way (via messages or something) that I can have the form stay permanently on the bottom yet still drag it around with the mouse? Perhaps by intercepting the mouse click, trapping the mouse dragging stuff but not activating the window? I'm not that familiar with window messaging so I'm not sure what is and isn't possible.

Also another (maybe related problem?) I am having is when I click the "Show Desktop" button, my form briefly disappears, then reappears, and if I click on it, it disappears! (Only to reappear if I click where it was). Very odd.

Any help would be greatly appreciated :)
0
Comment
Question by:NeM2k2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 350 total points
ID: 9919777
Hi,

Try this:

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMWindowPosChanging(var Message: TWMWindowPosChanging);
begin
  with Message do
    WindowPos.flags := WindowPos.flags or SWP_NOZORDER;
  inherited;
end;

end.

Regards, Geo
0
 

Author Comment

by:NeM2k2
ID: 9922213
Great! That works really well. Any idea about the "Show Desktop" thing? With this code the form gets hidden when it is clicked - I'd like it to stay visible at all times.

(Have increased the points for this question)
0
 
LVL 17

Expert Comment

by:geobul
ID: 9923048
>Any idea about the "Show Desktop" thing?
No, I'm sorry. 'Show Desktop' function actually hides all opened windows (without the desktop and taskbar windows). I stopped fighting with that function (and its results) long ago.

Regards, Geo
0
 

Author Comment

by:NeM2k2
ID: 9931879
I came up with a solution - I just have a timer that calls Show(); every 1/2 a second or so, so the window pops up again after the user clicks the "Show Desktop" button. Thanks for your help though - answer accepted :)
0
 
LVL 17

Expert Comment

by:geobul
ID: 9940726
Thanks for the grade :-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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