Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working With Multiple View Classes

Status
Not open for further replies.

forlorn

Programmer
Dec 12, 2001
28
0
0
TR
Hi,

I'm working on a project with a tab control which has 2 tabs. Clicking on each tab activates an appropriate view class. When user clicks one tab the below code is activated in OnselChange function :

pMainFr->m_Splitter2.DeleteView( 1, 0 );
pMainFr->m_Splitter2.CreateView( 1, 0, RUNTIME_CLASS( CNumerikView ), CSize( 0, 0 ), NULL );
pMainFr->m_Splitter2.SetActivePane( 1, 0 );

pMainFr->m_Splitter2.RecalcLayout();
pMainFr->m_Splitter2.RedrawWindow();

But with this approach, when i try to set some variables of the view class, they are deleted before i update the view.

I can't create instances of these classes because they have protected constructors.

So, what i want to know is this method, i mean setting or getting variables by pointers with such type casting? Is it
"programmatically correct"? If not, could you please give me some clues for doing it right.

Thank you very much.
 
And now thinking, would it work if try use Doc class? Are Doc classes mandatory?
 
Some questions:
1. do You check if pMainFr and m_Splitter2 exist? Normally CView - derived objects are created before MainFrame.
2. Why not create derived classes with public constructors, if You wish to create them itself?
3. Are You sure CSize( 0, 0 ) works by this class?
And one tip: If You wish to set any variables in CWnd - derived classes or their child - windows, You can try to do it in OnShowWindow() - Function (class wizard generates this function for message WM_SHOWWINDOW).
And - "programmatically correct" is all, that works right. You can do every thing many ways, and any way can be easier or better for some Programmers...
Best regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top