Link to home
Start Free TrialLog in
Avatar of NeM2k2
NeM2k2

asked on

Form always on bottom but allow dragging with mouse?

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 :)
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NeM2k2
NeM2k2

ASKER

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)
>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
Avatar of NeM2k2

ASKER

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 :)
Thanks for the grade :-)