从CWnd派生的CEditTrack,用如下创建的实列,可是显示不出来,什么也看不到。m_EditTrack.Create( _T("EDITTRACK"),NULL,
WS_VISIBLE|WS_CHILD|WS_TABSTOP,
CRect( 50, 400,800,250 ),this,0
); CEditTrack是这样写的:class CEditTrack : public CWnd
{
protected:
DECLARE_DYNCREATE(CEditTrack)public:
CEditTrack(){
RegisterWindowClass();
} virtual ~CEditTrack(); virtual BOOL Create( LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,CWnd* pParentWnd,
UINT nID, CCreateContext* pContext = NULL)
{
//这里我什么也没写
return CWnd::Create( lpszClassName,lpszWindowName,
dwStyle,rect,pParentWnd,nID,pContext );
} BOOL RegisterWindowClass()
{
WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle(); if (!(::GetClassInfo(hInst, EDITTRACK_CLASSNAME, &wndcls)))
{
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor=AfxGetApp()->LoadStandardCursor (IDC_ARROW);
wndcls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = EDITTRACK_CLASSNAME; return AfxRegisterClass(&wndcls));
} return TRUE;
}private:
void DrawScale( CDC *lpDC );
void DrawGrade( CDC *lpDC,RECT rect,bool UpDown );
void DrawRuler( CDC *lpDC );
void DrawSeparateLine( CDC *lpDC );
void DrawLinePos( CDC *lpDC );
private:
void DrawRect(CDC *lpDC,RECT rect,int Color,bool Selected);
void DrawTrack( CDC *lpDC,enumTrack TrackFlag );protected:
//{{AFX_MSG(CEditTrack)
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG DECLARE_MESSAGE_MAP()}
WS_VISIBLE|WS_CHILD|WS_TABSTOP,
CRect( 50, 400,800,250 ),this,0
); CEditTrack是这样写的:class CEditTrack : public CWnd
{
protected:
DECLARE_DYNCREATE(CEditTrack)public:
CEditTrack(){
RegisterWindowClass();
} virtual ~CEditTrack(); virtual BOOL Create( LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,CWnd* pParentWnd,
UINT nID, CCreateContext* pContext = NULL)
{
//这里我什么也没写
return CWnd::Create( lpszClassName,lpszWindowName,
dwStyle,rect,pParentWnd,nID,pContext );
} BOOL RegisterWindowClass()
{
WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle(); if (!(::GetClassInfo(hInst, EDITTRACK_CLASSNAME, &wndcls)))
{
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor=AfxGetApp()->LoadStandardCursor (IDC_ARROW);
wndcls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = EDITTRACK_CLASSNAME; return AfxRegisterClass(&wndcls));
} return TRUE;
}private:
void DrawScale( CDC *lpDC );
void DrawGrade( CDC *lpDC,RECT rect,bool UpDown );
void DrawRuler( CDC *lpDC );
void DrawSeparateLine( CDC *lpDC );
void DrawLinePos( CDC *lpDC );
private:
void DrawRect(CDC *lpDC,RECT rect,int Color,bool Selected);
void DrawTrack( CDC *lpDC,enumTrack TrackFlag );protected:
//{{AFX_MSG(CEditTrack)
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG DECLARE_MESSAGE_MAP()}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货