I want to add simple Cedit to my derived GUI class from CWnd. This class is simple container and treat the same as Panel in MFC. in constructor of class I add simple CEdit instance in the class. but the when I instantiated the panel in client dialog, the panel shows but the button does not show.why it doesn't show. The panel code
Panel header file
#pragma once
#include "afxwin.h"
class CPanel :
public CWnd
{
public:
CPanel(void);
~CPanel(void);
virtual void PreSubclassWindow();
virtual void DoDataExchange(CDataExchange* pDX);
CEdit *txt;
DECLARE_MESSAGE_MAP()
};
panel source file
#include "stdafx.h"
#include "Panel.h"
CPanel::CPanel(void)
{
WNDCLASS wndcls;
HINSTANCE hins=AfxGetInstanceHandle();
if(!(::GetClassInfo(hins,_T("CPanelCtrl"),&wndcls))){
wndcls.style=CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW;
wndcls.lpfnWndProc=::DefWindowProc;
wndcls.cbClsExtra=wndcls.cbWndExtra=0;
wndcls.hInstance=hins;
wndcls.hIcon=NULL;
wndcls.hCursor=AfxGetApp()->LoadStandardCursor(IDC_CROSS );
wndcls.hbrBackground=(HBRUSH)(COLOR_3DFACE+13);
wndcls.lpszMenuName=NULL;
wndcls.lpszClassName=_T("CPanelCtrl");
txt=new CEdit();
txt->Create(ES_PASSWORD,CRect(10,10,25,35),this,1);
if (!AfxRegisterClass(&wndcls))
{
AfxThrowResourceException();
return;
}
else{
return;
}
}
}
CPanel::~CPanel(void)
{
}
void CPanel::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
CWnd::PreSubclassWindow();
}
void CPanel::DoDataExchange(CDataExchange* pDX)
{
// TODO: Add your specialized code here and/or call the base class
CWnd::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CPanel, CWnd)
END_MESSAGE_MAP()
In dialog box in OninitDialog method I do like this
panel=new CPanel();
panel->Create(L"CPanelCtrl",L"Hello ", WS_VISIBLE , CRect(70, 70, 400, 200), this, 1);