CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: CEdit::Create()

  1. #1
    Join Date
    Jun 1999
    Location
    Oregon, USA
    Posts
    26

    CEdit::Create()

    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




  2. #2
    Join Date
    Apr 1999
    Location
    Toronto, ON
    Posts
    713

    Re: CEdit::Create()

    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

  3. #3
    Join Date
    Aug 1999
    Location
    CA
    Posts
    23

    Re: CEdit::Create()

    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


  4. #4
    Join Date
    Jun 1999
    Location
    Oregon, USA
    Posts
    26

    Re: CEdit::Create()

    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured