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

Thread: Create problem

  1. #1
    Join Date
    Apr 2003
    Location
    Montreal
    Posts
    64

    Create problem

    Hi, I use a class derived from CEdit to implement some kind of combo: edit box and buddy spinner with some special function. When I try to "Create" it, some times it works and some times I get an assertion failure but I don't know why since the same code is used every time. In my class, I have a function to create it which execute the following creation line:

    this->Create(WS_CHILD | WS_BORDER | WS_VISIBLE | WS_TABSTOP ,EditBoxRectangle,Parent,IDC_SPINEDITNUMCTRL_EDIT_BOX);

    I have no ides about what could cause an assertion failure. Every time it is called, the parrent is always the same. The ID is always the same too but since messages are handled in this class and not in the parent, I suppose this is not the problem. I checked the rectangle and it is valid.

    If it can help, has I said before, the program doesn't crash every time this line executes but it always crash on the same call.

    Thank you.

  2. #2
    Join Date
    Oct 2002
    Location
    Tx, US
    Posts
    208
    Can u provide the ASSERT information? At what statement its asserting.
    Check the Parent value it might be different each time.

    Vinod

  3. #3
    Join Date
    Apr 2003
    Location
    Montreal
    Posts
    64
    Originally posted by vinodp
    Can u provide the ASSERT information? At what statement its asserting.
    Check the Parent value it might be different each time.

    Vinod
    I think the assertion information you want are the following:

    FILE: WINCORE.CPP
    LINE: 628

    Here is the function:

    void AFXAPI AfxHookWindowCreate(CWnd* pWnd)
    {
    _AFX_THREAD_STATE* pThreadState = _afxThreadState.GetData();
    if (pThreadState->m_pWndInit == pWnd)
    return;

    if (pThreadState->m_hHookOldCbtFilter == NULL)
    {
    pThreadState->m_hHookOldCbtFilter = ::SetWindowsHookEx(WH_CBT,
    _AfxCbtFilterHook, NULL, ::GetCurrentThreadId());
    if (pThreadState->m_hHookOldCbtFilter == NULL)
    AfxThrowMemoryException();
    }
    ASSERT(pThreadState->m_hHookOldCbtFilter != NULL);
    ASSERT(pWnd != NULL);
    ASSERT(pWnd->m_hWnd == NULL); // only do once

    ASSERT(pThreadState->m_pWndInit == NULL); // hook not already in progress
    pThreadState->m_pWndInit = pWnd;
    }

    The assert that fails is :
    ASSERT(pWnd->m_hWnd == NULL); // only do once

    but I have no idea about what this function is supposed to do, nor what this assert is checking.

    For your second question about the parent, I traced the code and I know (I have checked) the parent is always the same. It is quite logic since all the controls are in the same dialog.

    Thank you.

  4. #4
    Join Date
    Apr 2003
    Location
    Montreal
    Posts
    64
    Hi, I've understood what the message was meaning and at the same time what my mistake was. I was creating twice the same window (stupid cut and paste error). I had forgot to change the name between two creation ant the second was trying to create the first again.

    Thank you for your help.

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