CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 1999
    Posts
    11

    Changing Title of propertypage

    Changing the title of a propertypage!

    How can I change the title of a propertypage during runtime after I've added it already to the propertysheet? Because SetWindowText() doesn't work in my application!

    I use VC 5.0!

    Thanks a lot for your reply!
    Ralph


  2. #2
    Join Date
    Jul 1999
    Location
    Moscow, Russia
    Posts
    667

    Re: Changing Title of propertypage

    Hi,
    try this:

    CMyPropSheet::SetPageTitle (int nPage, LPTSTR pszText)
    {
    CTabCtrl* pTab = GetTabControl();
    TC_ITEM ti;
    ti.mask = TCIF_TEXT;
    ti.pszText = pszText;
    pTab->SetItem (nPage, &ti);

    }




    Hope this helps,
    Oleg.


  3. #3
    Join Date
    Jun 1999
    Location
    Toulouse - France
    Posts
    135

    Re: Changing Title of propertypage


    You create your CPropertyPage objects ( m_dlgPage1) and CPropertySheet object ( m_dlgPropSheet)

    1- Add your page:

    /* --- Add the pages --- */
    m_dlgPropSheet->AddPage(m_dlgPage1);




    2- Change its title

    /* --- Add the title --- */
    m_dlgPage1->m_psp.pszTitle = _T("My title");
    m_dlgPage1->m_psp.dwFlags |= PSP_USETITLE;




    Bye

    Sandrine


  4. #4
    Join Date
    Apr 1999
    Posts
    11

    Re: Changing Title of propertypage

    Thanks a lot for your reply!
    It works!

    have a nice day !
    Ralph


  5. #5
    Join Date
    Apr 1999
    Posts
    11

    Re: Changing Title of propertypage

    Thanks a lot for your reply!
    But this suggestion will only work BEFORE you call the AddPage() methode!

    have a nice day !

    Ralph


  6. #6
    Join Date
    Jun 1999
    Location
    Toulouse - France
    Posts
    135

    Re: Changing Title of propertypage



    ?????

    This is my code ( A part of the OnInitDialogDialog function of the dialog box which contains the property sheet). And It works...


    // Property Sheet
    /* --- Create the property sheet object --- */
    m_dlgPropSheet = new CPropertySheet;

    /* --- Create Property Page Object --- */
    m_dlgPage1 = new CConvSimulPage;
    m_dlgPage2 = new CConvSimulPagebis;


    /* --- Add the pages --- */
    m_dlgPropSheet->AddPage(m_dlgPage1);
    m_dlgPropSheet->AddPage(m_dlgPage2);

    /* --- Add the title --- */
    m_dlgPage1->m_psp.pszTitle = _T("Solar Array");
    m_dlgPage1->m_psp.dwFlags |= PSP_USETITLE;
    m_dlgPage2->m_psp.pszTitle = _T("Battery");
    m_dlgPage2->m_psp.dwFlags |= PSP_USETITLE;


    /* --- Initialization and display the property sheet --- */
    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);

    .....






    Something wrong??

    Bye

    Sandrine


  7. #7
    Join Date
    Apr 1999
    Posts
    11

    Re: Changing Title of propertypage

    Thanks for the complete code, but I'm not sure whether the changing of the title will work after the "m_dlgPropSheet->Create()". With other words:
    after OnInitDialog() and when your dialog appears
    you should be able to change the title by pressing a certain button (for example) in your dialogbox.

    I tested the other suggestion and it works in this
    way.

    Thanks a lot again!
    bye
    Ralph



  8. #8
    Guest

    Re: Changing Title of propertypage

    I tried Sandrine's method because it looked _much_ simpler. It works fine after the OnCreate of the PropertySheet (though I do use it before the DoModal, that shows the property sheet). The only caveat is that Sandrine's code declares a PropertyPage, but references it as a *pointer* to a PropertyPage. The '->' should be a '.' (period).


  9. #9
    Guest

    Re: Changing Title of propertypage

    It works fine.
    Thanks


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