Click here to Skip to main content
15,913,939 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: BitBlt on Win98 / WinNT Pin
Christian Graus2-May-01 12:41
protectorChristian Graus2-May-01 12:41 
GeneralRe: BitBlt on Win98 / WinNT Pin
Liam O'Hagan2-May-01 13:16
Liam O'Hagan2-May-01 13:16 
GeneralDrag and Drop tree view items Pin
wfalby1-May-01 10:35
wfalby1-May-01 10:35 
GeneralRe: Drag and Drop tree view items Pin
Tomasz Sowinski2-May-01 1:17
Tomasz Sowinski2-May-01 1:17 
GeneralActivating window Pin
F.Dost1-May-01 9:08
F.Dost1-May-01 9:08 
GeneralRe: Activating window Pin
1-May-01 9:55
suss1-May-01 9:55 
GeneralRe: Activating window Pin
Felix Cho1-May-01 11:35
Felix Cho1-May-01 11:35 
GeneralRe: Try this. Pin
Masaaki Onishi1-May-01 17:32
Masaaki Onishi1-May-01 17:32 
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-
GeneralQuest on Flags... Pin
CMFC6.0VS.NETUser1-May-01 9:06
CMFC6.0VS.NETUser1-May-01 9:06 
GeneralRe: Quest on Flags... Pin
l a u r e n1-May-01 11:27
l a u r e n1-May-01 11:27 
GeneralRe: Quest on Flags... Pin
Michael Dunn1-May-01 16:29
sitebuilderMichael Dunn1-May-01 16:29 
GeneralRe: Quest on Flags... Pin
CMFC6.0VS.NETUser2-May-01 4:25
CMFC6.0VS.NETUser2-May-01 4:25 
Generalsimilar functions in vc++ for clreol and gotoxy Pin
1-May-01 8:55
suss1-May-01 8:55 
GeneralRe: similar functions in vc++ for clreol and gotoxy Pin
Christian Graus1-May-01 13:06
protectorChristian Graus1-May-01 13:06 
GeneralRe: similar functions in vc++ for clreol and gotoxy Pin
Tomasz Sowinski2-May-01 1:23
Tomasz Sowinski2-May-01 1:23 
GeneralHelp Topics Pin
kk91-May-01 8:46
kk91-May-01 8:46 
GeneralCOleControl and Office 200 Problem under NT4 Pin
Michael A Barnhart1-May-01 6:26
Michael A Barnhart1-May-01 6:26 
Generalw*fstream troubles Pin
Someone20021-May-01 5:43
Someone20021-May-01 5:43 
GeneralSimple Custom Control Question Pin
Mark Jones1-May-01 5:14
Mark Jones1-May-01 5:14 
GeneralRe: Simple Custom Control Question Pin
Michael A Barnhart1-May-01 7:36
Michael A Barnhart1-May-01 7:36 
GeneralRe: Simple Custom Control Question Pin
Mark Jones1-May-01 22:47
Mark Jones1-May-01 22:47 
GeneralRe: Simple Custom Control Question Pin
Tomasz Sowinski2-May-01 0:26
Tomasz Sowinski2-May-01 0:26 
GeneralRe: Simple Custom Control Question Pin
Mark Jones2-May-01 0:48
Mark Jones2-May-01 0:48 
GeneralPrint Preview Pin
1-May-01 4:59
suss1-May-01 4:59 
GeneralRe: Print Preview Pin
5-Jun-01 22:10
suss5-Jun-01 22:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.