Click here to Skip to main content
14,666,876 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
Questionconfused in static member function of class. Pin
Member 87269408-Mar-16 19:01
MemberMember 87269408-Mar-16 19:01 
AnswerRe: confused in static member function of class. Pin
Richard MacCutchan8-Mar-16 21:37
mveRichard MacCutchan8-Mar-16 21:37 
GeneralRe: confused in static member function of class. Pin
Member 872694014-Mar-16 19:19
MemberMember 872694014-Mar-16 19:19 
QuestionAssertion failure While Editing CTreeView Label. Pin
shanmugarajaa8-Mar-16 9:04
Membershanmugarajaa8-Mar-16 9:04 
QuestionRe: Assertion failure While Editing CTreeView Label. Pin
jeron18-Mar-16 9:43
Memberjeron18-Mar-16 9:43 
QuestionRe: Assertion failure While Editing CTreeView Label. Pin
David Crow8-Mar-16 16:41
MemberDavid Crow8-Mar-16 16:41 
AnswerRe: Assertion failure While Editing CTreeView Label. Pin
_Flaviu8-Mar-16 20:37
Member_Flaviu8-Mar-16 20:37 
QuestionApplication crashes on calling OnPaint() function!? Pin
Kiran Satish7-Mar-16 16:51
MemberKiran Satish7-Mar-16 16:51 
I have a dialog based MFC application that I am rewriting in VS2010 from its original VC++ 6.0 source. Everything works fine in VC++ 6.0

The main dialog contains many child dialogs (not pop-ups) in which one child dialog is used to draw a plot based on the values sent from main dialog. The main dialog calls a function (Draw_Points) within the child dialog and the child dialog draws it and it does as long as the plot hits the edge and then it calls OnPaint message to refresh the dialog so that it can start afresh from left.

void CPlotDlg::Draw_Points(double value1, double value2)
{
	if(m_LastPoint1.x < (m_time_rect.right-2))
	{
		// Store the data for later retrieval	
		m_CurrentPoint1.x = m_LastPoint1.x + 1;
		m_CurrentPoint2.x = m_LastPoint2.x + 1;
// Do some calculations
		m_Data1[m_DataCounter] = value1;
		m_Data2[m_DataCounter++] = value2;
		CWnd *Ctrl = GetDlgItem(IDE_PLOTS);
		CDC *cdc = Ctrl->GetDC();
		HGDIOBJ original = NULL;
		original = cdc->SelectObject(GetStockObject(DC_PEN));
		cdc->SelectObject(pen1);
		cdc->MoveTo(m_LastPoint1);
		cdc->LineTo(m_CurrentPoint1);
		cdc->SelectObject(pen2);
		cdc->MoveTo(m_LastPoint2);
		cdc->LineTo(m_CurrentPoint2);	
		cdc->SelectObject(original);
		Ctrl->ReleaseDC(cdc);
		m_LastPoint1 = m_CurrentPoint1;
		m_LastPoint2 = m_CurrentPoint2;
	}
	else
	{
		OnPaint();
		Reset_PlotData();			
	}
}

void CPlotDlg::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: Add your message handler code here
	if(m_BUpdate)
	{
		CDialogEx::OnPaint();
		CWnd *Ctrl = GetDlgItem(IDE_PLOTS);
		Ctrl->InvalidateRect(NULL,true);
		Ctrl->UpdateWindow();
	}
	// Do not call CDialogEx::OnPaint() for painting messages
}


It crashes when the Draw_points function calls OnPaint function in its else section, and when OnPaint() function executes CPaintDC dc(this);

Any suggestions?

thanks
PKNT

AnswerRe: Application crashes on calling OnPaint() function!? Pin
Richard MacCutchan7-Mar-16 21:59
mveRichard MacCutchan7-Mar-16 21:59 
GeneralRe: Application crashes on calling OnPaint() function!? Pin
Kiran Satish8-Mar-16 3:40
MemberKiran Satish8-Mar-16 3:40 
GeneralRe: Application crashes on calling OnPaint() function!? Pin
Richard MacCutchan8-Mar-16 5:53
mveRichard MacCutchan8-Mar-16 5:53 
SuggestionRe: Application crashes on calling OnPaint() function!? Pin
David Crow8-Mar-16 3:40
MemberDavid Crow8-Mar-16 3:40 
GeneralRe: Application crashes on calling OnPaint() function!? Pin
Kiran Satish8-Mar-16 4:31
MemberKiran Satish8-Mar-16 4:31 
Questionhow execute query in access database with CRecordset file? Pin
Le@rner4-Mar-16 18:05
MemberLe@rner4-Mar-16 18:05 
AnswerRe: how execute query in access database with CRecordset file? Pin
Victor Nijegorodov5-Mar-16 4:51
MemberVictor Nijegorodov5-Mar-16 4:51 
QuestionRe: how execute query in access database with CRecordset file? Pin
David Crow5-Mar-16 16:55
MemberDavid Crow5-Mar-16 16:55 
QuestionAT command serially via C code Pin
Member 123621671-Mar-16 6:57
MemberMember 123621671-Mar-16 6:57 
AnswerRe: AT command serially via C code Pin
Jochen Arndt1-Mar-16 7:48
professionalJochen Arndt1-Mar-16 7:48 
QuestionPassing macro parameters via function Pin
Vaclav_1-Mar-16 4:48
MemberVaclav_1-Mar-16 4:48 
AnswerRe: Passing macro parameters via function Pin
Richard Andrew x641-Mar-16 5:58
professionalRichard Andrew x641-Mar-16 5:58 
GeneralRe: Passing macro parameters via function Pin
Vaclav_1-Mar-16 6:08
MemberVaclav_1-Mar-16 6:08 
AnswerRe: Passing macro parameters via function Pin
Richard MacCutchan1-Mar-16 10:52
mveRichard MacCutchan1-Mar-16 10:52 
GeneralRe: Passing macro parameters via function Pin
Vaclav_2-Mar-16 4:09
MemberVaclav_2-Mar-16 4:09 
GeneralRe: Passing macro parameters via function Pin
Richard MacCutchan2-Mar-16 5:06
mveRichard MacCutchan2-Mar-16 5:06 
GeneralRe: Passing macro parameters via function Pin
Vaclav_3-Mar-16 4:34
MemberVaclav_3-Mar-16 4:34 

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.