Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

About CPropertySheet, CPropertyPage and CTabCtrl

Posted on 1997-12-09
6
Medium Priority
?
846 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
[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
  • 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
Independent Software Vendors: 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

721 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