Re: Adding Edit Control to MainFrame.
- From: "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 20 Apr 2010 12:08:06 -0700
"Saint Atique" <unix9n@xxxxxxxxx> wrote in message news:1db59444-17d4-4bc1-bc7a-1adcf3b75b9b@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm trying to add an Edit Control to MainFrame. I'm creating an
instance of CEdit in the paint message like this:
void SAFrame::OnPaint() {
CFrameWnd::OnPaint();
CEdit *PEdit = new CEdit;
PEdit->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP |
WS_BORDER,
CRect(10, 50, 150, 70), this, 0x1552);
}
But the control is not displayed. I think you have better ideas.
Don't call CFrameWnd::OnPaint() from within SAFrame::OnPaint(). It is not necessary and causes an error because EndPaint() is called before you have a chance to paint.
Move the code to create the edit control into SAFrame::OnCreate() which is called once, not every time the window is painted.
Rename PEdit to m_edit and make it a member of SAFrame. (Not a pointer, but a CEdit instance). Child windows like this are meant to have member instances and not pointers (due to the way the object is destroyed).
-- David
.
- Follow-Ups:
- Re: Adding Edit Control to MainFrame.
- From: Oliver Regenfelder
- Re: Adding Edit Control to MainFrame.
- From: Scott McPhillips [MVP]
- Re: Adding Edit Control to MainFrame.
- References:
- Adding Edit Control to MainFrame.
- From: Saint Atique
- Adding Edit Control to MainFrame.
- Prev by Date: Adding Edit Control to MainFrame.
- Next by Date: How to handle Windows 7 screen resolution change?
- Previous by thread: Adding Edit Control to MainFrame.
- Next by thread: Re: Adding Edit Control to MainFrame.
- Index(es):
Relevant Pages
|