Re: Subclassing CStatic - re: OnPaint()
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
news:eKmMbh6THHA.5016@TK2MSFTNGP05.phx.gbl...
nappy wrote:
I am trying to create a grid class using a CStatic (picture box) and
after subclassing it does not receive the WM_PAINT message. The CStatic
is in a Cdialog. Any hints would be appreciated.
I do have the ON_WM_PAINT in teh subclass's message map and an
appropriate OnPaint function..
Make sure you have changed the control's ID to something unique, instead
of IDC_STATIC.
If that's not the problem, post the code that subclasses it and related
declarations.
--
Scott McPhillips [VC++ MVP]
Yes I called it : IDC_IR_IMAGEBOX
This is the header for the subclass:
class CGridCtrl : public CStatic
{
// Construction
public:
CGridCtrl::CGridCtrl();
// Attributes
public:
// Operations
public:
// Overrides
// Implementation
public:
virtual ~CGridCtrl();
// Generated message map functions
protected:
void OnDraw (CDC *pdc);
void OnPaint ();
BOOL OnEraseBkgnd (CDC *pDC);
void DrawIRGrid(CDC *cDC);
void DrawBkg(CDC *cDC);
int m_IR_Xpts;
int m_IR_Ypts;
int m_BlockWidth;
int m_BlockHeight;
CBitmap * m_pBmp1;
CDC m_memDC ;
CDC *m_pCdc;
DECLARE_MESSAGE_MAP()
};
I can tell the class is being instantiated by placing a debug point in the
Constructor:
BEGIN_MESSAGE_MAP(CGridCtrl, CStatic)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
CGridCtrl::CGridCtrl()
{
m_pBmp1 = NULL; // DEBUG POINT HERE>.
}
..... And here's the ONPaint()
void CGridCtrl::OnPaint ()
{
CPaintDC pdc(this); // device context for painting
OnDraw(&pdc);
}
Thanks