|
-
May 14th, 1999, 05:51 AM
#1
How can I bring a selected view window to the top?
I got a treeview holding the path of all the opened files. I can selected a
file path by double clicking an item of the
treeview. My problem is: how can I bring the
view window associated with the selected file to the top like MS VC++ does? I wrote the following
code overrided when double clicking
on an item of the treeview but this seems not work:
void CMainFrame::SetActiveWindow()
{
CString strDocName,strDocPath;
CDocTemplate* pSelectedTemplate;
CDocument* pSelectedDoc;
CMyView* pView;
POSITION posd,posv;
POSITION pos=AfxGetApp()->GetFirstDocTemplatePosition();
CMyTreeView* TreeCtrl=GetTreeViewFile(); // get a pointer to my treeview
CString strfilepath=TreeCtrl->GetFilePath();
while(pos!=NULL) {
pSelectedTemplate=(CDocTemplate*)AfxGetApp()->GetNextDocTemplate(pos);
ASSERT(pSelectedTemplate!=NULL);
pSelectedTemplate->GetDocString(strDocName,CDocTemplate: ocName);
posd=pSelectedTemplate->GetFirstDocPosition();
while(posd!=NULL) {
pSelectedDoc=(CDocument*)pSelectedTemplate->GetNextDoc(posd);
ASSERT(pSelectedDoc!=NULL);
strDocPath=pSelectedDoc->GetPathName();
if(strDocPath==strfilepath) {
// Iterating for views
posv=pSelectedDoc->GetFirstViewPosition();
while(posv!=NULL) {
pView=(CMyView*)pSelectedDoc->GetNextView(posv);
ASSERT(pView!=NULL);
pView->SetActiveWindow();
pView->BringWindowToTop();
pSelectedDoc->UpdateAllViews(NULL);
}
}
}
}
}
I appricate your suggestions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|