Solved

Changing captions on the CPropertyPage tab...

Posted on 1997-09-17
1
667 Views
Last Modified: 2013-11-19
How does one go about setting the tab caption for a derived CPropertyPage that is being used in a CPropertySheet. I know the initial caption can be set in the resource editor when designing the dialog for the property page, but I would like to change the caption dynamically on the fly.

I am assuming to use the CWnd::SetWindowText for the property page, but not sure where to handle this. I have tried setting it in the CPropertySheet OnInitDialog handler, but the property page windows have not yet been created, thus calling the SetWindowText errors with a null window handle.

class CCPage1 : public CPropertyPage
{
...
};

class CCPage2 : public CPropertyPage
{
...
};

class CMyPSheet : public CPropertySheet
{
public:
      // would like create multiple CCpage1 style property pages
    CCPage1 m_page1[2];
    CCPage2 m_page2;

...
};

...

CMyPSheet psheet;

if (psheet.DoModal() == IDOK)
{
   ...
}

...

At some point, I need to set the tab caption for m_page1[0] and m_page1[1].

  i.e.  m_page1[0].SetWindowText("Tab One");
        m_page1[1].SetWindowText("Tab Two");

Thanks for any advice,

Don ...
0
Comment
Question by:taeguk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
RONSLOW earned 50 total points
ID: 1306481
SetWindowText wil not do it - this is bause there are two things here - the property page is displayed without a caption, so setting window text has no effect.  The tab text is in the tab control (which owns the actual page).  When created, the tab gets its text from the property page windows text, but after that they are not linked.  You have to explicitly tell the tab to change.

This is how to do it,,,

TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
tcItem.pszText = "your new caption";
GetTabControl()->SetItem(x, &tcItem );

where x is the tab number.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question