Tabs under tab(PropertySheet under PropertyPage)

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 .

usmaniAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WBerthinCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.