Visual C++ programming help

Adrian Tung

Golden Member
Oct 10, 1999
1,370
1
0
I have a static splitter window in which I create 4 panes. In each of these panes are child views of CView class. From this scenario, can a child view know which pane it belongs to, without having to resort to using any global variables?

Thanx!
:)atwl
 

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
I'm not to clear what you want to do, but if the idea is to have a different type of display in each pane, then you should derive 4 different view classes from CView.

If you really want to use the same class - then use the CSplitterWnd::GetPane (int row, int col) member function to obtain the CView derived object for each individual view and call a member function and set a member variable as necessary.
 

Adrian Tung

Golden Member
Oct 10, 1999
1,370
1
0
My idea is to have a 3D Studio MAX interface. Problem is that I got my draw functions split up everywhere... I use the splitter's GetPane function in the child frame (CMDIChildWnd) to pass a CWnd* to the renderer.

I run into headaches when I need to perform basic functions on one of the panes, such as move/rotate/scale. It is the child view (CView) that gets the WM_LMOUSEDOWN message (I can't or don't know how to get the splitter or child frame to intercept the message), so from the view I need to pass the message up to the renderer (through the splitter and child frame), to tell the renderer about the event. Problem is, if I do it this way, the child view itself needs to know which pane it belongs to so that the renderer can perform the operation and render in the correct pane.

It sort of looks something like that:

Child Frame (CMDIFrameWnd)
|
|
v
Splitter (CSplitterWnd) --> GetPane() --> (CWnd*) --> Rendering engine
|
|
v
Child View (CView)

The splitter is a member variable in the child frame, and there are four child views created by the splitter to represent the views (e.g. Top, Front, Left, Camera).

If anyone can provide a hint or solution, I'd appreciate it.


Thanks in advance!
:)atwl
 

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
OK. If I understand you correctly, you want to be able to use functions within the Splitter class from within the View class.

All you need to do, is store within the view object, a pointer to the appropriate frame object.

The easiest way I can think of doing it is as follows:

Add a member variable to the View class of type CMyFrameWnd*.
During creation of the splitter window, set the member variable for each view to point to the frame.

I would do it as follows:

Extract from [CMyMainFrame::eek:nCreateClient]
m_wndSplitterTop.CreateView(0, 0, RUNTIME_CLASS(CMyView), CSize(1, 1), pContext)
((CMyView*) m_wndSplitterTop.GetPane(0,0))->m_ParentFrame= this;

Then add a function call to the CView::eek:nLButtonDown function:
m_ParentFrame->ChildViewLButtonDown (nFlags, point);