Solved

About CPropertySheet, CPropertyPage and CTabCtrl

Posted on 1997-12-09
6
812 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

837 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