Archived

This topic is now archived and is closed to further replies.

Mr Plough

Always on bottom?

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites