Access a Specific View in MainFrame :: MFC

kuphryn

Senior member
Jan 7, 2001
400
0
0
Hi.

I am working on a multiview program (two views). The design is done; however, I just found out I cannot cast GetActiveView() in main to any view I want. For example, let say I am in main and the active view is View#1, but I want to send a message or call a function in View#2.

How do you access *any* view, active or inactive, from main?

Thanks,
Kuphryn
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126


<< How do you access *any* view, active or inactive, from main? >>

Easiest way is to add CWnd* / CView* pointer variables to main, and set them at the time that you create the views. You can just make them public, or get OO-fancy and add something like CMainFrame : : AddViewPointer( int index, CView* pv )
 

kuphryn

Senior member
Jan 7, 2001
400
0
0
Thanks.

Okay. I am using a split windows.

Here is the solution for a splitter design.

-----
CMyView2 *pView = reinterpret_cast(m_wndSplitter.GetPane(1, 0));

pView->SendMessage(WM_USER_TEST, 0, 0);

return 0;
-----

Thanks to LordShade of GameDev for for the pointer.

Kuphryn