?
Solved

Form always on bottom but allow dragging with mouse?

Posted on 2003-12-11
5
Medium Priority
?
447 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 1400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

771 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