Always on bottom?

Started by
4 comments, last by Mr Plough 20 years, 8 months ago
Hi, How can i keep a window bottom most in the z-order? My app should remain above the desktop and below all other apps. I figure it has something to do with the SetWindowPos function, but im having no luck. VC++ thanks. Mr Plough
Advertisement
HWND_BOTTOM as the last flag. From MSDN, of course
actually, for SetWindowPos, that should be HWND_BOTTOM as the 2nd parm and make sure that the flags parm does not include a "no z order" flag such as SWP_NOZORDER or SWP_NOREPOSITION.

but the easiest, most effective way to handle this is to process the WM_WINDOWPOSCHANGING msg and override its WINDOWPOS structure''s hwndInsertAfter to always be HWND_BOTTOM and to have a flag that never contains a "no z order" flag, i.e., bitwise and-out those flags.
thanks for the replies.

HWND_BOTTOM puts the window at the bottom, but doesnt stop it being clicked into the foreground. I assume thats what MR Anonymous was suggesting the WM_WINDOWPOSCHANGING msg.

case WM_WINDOWPOSCHANGING:
{
SetWindowPos(hwnd,HWND_BOTTOM,0,0,400,400,SWP_NOSENDCHANGING);
return(0);
} break;

has no effect at all.
could someone put it in laymens terms please

Mr Plough
if you had bothered looking up WM_WINDOWPOSCHANGING in the docs you would have noticed that the msg has a pointer to a WINDOWPOS structure as its lParam. that''s what you change (which was clearly indicated by my previous post.) you don''t call SetWindowPos again. SetWindowPos is one of the functions that triggers the WM_WINDOWPOSCHANGING msg.

it can''t get much simpler than that.

and having a foreground window and wanting to keep a window always on bottom are two entirely different subjects. but i''ll leave that one for someone else.
A little aggressive....

....but thanks. that works a treat.

Mr Plough.

This topic is closed to new replies.

Advertisement