Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: How to add tabs to CView Class? Pin
Sampath57910-Mar-18 22:15
Sampath57910-Mar-18 22:15 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu12-Mar-18 23:43
_Flaviu12-Mar-18 23:43 
QuestionSerializing CMapStringToPtr Pin
_Flaviu4-Mar-18 22:35
_Flaviu4-Mar-18 22:35 
AnswerRe: Serializing CMapStringToPtr Pin
CPallini4-Mar-18 23:29
mveCPallini4-Mar-18 23:29 
QuestionMSXML load - not able to read chinese characters in path Pin
Gopi Nath28-Feb-18 22:25
Gopi Nath28-Feb-18 22:25 
QuestionRe: MSXML load - not able to read chinese characters in path Pin
Richard MacCutchan28-Feb-18 22:52
mveRichard MacCutchan28-Feb-18 22:52 
AnswerRe: MSXML load - not able to read chinese characters in path Pin
Gopi Nath28-Feb-18 23:12
Gopi Nath28-Feb-18 23:12 
GeneralRe: MSXML load - not able to read chinese characters in path Pin
Richard MacCutchan28-Feb-18 23:15
mveRichard MacCutchan28-Feb-18 23:15 

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.