15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Can I auto re-size a CSplitter on creation for various

Thomas Bonnes -- bonnes@ssnet.com
Saturday, April 27, 1996

 I have a MDI  three view CSplitter project:

 _____________________ ____________
|                     |            |
|         View1       |   View 2   |
|                     |            |
|                     |____________|
|                     |            |
|                     |    View3   |
|_____________________|____________| 

      I can create the views, then when the program starts my left view is
much larger on my 640/480 mode than when I use the same program on a higher
resolution.  The views are:  view1 is a CScrollView, the view2 is a
CFormView, and the View3 is a CView.  I create the view's with the following
code:


******************************************************
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
pContext) 
{
	if(!m_wndSplitter.CreateStatic(this, 1, 2))
	 	return FALSE;
	 if(!m_wndSplitter.CreateView(0,0, RUNTIME_CLASS(CBaseBall1View
			), CSize(600, 50), pContext))
	 	return FALSE;
	  if(!m_wndSplitter2.CreateStatic(&m_wndSplitter, 2, 1, 
 			WS_CHILD | WS_VISIBLE | WS_BORDER, 
 			m_wndSplitter.IdFromRowCol(0, 1) ))
 		return FALSE;
	 int cyText = max(lpcs->cy -210, 350);
	if(!m_wndSplitter2.CreateView(0,0,
			RUNTIME_CLASS(ShowGameNumber), CSize(0, cyText), pContext))
		return FALSE;
	if(!m_wndSplitter2.CreateView(1,0,
			RUNTIME_CLASS(GraphView), CSize(0,220), pContext))
		return FALSE;
return TRUE;
}
******************************************************

	Is there a way of telling the size of the MDI Child Frame before I call
"CreateView()" so I can use relative coordinates to set my view's sizes?

Thanks,
Tom Bonnes      bonnes@ssnet.com




Niels Ull Jacobsen -- nuj@kruger.dk
Wednesday, May 01, 1996

At 19:41 27-04-96 -0400, you wrote:
> I have a MDI  three view CSplitter project:
>
> _____________________ ____________
>|                     |            |
>|         View1       |   View 2   |
>|                     |            |
>|                     |____________|
>|                     |            |
>|                     |    View3   |
>|_____________________|____________|=20
>
>      I can create the views, then when the program starts my left view is
>much larger on my 640/480 mode than when I use the same program on a higher
>resolution.  The views are:  view1 is a CScrollView, the view2 is a
>CFormView, and the View3 is a CView.  I create the view's with the=
 following
>code:
>
>
>******************************************************
>BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
>pContext)=20
>{
>	if(!m_wndSplitter.CreateStatic(this, 1, 2))
>	 	return FALSE;
>	 if(!m_wndSplitter.CreateView(0,0, RUNTIME_CLASS(CBaseBall1View
>			), CSize(600, 50), pContext))
...
>}
>******************************************************
>
>	Is there a way of telling the size of the MDI Child Frame before I call
>"CreateView()" so I can use relative coordinates to set my view's sizes?

Look in the LPCREATESTRUCT?

>
>Thanks,
>Tom Bonnes      bonnes@ssnet.com
>
>
>
>
Niels Ull Jacobsen, Kr=FCger A/S (nuj@kruger.dk)
Everything stated herein is THE OFFICIAL POLICY of the entire Kruger group
and should be taken as legally binding in every respect. Pigs will grow
wings and fly.








Thomas J. Bonnes -- bonnes@Bonnes
Wednesday, May 01, 1996

Thanks Roy,
        I used your example but changed it a bit(due to my not wanting 
exactly an even split), and had an NON_EXPECTED result. I show what I did 
below your included text.  I am wondering if you or someone can explain 
what is going on.

	I have a theory, but I am not sure.



> >      I can create the views, then when the program starts my left view
is
> >much larger on my 640/480 mode than when I use the same program on a
higher
> >resolution.  The views are:  view1 is a CScrollView, the view2 is a
> >CFormView, and the View3 is a CView.  I create the view's with the
following
> >code:
> >Tom Bonnes      bonnes@ssnet.com
> 
> Tom;
> 
> The following is working for me.
> 
> Roy Browning
> 
>
///////////////////////////////////////////////////////////////////////////
>     CRect   clientArea;
>     GetClientRect( &clientArea );
>     CSize   evenSplit( ( clientArea.right >> 1 ), clientArea.bottom );
>         
>     // create a splitter with 1 row, 2 columns
>     if ( !m_wndSplitter.CreateStatic( this, 1, 2 ) )
>     {
>         TRACE0("Failed to CreateStaticSplitter\n");
>         return FALSE;
>     }
> 
>     // add the first splitter pane - the default view in column 0
>     if (!m_wndSplitter.CreateView( 0, 0,
>         pContext->m_pNewViewClass, evenSplit, pContext ) )
>     {
>         TRACE0("Failed to create first pane\n");
>         return FALSE;
>     }
>
////////////////////////////////////////////////////////////////////////////----
 
        Now what I wanted was not an even split view, I wanted the view 
