Solved

Tabs under tab(PropertySheet under PropertyPage)

Posted on 1997-12-15
1
215 Views
Last Modified: 2013-11-19
I am facing a strange problem regarding tabs under a tab. I have createda dialog containing a PropertySheet say MainSheet . In this sheet , I am adding 4 pages . One of the pages , further contains a PropertySheet,Say ChildSheet , in which I am adding 7 pages.
I am using MSVC 5 - windows 95 and using the Application wizard and Class wizard for most of the code generation .
Now on executing the application , I am facing this strange problem . If initially , I click any tab twice in the ChildSheet (why twice ? One for making that tab , an active page and second for setting the focus on that tab), then I get no trouble and clicking any tab in the MainSheet works smoothly.Note that I have to do this only once.Afterwords , this restriction is relaxed :-)

Now if I don't do that , i.e setting focus to any tab in the ChildSheet , before trying to click any tab in the Mainsheet (accept the one , who is the parent of ChildSheet ) the application is HANGED .

So this application needs a bit smarter user for handling :-) To run smoothly  or to be hanged.

ONE SOLUTION

I have got with me one solution for that , But I am afraid that it is concerned with the performance issue as in future these tabs will be having high interaction with data base server .

The above mentioned problem won't occur , If I create the ChildSheet every time , in OnSetActive() message and delete it in OnKillActive() message in that tab of MainSheet which is responsible for creating the childSheet.However , in the above Strange Case , I was creating the ChildSheet once in the OnInitDialog().

Any suggestion for the appropriate solution is highly appreciated.One more thing, I also tried to programmatically put the focus on any tab in the childSheet in the start of application execution but it won't work .

0
Comment
Question by:usmani
1 Comment
 
LVL 1

Accepted Solution

by:
WBerthin earned 100 total points
ID: 1312299
Hi usmani,

The trick to putting a CPropertySheet in a CPropertyPage
 (nesting Property Sheets) is to create a CFrameWnd to
contain the nested Property Sheet.

Here is how you put it all together. Lets assume that
you have the outer property sheet and property page,
and start from there.

Step 1 Create the Inner Property Sheet and its pages:
Open the Insert menu,chose component, and double
click Property Sheet to get the "Insert Property Sheet"
Wizard. Then create a property sheet using the Wizard, BUT
change the default type to Modless not Modal. Also change
the name of the class that will have access to your new
CPropertySheet to your owner owner CPropertyPage.
Allow the WIzard to finish its creation.

Step 2 Change the modless inner property sheet contained
in a CMiniFrameWnd to a CFrameWnd contained item. Do
this by opening the CPropertyFrame class that the Wizard
just created for the inner property sheet, and use the editor
to search CMiniFrameWnd and replace it with CFrameWnd.
Do this in both the .cpp and .h files for the class. The CFrameWnd
class you create contains all the code you need thanks to
the Wizard (so I won't reproduce it here).

Step 3 Attach the inner property frame to the outer property
page. The wizard will create a function called OnProperties()
in your owner CPropertyPage. Cut its contents entirely and
paste then into your OnInitDialog for your owner Property
Page. Change the two lines as below. I have commented out
the old lines created by the Wizard so the changes are easily
seen.

BOOL CMyPropertyPage1::OnInitDialog()
{
     CPropertyPage::OnInitDialog();
      
     if (m_pPropFrame == NULL)
     {
         m_pPropFrame = new CPropertyFrame;
         CRect rect(0, 0, 0, 0);
         CString strTitle;
          VERIFY(strTitle.LoadString(IDS_PROPSHT_CAPTION1));

          if (!m_pPropFrame->Create(NULL, strTitle,
//             WS_POPUP | WS_CAPTION | WS_SYSMENU, rect, this))
                     WS_CHILD | WS_VISIBLE, rect, this))
               {
                    delete m_pPropFrame;
                    m_pPropFrame = NULL;
//                  return;
                    return TRUE;
               }
                     m_pPropFrame->CenterWindow();
          }
      
          if (m_pPropFrame != NULL && !m_pPropFrame->IsWindowVisible())
               m_pPropFrame->ShowWindow(SW_SHOW);

          return TRUE;  // return TRUE unless you set the focus to a control
                    // EXCEPTION: OCX Property Pages should return FALSE
}

Step 4 Delete the OnProperties function created by the Wizard
form the owner CPropertyPage class.

Step 5 Be sure the size of the outer proeprty page is bigger
than the inner property sheet. Both are resized using the
resource editor. You can play with the line
m_pPropFrame->CenterWindow()
above, if you want the inside property sheet positioned differently.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 30
Detect CR LF to each line 12 137
either24  challenge 19 84
pre4 challenge 19 88
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 …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

18 Experts available now in Live!

Get 1:1 Help Now