What cause " stack overflow " ?
I have seen several times this problem in others program, I don't know
why?.Now it turn to me.Below is a part of my program:
// TrackPanel.h : header file
//
///////////////////////////////////////////////////////////////////////////=
//
// CTrackPanel window
class CTrackPanel : public CStatic
{
// Construction
public:
CTrackPanel();
// Attributes
private:
COLORREF m_bgcolor; // =B1=B3=BE=B0=D1=D5=C9=AB
COLORREF m_linecolor; // =D7=F8=B1=EA=CF=DF=D1=D5=C9=AB
COLORREF m_valuecolor; // =D7=F8=B1=EA=D6=B5=D1=D5=C9=AB
COLORREF m_targetcolor1; // =C4=BF=B1=EA1=D1=D5=C9=AB
COLORREF m_targetcolor2; // =C4=BF=B1=EA2=D1=D5=C9=AB
COLORREF m_targetcolor3; // =C4=BF=B1=EA3=D1=D5=C9=AB
CString m_xtitle; // =BA=E1=D6=E1=C3=FB=B3=C6
CString m_ytitle; // =D7=DD=D6=E1=C3=FB=B3=C6
CString m_title; // =D7=F3=C9=CF=BD=C7=B5=C4=B1=EA=CC=E2
int m_xrange; // =BA=E1=D6=E1=D7=EE=B4=F3=D6=B5
int m_yrange; // =D7=DD=D6=E1=D7=EE=B4=F3=D6=B5
int m_unit; // =B5=A5=D4=AA=D6=B5
int m_minrange; // =D7=EE=D0=A1=CF=D4=CA=BE=B7=B6=CE=A7
int m_targetpnt; // =C4=BF=B1=EA=B5=C4=D6=B1=BE=B6=A3=AC=D3=C3=CF=F1=CB=D8=
=CA=FD=B1=ED=CA=BE
CBrush m_bgbrush; // =B1=B3=BE=B0=CB=A2=D7=D3
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTrackPanel)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CTrackPanel();
// Generated message map functions
protected:
//{{AFX_MSG(CTrackPanel)
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
///////////////////////////////////////////////////////////////////////////=
//
// TrackPanel.cpp : implementation file
//
#include "stdafx.h"
#include "AttackAngleTest.h"
#include "TrackPanel.h"
///////////////////////////////////////////////////////////////////////////=
//
// CTrackPanel
CTrackPanel::CTrackPanel()
{
m_bgcolor = RGB(0x00, 0x00,0xf0); //=C7=B3=C0=B6=B1=B3=BE=B0
m_bgcolor = 0x00f00000; //=C7=B3=C0=B6=B1=B3=BE=B0
m_linecolor = 0x00ffffff; // =B0=D7=C9=AB=D7=F8=B1=EA=CF=DF
m_valuecolor = 0x00ffffff; // =D7=F8=B1=EA=D6=B5=D3=C3=B0=D7=C9=AB
m_targetcolor1 = 0x0000ffff; // =C4=BF=B1=EA1=D3=C3=BB=C6=C9=AB
m_targetcolor2 = 0x0000ff00; // =C4=BF=B1=EA2=D3=C3 =CC=C9=AB
m_targetcolor3 = 0x000000ff; // =C4=BF=B1=EA3=D3=C3=BA=EC=C9=AB
m_unit = 20; // 10=C3=D7
m_minrange = 100; // =D7=EE=D0=A1=CF=D4=CA=BE=B7=B6=CE=A7100=C3=D7
m_title = "=B5=A5=CE=BB=A3=BA=C3=D7"; // =D7=F3=C9=CF=BD=C7=B1=EA=CC=E2
m_xtitle = "X"; // =BA=E1=D6=E1=C3=FB=B3=C6"X"
m_ytitle = "Y"; // =D7=DD=D6=E1=C3=FB=B3=C6"Y"
m_targetpnt = 3; // =C4=BF=B1=EA=B5=C4=D6=B1=BE=B63=B8=F6=CF=F1=CB=D8=B5=
=E3
}
CTrackPanel::~CTrackPanel()
{
}
BEGIN_MESSAGE_MAP(CTrackPanel, CStatic)
//{{AFX_MSG_MAP(CTrackPanel)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////=
//
// CTrackPanel message handlers
HBRUSH CTrackPanel::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
m_bgbrush.CreateSolidBrush(m_bgcolor);
pDC->SetBkColor(m_bgcolor);
return m_bgbrush;
// TODO: Return a non-NULL brush if the parent's handler should not be
called
//return NULL;
}
The problem occurs in the
constructor:CTrackPanel::CTrackPanel(){......}. I run this program in
Visual studio 6.0, windows xp, sometimes it report "stack overflow" and
sometimes it report " not enough memory", mostly it report " invalid
access memory......". Who could give me some sugestion? Thank you!