Solved

About CPropertySheet, CPropertyPage and CTabCtrl

Posted on 1997-12-09
6
786 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now