• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

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 .

0
usmani
Asked:
usmani
1 Solution
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now