Use CFormView as child of a Tab Control? 
Author Message
 Use CFormView as child of a Tab Control?

Use CFormView as child of a Tab Control?

Hi,

I am really stumped. I have a tab control being created as a child in a
view. I would like to display a child CFormView window (so I can use scroll
bars under the tabs to help display long dialogs). An example of this is the
right panel of the 3D Studio Max application.

Below is the code that has so far successfully created the tab control in
the window, but the CFormView child window is not showing up, though this
will compile without errors. Is the code, or approach wrong, or is there a
better way to achieve this?

Thanks for your help, I really should be working on issues beyond the user
interface at this point, so any advice will be really appreatiated.

Scott Kerr

Here is the code:

int CViewTools::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
     if (CView::OnCreate(lpCreateStruct) == -1)
     return -1;

    // TODO: Add your specialized creation code here

     RECT myRect;
     myRect.bottom = 100;
     myRect.left = 0;
     myRect.right = 300;
     myRect.top = 0;

     m_ToolTab.Create( TCS_TABS | TCS_FIXEDWIDTH | WS_CHILD | WS_VISIBLE,
                                myRect, this,  0x1006);

////////////////////////////////////////////////////////////////////////////
//////////////////////
    // I had to make the CFormViewCeiling and ~CFormViewCeiling functions
public for this to work!

////////////////////////////////////////////////////////////////////////////
//////////////////////

    CFormViewCeiling m_CFormViewCeiling;

    if (!m_CFormViewCeiling.Create( _T("CFormViewCeiling"),
     "Test",
     WS_VISIBLE|WS_CHILD|WS_BORDER | WS_VSCROLL,
     myRect,
     this,
     0x1009,
     NULL)
   )
  {
       TRACE0("Failed to Create m_CFormViewCeiling\n");
       return -1;
  }

  m_CFormViewCeiling.ShowWindow(SW_SHOW);
  m_CFormViewCeiling.BringWindowToTop();

  return 0;

Quote:
}



Wed, 13 Apr 2005 15:02:26 GMT  
 Use CFormView as child of a Tab Control?

Quote:

> Use CFormView as child of a Tab Control?

> Hi,

> I am really stumped. I have a tab control being created as a child in a
> view. I would like to display a child CFormView window (so I can use scroll
> bars under the tabs to help display long dialogs). An example of this is the
> right panel of the 3D Studio Max application.

> Below is the code that has so far successfully created the tab control in
> the window, but the CFormView child window is not showing up, though this
> will compile without errors. Is the code, or approach wrong, or is there a
> better way to achieve this?

> Thanks for your help, I really should be working on issues beyond the user
> interface at this point, so any advice will be really appreatiated.

> Scott Kerr

> Here is the code:

> int CViewTools::OnCreate(LPCREATESTRUCT lpCreateStruct)
> {
>      if (CView::OnCreate(lpCreateStruct) == -1)
>      return -1;

>     // TODO: Add your specialized creation code here

>      RECT myRect;
>      myRect.bottom = 100;
>      myRect.left = 0;
>      myRect.right = 300;
>      myRect.top = 0;

>      m_ToolTab.Create( TCS_TABS | TCS_FIXEDWIDTH | WS_CHILD | WS_VISIBLE,
>                                 myRect, this,  0x1006);

> ////////////////////////////////////////////////////////////////////////////
> //////////////////////
>     // I had to make the CFormViewCeiling and ~CFormViewCeiling functions
> public for this to work!

> ////////////////////////////////////////////////////////////////////////////
> //////////////////////

>     CFormViewCeiling m_CFormViewCeiling;

>     if (!m_CFormViewCeiling.Create( _T("CFormViewCeiling"),
>      "Test",
>      WS_VISIBLE|WS_CHILD|WS_BORDER | WS_VSCROLL,
>      myRect,
>      this,
>      0x1009,
>      NULL)
>    )
>   {
>        TRACE0("Failed to Create m_CFormViewCeiling\n");
>        return -1;
>   }

>   m_CFormViewCeiling.ShowWindow(SW_SHOW);
>   m_CFormViewCeiling.BringWindowToTop();

>   return 0;

> }

The first problem is that you created the view object as a local
variable instead of member variable.  Local variables are destroyed when
the enclosing function returns.

The second problem is that views require some initialization that is
normallly provided by their parent frame window.  This initialization
includes setting the m_pDocument member variable and sending the
WM_INITIALUPDATE message.  For an example of how you can do this see the
CreateView member function in the CSplitterWnd MFC source code.

You will also probably need to manage the view size, another service
that is normally provided by the parent frame window.  Use
pview->MoveWindow initially, and if the parent is resizeable you also
need to resize the view from the parent's WM_SIZE handler.

--
Scott McPhillips [VC++ MVP]



Wed, 13 Apr 2005 21:16:26 GMT  
 Use CFormView as child of a Tab Control?
Excellent Scott, I'll get on this right away. Thanks!

Scott Kerr



Wed, 13 Apr 2005 23:29:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Use CFormView as child of a Tab Control?

2. Use CFormView as child of a Tab Control?

3. Using dialogs as children of a tab control

4. TAB key, controls and child windows with controls

5. Cannot press tab to move to a tab control after using WS_EX_CONTROLPARENT

6. Tab Control in CFormView

7. How to Add a tabbed control to CFormView???

8. A tab control on a CFormView.

9. Accessing Tab Controls in CFormView to retrieve data

10. How to Add a tabbed control to CFormView???

11. CFormView control not created in Child Class

12. CFormView, children of children and Background erasing

 

 
Powered by phpBB® Forum Software