Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
GetDlgItem() get NULL the 3rd time after first 2 successes

Unanswered GetDlgItem() get NULL the 3rd time after first 2 successes

  • Monday, March 12, 2012 12:29 PM
     
     

    vs2008,win7 32bits,vc++

    I use a CPropertyPage dlg on a CPropertySheet;

    The dlg have a ActiveX WebBrowser control and a button1;

     ON_BN_CLICKED(IDC_BTN1,OnBnClickedBtnDisp)

    void DlgParaAuditPage_Layout::OnBnClickedBtnDispstd()

    {

     m_bDisplay=!m_bDisplay;
     CWnd*pWeb=GetDlgItem(IDC_EXPLORER); //ActiveX WebBrowser control
     ASSERT(pWeb);
     pWeb->ShowWindow(m_bDisplay?SW_SHOW:SW_HIDE);

    }

    the original state  m_bDisplay==false;

    when I press IDC_BTN1 ->1 time, pWeb show

    ->2 time, pWeb Hide

    But when I ->3rd time press,then ASSERT(pWeb) fired!

    I just don't know why?

    Any suggestion is good!


    Jzq


    • Edited by Jiazhiqiang Monday, March 12, 2012 12:30 PM
    •