Derive a custom control from a CEdit and then implement OnPaint
You'll get something like the following where you will use your paint dc for drawing shapes...
class CShapeEdit : public CEdit
{
DECLARE_DYNAMIC(CShapeEdit)
public:
CShapeEdit();
virtual ~CShapeEdit();
protected:
DECLARE_MESSAGE_MAP()
afx_msg void OnPaint();
};
BEGIN_MESSAGE_MAP(CShapeEdit, CEdit)
ON_WM_PAINT()
END_MESSAGE_MAP()
IMPLEMENT_DYNAMIC(CShapeEdit, CEdit)
CShapeEdit::CShapeEdit()
{
}
CShapeEdit::~CShapeEdit()
{
}
void CShapeEdit::OnPaint()
{
CPaintDC dc(this);
}
Now in your dialog class, which hosts the custom edit control, you add a member variable
CShapeEdit m_ShapeEdit;
In the implementation of your dialog class bind it to the UI using DDX
DDX_Control(pDX, IDC_SHAPE_EDIT, m_ShapeEdit);
Then later on cause it to redraw itself with
m_ShapeEdit.RedrawWindow();
Now you have a canvas with which to explore the Win32 GDI!!!!