Click to See Complete Forum and Search --> : CEdit::Create()


Be_ginner
August 24th, 1999, 03:55 PM
I have a CFormView that I want to create my own CEdit control on. I have the following defined in my .h file for the view:
...
CEdit *m_Edit;
...

in my implementation code I have in OnInitialUpdate():

m_Edit = new CEdit;
if (m_Edit != NULL)
{
if (m_Edit->Create(WS_CHILD | WS_VISIBLE,
CRect(20, 20, 120, 120),
this,
IDC_MYEDIT) == NULL)
{
AfxMessageBox("Failed to create CEdit");
return;
}
m_Edit->ShowWindow(SW_SHOW);
}

The CEdit fails to display. I basically followed the example "Adding Controls by Hand", the only difference is that I am using a CFormView instead of a CDialog, and I am using a CEdit *m_Edit instead of a CEdit m_Edit.

Why does this not work?
Be_ginner

Dmitriy
August 24th, 1999, 07:50 PM
Try to get error:
DWORD dwError=GetLastError();
then check it with ErrorLookUp utility. I'm sure you just cannot create CEdit on the View.


Dmitriy, MCSE

ingrilli
August 24th, 1999, 10:02 PM
you don't need to do a GetLastError:
after a line of code that would have resulted in a call to SetLastError, all you have to do is watch (shift-f9) for 'err', and that will have the last error code

Be_ginner
August 25th, 1999, 01:27 PM
Well,

After not getting any errors, I double-checked my create code and I wasn't using WS_CHILD. Therefore, no error and the control just wasn't displayed. After adding WS_CHILD, it's working great.

Thanks for your ideas though. They helped me find that the error was easier than I thought.
Be_ginner