Child windows overlapping scroll/status & toolbars 
Author Message
 Child windows overlapping scroll/status & toolbars

Hello again people :o),

After banging my head against a brick wall, I still can't figure a way
around this.

Scenario:
 I have an SDI (FormView based) application.  I also have a button in
the toolbar to toggle on and off the ability to hide/display a child
window that represents some portion of data in my document class.

Problems:
 1.  Although the child window can be displayed/hidden, repositioned and
resized,  the title bar always remains greyed out, as though it's always
inactive (nothing major yet, just annoying UI feedback).  But...
 2. Dragging the window around inside its parents frame (the main frame
window in this case) causes the parent window scroll bars, status bars
and toolbars to be occluded by the child window - it never goes behind
them - its *always* drawn in front of them!!!

 The Code:
 Here's how I create, display and toggle the child window:

void CMainFrame::OnButtonShowGaussianMixture()  {

 if (  m_gFlag = !m_gFlag ) { // Toggle the display flag
  if ( !m_theFrame ) {    // If the window is not yet created, then...

   m_theFrame = new CFrameWnd;
   m_theFrame->Create( NULL , "Gaussian Mixture", WS_CHILD | WS_CAPTION
| WS_THICKFRAME, CRect( 0, 0, 300, 300 ), this );

   CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( MyView );
   CObject* pObject = pRuntimeClass->CreateObject();
   m_theView = (MyView*)pObject;

   CTestDoc *pDoc = (CTestDoc*)GetActiveDocument();
   CCreateContext *cc = new CCreateContext;
   cc->m_pNewViewClass = pRuntimeClass;
   cc->m_pCurrentDoc = pDoc;
   cc->m_pNewDocTemplate = NULL;
   cc->m_pLastView = NULL;
   cc->m_pCurrentFrame = NULL;
   m_theFrame->CreateView( cc );
   delete cc;

   m_theFrame->ActivateFrame( );
  }
  else
    m_theFrame->ActivateFrame( );  // Otherwise, the window already
exists, so just display it.
   }
 }
 else
   m_theFrame->ActivateFrame( SW_HIDE );  // It's being displayed, so
now hide it

Quote:
}

Please could one of you MFC gurus point out my mistakes!!!

Thanks

Paul...



Tue, 14 Aug 2001 03:00:00 GMT  
 Child windows overlapping scroll/status & toolbars
Do I understand you right - you use a CFrameWnd as the child? It will be an
overlapped window and have a style giving the results you describe. If that
is the case: create a window derived from CWnd instead, and apply visual
styles as desired.

Johan Rosengren
Responsable Informatique
PACTA S.A.



Wed, 15 Aug 2001 03:00:00 GMT  
 Child windows overlapping scroll/status & toolbars

Hi,

Quote:
> Do I understand you right - you use a CFrameWnd as the child? It will be an
> overlapped window and have a style giving the results you describe. If that
> is the case: create a window derived from CWnd instead, and apply visual
> styles as desired.

Thanks for the advice.  I've tried out your suggestion but I still think it's something I'm doing
wrong.  I've derived a class from CWnd and CView, created the view using RUNTIME_CLASS(), created
CWnd using 'new' and then Create().  I use the CCreateContext class to 'attach' my view to the
window.  But I'm experiencing all the same problems as before.  Except this time no client area of
the frame exists (as though only the frame gets drawn), and you can't activate or move the child
frame around!  It just stays 'stuck' to the parent frame - drawn on top of the toolbar.

Anyway, I've moved on to something else now - I'll give it another go someother time [still, any
more suggestions are welcomed :)]

Paul...



Mon, 20 Aug 2001 03:00:00 GMT  
 Child windows overlapping scroll/status & toolbars
Paul!

This is also expected behavior. A child window cannot be moved around (you
don't want to rearrange the buttons in a dialog, for example!). It will also
be located where you put it, wether it be above a toolbar or not. When it is
time to revisit this area, I guess I'll still be trawling around here -
waiting to confuse the unprepared poster...

Johan Rosengren
Responsable Informatique
PACTA S.A.



Mon, 20 Aug 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Child windows overlapping scroll/status & toolbars

2. Overlapping controls/child windows/dialogs/?????

3. overlapping child window

4. Overlapping controls/child windows/dialogs/????

5. Toolbar & Status bar in CDialog

6. Toolbar & Status bar in CDialog

7. Status bar in child window

8. Scrolling Text in a Status window...

9. Main & Child toolbar hiding

10. Prevent child windows from scrolling

11. Scroll child window?

12. Q: how to scroll child windows

 

 
Powered by phpBB® Forum Software