Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. DialogBox Create Fails

DialogBox Create Fails

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi My code for Create (of a dialog box fails) in MFC base code specifically the line in bold when I try to Create for a DialogBox I have DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC in the respective sources though I don't think that is a issue one way or a other Don't know why

    main_app->myshow_storageptr = new Show_storage();
    main_app->myshow_storageptr->AssertValid();
    main_app->myshow_storageptr->Create(IDD_DIALOG6,NULL);

    MFC code from wincore

    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;
    
    D L 2 Replies Last reply
    0
    • F ForNow

      Hi My code for Create (of a dialog box fails) in MFC base code specifically the line in bold when I try to Create for a DialogBox I have DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC in the respective sources though I don't think that is a issue one way or a other Don't know why

      main_app->myshow_storageptr = new Show_storage();
      main_app->myshow_storageptr->AssertValid();
      main_app->myshow_storageptr->Create(IDD_DIALOG6,NULL);

      MFC code from wincore

      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;
      
      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      What type of object is Show_storage? What does Create() return? Where is your code called from, or what is it in response to?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      F 1 Reply Last reply
      0
      • D David Crow

        What type of object is Show_storage? What does Create() return? Where is your code called from, or what is it in response to?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        A CDialog Create never return it aborts causes an an exception In the assert highlighted in bold

        1 Reply Last reply
        0
        • F ForNow

          Hi My code for Create (of a dialog box fails) in MFC base code specifically the line in bold when I try to Create for a DialogBox I have DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC in the respective sources though I don't think that is a issue one way or a other Don't know why

          main_app->myshow_storageptr = new Show_storage();
          main_app->myshow_storageptr->AssertValid();
          main_app->myshow_storageptr->Create(IDD_DIALOG6,NULL);

          MFC code from wincore

          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;
          
          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          The assert fails because the CWnd* does not point to an object that contains a valid Window handle. Something in your code has not been initiailised correctly, or you are calling Create from outside of a Window class. What class is Show_storage?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups