Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

About CPropertySheet, CPropertyPage and CTabCtrl

Posted on 1997-12-09
6
Medium Priority
?
864 Views
Last Modified: 2013-11-20
I have created a propertySheet with 3 propertyPages :

 CMyPropertySheet MySheet("Test sheet");
 CMyPage1         Page1;
 CMyPage2         Page2;
 CMyPage3         Page3;

 MySheet.AddPage(&Page1);
 MySheet.AddPage(&Page2);
 MySheet.AddPage(&Page3);

My question is :

- How can I subclass the CTabCtrl returned by MySheet.GetTabControl()
  to my class : CMyTabCtrl. Because I want to use owner draw the
  Tab control associated with my PropertySheet and that all messages
  are received by my class.

  I have try do to this in CMyPropertySheet :
 
  BOOL CMyPropertySheet::OnInitDialog()
   {
    CMyTabCtrl *pTab = (CMyTabCtrl *)GetTabControl();

    SubclassWindow(pTab->m_hWnd); //--> Assertion fail, Why ?

    return CPropertySheet::OnInitDialog();
   }
 

- I want to use owner draw because I want that some tab controls
  are disabled (text in gray).

- Is there a different solution to do this ?

- Can some one send my a sample that made something like this
  at tech@gerelec.com

                              Thanks,
                              MIKE
0
Comment
Question by:mike_marquet
  • 3
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 150 total points
ID: 1311880
Yuo msitake is that you are trying to sunclass tab control by property sheet. Do the following. Derive class from CTabCtrl and add member variable of this type to your Property sheet class declaration( say m_YourTabCtrl). The call
m_YourTabCtrl->SubclassWindow(GetTabControl()->GetSfeHwnd());
0
 

Expert Comment

by:kalaru
ID: 1311881
I dont think this will work either! There seems to be a problem during the evaluation of GetTabControl(). There's an unhandled exception  then.
0
 

Author Comment

by:mike_marquet
ID: 1311882
What can I do then ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:galkin
ID: 1311883
I specially built project to check it. It works!. Follow the my steps to subclass property sheet tab control.

1.Derive you property sheet class from MFC CPropertySheet. You called it CMyPropertySheet.

2.Derive class from CTabCtrl say CSubclassedTabCtrl and add member variable of such a class to your property sheet class
CSubclassedTabCtrl m_SubclassedTabCtrl.

2.Overwrite CMyPropertySheet OnInitDialog function. That's you did. Add the following code

CTabCtrl *pTabCtrl = GetTabControl();
ASSERT(pTabCtrl);
m_SubclassedTabCtrl.SubclassWindow(pTabCtrl->m_hWnd);

Now you can add whatever message handlers to CSubclassedTabCtrl class and handle tab control messages in this class.

 
 
0
 

Author Comment

by:mike_marquet
ID: 1311884
Thanks for your help.
0
 

Author Comment

by:mike_marquet
ID: 1311885
I have try this, and it works but only some messages are handled by the CSubclassedTabCtrl class
--> DefWindowProc, PreTranslateMessage, ...
but WM_DRAWITEM, WM_MEASUREITEM, WM_CTLCOLOR, ... never arrive in this new class. Why ?
What can I do for handling this messages in this class ?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

972 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