This question is related to my previous one.
I have an MFC (VC6) MDI Application which has several MDI child windows acting as different views for one document.
Is it possible to set one of those frames to stay on top of the others?
I have tried to call
SetWindowPos(
&GetParentFrame()->wndTopMost,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);
and
ModifyStyleEx(0, WS_EX_TOPMOST);
from the CMDIChildWnd but neither appears to work.
Are you sure it's good UI design to keep a child window on top of the others? Shouldn't this become a separate topmost frame? Or a control bar?
In your CMDIChildWnd class (usually CChildFrame), add a static
HWND m_hTopWnd
. Set it equal to the HWND of the child you want to be always on top.Handle
WM_WINDOWPOSCHANGED
inCChildFrame
. In the handler, check if the currentm_hWnd == m_hTopWnd
. If not, callThis way whenever the position of any MDI child window is set, the "always on top" window will be pushed back to the top.
Also handle
WM_CLOSE
and when the top window is closing, set m_hTopWnd = NULL.See also: CodeProject article and MSDN knowledgebase