Click here to Skip to main content
15,896,207 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Double Click on ProgressBar Pin
Maciej Los5-Mar-18 20:24
mveMaciej Los5-Mar-18 20:24 
AnswerRe: Double Click on ProgressBar Pin
Fedrer5-Mar-18 20:42
Fedrer5-Mar-18 20:42 
QuestionRe: Double Click on ProgressBar Pin
David Crow6-Mar-18 2:24
David Crow6-Mar-18 2:24 
AnswerRe: Double Click on ProgressBar Pin
Victor Nijegorodov5-Mar-18 21:16
Victor Nijegorodov5-Mar-18 21:16 
QuestionHow to add tabs to CView Class? Pin
Sampath5794-Mar-18 22:42
Sampath5794-Mar-18 22:42 
AnswerRe: How to add tabs to CView Class? Pin
Victor Nijegorodov5-Mar-18 5:13
Victor Nijegorodov5-Mar-18 5:13 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5795-Mar-18 5:41
Sampath5795-Mar-18 5:41 
GeneralRe: How to add tabs to CView Class? Pin
jeron15-Mar-18 9:31
jeron15-Mar-18 9:31 
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 

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.