to be about 14/18ths the horrizontal distance when I created the split on the
vertical.  I was finally able to get the desired split using basically a 1:1
ratio(I kept increasing the ratio until I sized it like I wanted).  I thought
this 1:1 ratio  would fill up my client area totally??  I am now 
"guessing" that when inside OnCreateClient(......) the sizing takes place 
"before" my view is actually shown, which is later shown *maximized* 
insided the frame. 

        I also found that when I did a File/New menu command to create a new
window, I had a different split ratio, than the first view created.  All new
documents opened would had that same size, not the size of the first one
created.  So I used the following code, to basically get what I wanted(it 
seems to work).  I now get the same size split(basically) on the first 
document opened as I do on all following new windows. Can someone explain 
what is exactly going on here, and also might I handle the sizing in a 
better or different place.




BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
pContext) 
{
       CRect clientArea;

       GetClientRect(&clientArea);
       CSize splitView;
       CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;

            // Added this flag to allow the sizing to know the first time
	    //created
        if(pFrame->FirstFrame == TRUE)
        {
                splitView = CSize((int)((clientArea.right/18.000)*18.000),
			clientArea.bottom);
                pFrame->FirstFrame = FALSE;  //would not work for my desired
			14/18ths size wanted
        }
        else
        {
                splitView = CSize((int)((clientArea.right/18.000)*14.000),
			clientArea.bottom);
        }
                if(!m_wndSplitter.CreateStatic(this, 1, 2))
                        return FALSE;
                if(!m_wndSplitter.CreateView(0,0, 
			RUNTIME_CLASS(CBaseBall1View),
			splitView, pContext))
                        return FALSE;
                 if(!m_wndSplitter2.CreateStatic(&m_wndSplitter, 2, 1,

                        WS_CHILD | WS_VISIBLE | WS_BORDER,

                        m_wndSplitter.IdFromRowCol(0, 1) ))
                        return FALSE;
                int cyText = max(lpcs->cy -210, 350);
                if(!m_wndSplitter2.CreateView(0,0,
                        RUNTIME_CLASS(ShowGameNumber), CSize(0, cyText),
				pContext))
                        return FALSE;
                if(!m_wndSplitter2.CreateView(1,0,
                        RUNTIME_CLASS(GraphView), CSize(0,220), pContext))
                        return FALSE;
          
        return TRUE;
}


****************************************************
************ THE ORIGINAL NOTE BELOW   *************
****************************************************
> I have a MDI  three view CSplitter project:
> 
>  _____________________ ____________
> |                     |            |
> |         View1       |   View 2   |
> |                     |            |
> |                     |____________|
> |                     |            |
> |                     |    View3   |
> |_____________________|____________| 
> 
>       I can create the views, then when the program starts my left view is
much
> larger on my 640/480 mode than when I use the same program on a higher
> resolution.  The views are:  view1 is a CScrollView, the view2 is a 
CFormView,
> and the View3 is a CView.  I create the view's with the following code:
> 
> 
> ******************************************************
> BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
pContext)
> {
>         if(!m_wndSplitter.CreateStatic(this, 1, 2))
>                 return FALSE;
>          if(!m_wndSplitter.CreateView(0,0, RUNTIME_CLASS(CBaseBall1View
>                         ), CSize(600, 50), pContext))
>                 return FALSE;
>           if(!m_wndSplitter2.CreateStatic(&m_wndSplitter, 2, 1, 
>                         WS_CHILD | WS_VISIBLE | WS_BORDER, 
>                         m_wndSplitter.IdFromRowCol(0, 1) ))
>                 return FALSE;
>          int cyText = max(lpcs->cy -210, 350);
>         if(!m_wndSplitter2.CreateView(0,0,
>                         RUNTIME_CLASS(ShowGameNumber), CSize(0, cyText),
> pContext))
>                 return FALSE;
>         if(!m_wndSplitter2.CreateView(1,0,
>                         RUNTIME_CLASS(GraphView), CSize(0,220), pContext))
>                 return FALSE;
> return TRUE;
> }
> ******************************************************
> 
>         Is there a way of telling the size of the MDI Child Frame 
before I
call
> "CreateView()" so I can use relative coordinates to set my view's sizes?
> 
> Thanks,
> Tom Bonnes      bonnes@ssnet.com





| Вернуться в корень Архива |