ShowWindow() Has No Effect
The ShowWindow() method does not work for me. It was my expectation that
ShowWindow( SW_RESTORE ); would bring the window to the size it had before
it was minimized. I also tried ShowWindow( SW_SHOWMAXIMIZED ); and there
still was no change in the minimized window. The relevant section of code
pasted below. I included how I came by the pointer to the CView object in
cast that has something to do with my problem. This code is in an overridden
OnOpenRecentFile() function. If the file already opened I want to show the
window displaying it data instead of proceeding to have two document objects
for the same file.
CEkDocList is a class for iterating through all open documents and its
details are available in the "The MFC Answer Book", by Eugene Kain. I have
verified this works.
pDoc->m_pContFile and pContFile are of the same class and contain filename
information.
CContFileLess class has an overridden () operator for using the class
pDoc->m_pContFile and pContFile with the map class. (Not shown). The
operator returns true if the filename left argument is less than the
filename in the right one. The ShowWindow( SW_RESTORE ),
BringWindowToTop(); SetFocus(); calls are a failed effort to bring the
minimized window to its former size and give it focus. Tracing execution
with break statements show these are being executed when they should be.
CEkDocList DocList;
CLookDoc *pDoc;
CContFileLess Less;
while( pDoc = (CLookDoc*)(DocList.GetNextDoc()) )
{ if( !Less(pDoc->m_pContFile, pContFile) && !Less( pContFile,
pDoc->m_pContFile) )
{ POSITION pos = pDoc->GetFirstViewPosition();
if(pos != NULL) // Only one view in the document can be shown and
focused so if() is used instead of while()
{ CView* pView = pDoc->GetNextView(pos);
pView->ShowWindow( SW_RESTORE ); // Does not show the window.
pView->BringWindowToTop();
pView->SetFocus();
CLookApp::Wind
}
delete pContFile;
return pDoc;
}
}