Solved

Form always on bottom but allow dragging with mouse?

Posted on 2003-12-11
5
438 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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…

757 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

23 Experts available now in Live!

Get 1:1 Help Now