CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 1999
    Location
    Toulouse - France
    Posts
    135

    Add and remove property page

    Hi!

    I've a dialog with property sheet. And i want add or remove property page when the value of an edit zone is greater than a fixed value.
    So i add a EN_CHANGE function to intercept the changement in the edit box ( the edit box is associated with a spin button) and according to the value i add or remove property page. But i have a assertion error.

    This is my code:

    BOOL CPDUShapeDlg::OnInitDialog()
    {
    CString str;

    CDialog::OnInitDialog();



    if ( m_NbActive <= 8 )
    m_dlgPropSheet.AddPage(&m_Shape1);
    else
    {
    m_dlgPropSheet.AddPage(&m_Shape1);
    m_dlgPropSheet.AddPage(&m_Shape2);
    }


    m_dlgPropSheet.Create(this, WS_CHILD | WS_VISIBLE, 0 );
    m_dlgPropSheet.ModifyStyleEx ( 0, WS_EX_CONTROLPARENT );
    m_dlgPropSheet.ModifyStyle(0, WS_TABSTOP );

    CRect rcSheet;
    GetDlgItem(IDC_PROPSHEET)->GetWindowRect(&rcSheet);
    ScreenToClient(&rcSheet);
    m_dlgPropSheet.SetWindowPos(NULL, rcSheet.left-7, rcSheet.top-7, 0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);



    // Spin counter
    m_Spin.SetRange(m_NbMinUnit, m_NbMaxUnit);
    m_Spin.SetPos(m_NbActive);

    str.Format("%d", m_NbActive);
    SetDlgItemText(IDC_NBUNIT, str);


    return TRUE; // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
    }


    void CPDUShapeDlg::OnChangeNbunit()
    {
    CString buf;
    char *strend;

    GetDlgItem(IDC_NBUNIT)->GetWindowText(buf);
    int nb = (int) strtod(buf, &strend );

    if ( nb > 0 && nb < 17 )
    {
    m_dlgPropSheet.EndDialog(IDC_PROPSHEET);

    if ( m_NbActive <= 8 )
    m_dlgPropSheet.AddPage(&m_Shape1);
    else
    {
    m_dlgPropSheet.AddPage(&m_Shape1);
    m_dlgPropSheet.AddPage(&m_Shape2);
    }


    m_dlgPropSheet.Create(this, WS_CHILD | WS_VISIBLE, 0 );
    m_dlgPropSheet.ModifyStyleEx ( 0, WS_EX_CONTROLPARENT );
    m_dlgPropSheet.ModifyStyle(0, WS_TABSTOP );

    CRect rcSheet;
    GetDlgItem(IDC_PROPSHEET)->GetWindowRect(&rcSheet);
    ScreenToClient(&rcSheet);
    m_dlgPropSheet.SetWindowPos(NULL, rcSheet.left-7, rcSheet.top-7, 0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
    }
    }





    Thanks in advance

    Sandrine



  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: Add and remove property page

    Why not use RemovePage rather than destroying and recreating the propertySheet?
    Also what assert are you getting?
    Chris


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