Solved

Form always on bottom but allow dragging with mouse?

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 143
Print Graphic and Text to Epson TM-T88v 12 241
update joined tables 2 45
Delphi: sending SMS on android platform 1 18
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

13 Experts available now in Live!

Get 1:1 Help Now