Solved

About CPropertySheet, CPropertyPage and CTabCtrl

Posted on 1997-12-09
6
813 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 50 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
Industry Leaders: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 83
how to you can convert your project to a Maven project and the Maven plugin should download the source 1 51
pre4 challenge 19 110
Thin secure Windows 10 5 107
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.

756 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