Archived

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

Zipster

CFrameWnd is being stubborn

Recommended Posts

I have a dialog-based MFC application that creates several CFrameWnd-derived classes dynamically during execution. My only complaint is that these windows always hog the foreground! In other words, they always stay on top of all the other windows of the application, always. I know CFrameWnd is supposed to be meant as a top-level window, but shouldn''t there be some way to force it to the background? I''ve tried SetWindowPos on both the offending window to get it to go back and the dialog to get it to move to the front, but to no avail. Does anyone know of any other ways to force CFrameWnd-derived windows to the back? "Yield, damn you, yield!"

Share this post


Link to post
Share on other sites
are you using WS_OVERLAPPEDWINDOW or WS_OVERLAPPED in your create function if so you might want to try removing them or try using CWnd::ShowWindow() or you might want to look at this code snippet that i used to tile a cview window and a form window
void CMainFrame::CreateOrActivateFrame(CDocTemplate* pTemplate,
CRuntimeClass* pViewClass)
{ TRACE("Entering CMainFrame::CreateOrActivateFrame\n");
CMDIChildWnd* pMDIActive = MDIGetActive();
ASSERT(pMDIActive != NULL);
CDocument* pDoc = pMDIActive->GetActiveDocument();
ASSERT(pDoc != NULL);

CView* pView;
POSITION pos = pDoc->GetFirstViewPosition();
while (pos != NULL)
{
pView = pDoc->GetNextView(pos);
if (pView->IsKindOf(pViewClass))
{
pView->GetParentFrame()->ActivateFrame();
return;
}
}

CMDIChildWnd* pNewFrame
= (CMDIChildWnd*)(pTemplate->CreateNewFrame(pDoc, NULL));
if (pNewFrame == NULL)
return; // not created
ASSERT_KINDOF(CMDIChildWnd, pNewFrame);
pTemplate->InitialUpdateFrame(pNewFrame, pDoc);
MDITile(MDITILE_HORIZONTAL);
}


[edited by - j stoll on December 25, 2002 10:58:31 PM]

Share this post


Link to post
Share on other sites