Click here to Skip to main content
15,904,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5795-Mar-18 18:41
Sampath5795-Mar-18 18:41 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu5-Mar-18 20:42
_Flaviu5-Mar-18 20:42 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5795-Mar-18 20:43
Sampath5795-Mar-18 20:43 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu5-Mar-18 22:03
_Flaviu5-Mar-18 22:03 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5795-Mar-18 22:51
Sampath5795-Mar-18 22:51 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu5-Mar-18 23:21
_Flaviu5-Mar-18 23:21 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 0:26
Sampath5796-Mar-18 0:26 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 0:33
_Flaviu6-Mar-18 0:33 
GeneralMessage Closed Pin
6-Mar-18 0:44
Sampath5796-Mar-18 0:44 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 1:16
_Flaviu6-Mar-18 1:16 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 1:44
Sampath5796-Mar-18 1:44 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 1:50
_Flaviu6-Mar-18 1:50 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 4:09
Sampath5796-Mar-18 4:09 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 4:30
_Flaviu6-Mar-18 4:30 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 4:52
Sampath5796-Mar-18 4:52 
GeneralRe: How to add tabs to CView Class? Pin
Sampath57910-Mar-18 22:06
Sampath57910-Mar-18 22:06 
If i call AddView() and run my program, it working absolutely fine with a window and a view(tab).
But instead of calling AddView() initially, at runtime i based on user input, i called addview() which leads to a crash. What could be the reason.

class View : public CScrollView
{
	
}

//below is my main class
class MyTabClass : public CTabView
{
	//this function gets called automatically during creation of window.
	void OnCreate(LPCREATESTRUCT lpCreateStruct)
	{
		if (CTabView::OnCreate(lpCreateStruct) == -1)
			return -1;
		AddView(RUNTIME_CLASS(View),_T("Sheet1")); //this works fine.
	}
	
	//this function i will call based on user input and hence its crashing during addView call.
	void RunTimeBasedOnUserInput()
	{
		for(int i = 0 ; i < userinput; i++)
		{
			AddView(RUNTIME_CLASS(View),_T("sheet %d",i));
		}

	}
}



After investigation, what i found is, During creation of window itself, OnInitUpdate function in class View is getting called each time when AddView() is called.

But if i create the views dynamically, then AddView() wont call OnInitUpdate of my View class and hence the crash occurs.

Exception as follows:


---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Assertion Failed!

Program: C:\Windows\SYSTEM32\mfc140d.dll
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxtabview.cpp
Line: 102

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

---------------------------
Abort Retry Ignore
---------------------------

Can you let me know how to get rid of this problem?

modified 13-Mar-18 1:03am.

GeneralRe: How to add tabs to CView Class? Pin
Sampath57910-Mar-18 22:10
Sampath57910-Mar-18 22:10 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 0:36
_Flaviu6-Mar-18 0:36 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 0:45
Sampath5796-Mar-18 0:45 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 20:18
Sampath5796-Mar-18 20:18 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 21:01
_Flaviu6-Mar-18 21:01 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 21:20
Sampath5796-Mar-18 21:20 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 21:35
_Flaviu6-Mar-18 21:35 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 21:51
Sampath5796-Mar-18 21:51 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 22:08
_Flaviu6-Mar-18 22:08 

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.