Activating window
-
does anyone know how make a window active when multiple windows are open. in an mdi applicatin under window menu item there is a list of all open files and the active one is checked, i want to know how that code works, so that when i click on my tree node that window should be activated, Thanks, F.Dost
-
does anyone know how make a window active when multiple windows are open. in an mdi applicatin under window menu item there is a list of all open files and the active one is checked, i want to know how that code works, so that when i click on my tree node that window should be activated, Thanks, F.Dost
-
does anyone know how make a window active when multiple windows are open. in an mdi applicatin under window menu item there is a list of all open files and the active one is checked, i want to know how that code works, so that when i click on my tree node that window should be activated, Thanks, F.Dost
-
does anyone know how make a window active when multiple windows are open. in an mdi applicatin under window menu item there is a list of all open files and the active one is checked, i want to know how that code works, so that when i click on my tree node that window should be activated, Thanks, F.Dost
Hello, the codegurus around the world.;) I often use this function from "HOW-TO VISUAL C++ 4.0" by Scott ? to change the active view on MDI application.
void CMainFrame::SwitchToView(CDocTemplate* pTemplate, CRuntimeClass* pViewClass)
{
CMDIChildWnd* pMDIActive = MDIGetActive();
CDocument* pDoc = pMDIActive->GetActiveDocument();
CView* pView;POSITION pos = pDoc->GetFirstViewPosition(); while(pos != NULL) { pView = pDoc->GetNextView(pos); if(pView->IsKindOf(pViewClass)) { //the requested view has already been created; show it pView->GetParentFrame()->ActivateFrame(); return; } } //The requested view hasn't been created yet CMDIChildWnd\* pNewFrame = (CMDIChildWnd\*) pTemplate->CreateNewFrame(pDoc, NULL); if(pNewFrame == NULL) return; pTemplate->InitialUpdateFrame(pNewFrame, pDoc);
}
and call this function anywhere like this.
((CMainFrame\*)AfxGetMainWnd())->SwitchToView(theApp.m\_pAppTemplate, RUNTIME\_CLASS(CAppView));
Have a nice day! -Masaaki Onishi-